• 100% Satisfaction Guarantee

Ingo U, Software Engineer
Category: Programming
Satisfied Customers: 755
Experience:  Over 25 years experience in software development. Expert in Microsoft .Net, C#, C++, VB, SQL
44076068
Ingo U is online now

# I have this linked list in c++ and i would like to know how

### Resolved Question:

I have this linked list in c++ and i would like to know how to delete the middle node and link the 1st node to the 3rd node so the values can be printed out:
#include
using namespace std;
struct Node {
string str;
Node *next;
};
int main() {
string entry;
Node *root;
Node *trav;
root = new Node;
cout <> entry;
cout < str = entry;
trav = root;
trav -> next = new Node;
trav = trav -> next;
cout <> entry;
cout < str = entry;
trav -> next = new Node;
trav = trav -> next;
cout <> entry;
cout < str = entry;
trav -> next = NULL;
trav = root;
while(trav != NULL) {
cout < str < next;
}
// code here
while(trav != NULL) {
cout < str < next;
}
cout << endl;
return 0;
}
Submitted: 1 year ago.
Category: Programming
Expert:  Ingo U replied 1 year ago.
Hello again,
how general of a solution do you need?
- Will the list have exactly 3 nodes, no more no less?
- How to identify the node to delete? Only by its position, #2 ?
The steps needed are slightly different for the first node of a list vs. the last node vs. any node in between.
Thanks,
Ingo
Customer: replied 1 year ago.

There are 3 nodes. I'd like to know how to remove the 2nd node, the 1st node and the 3rd node: http://pastebin.com/28Z8CGFw

Expert:  Ingo U replied 1 year ago.
Here's the code:
As you'll see you have to uncomment one of the 3 blocks of code to delete 1st, 2nd or 3rd node.
Ingo U, Software Engineer
Category: Programming
Satisfied Customers: 755
Experience: Over 25 years experience in software development. Expert in Microsoft .Net, C#, C++, VB, SQL

### What Customers are Saying:

• My Expert answered my question promptly and he resolved the issue totally. This is a great service. I am so glad I found it I will definitely use the service again if needed. One Happy Customer
< Previous | Next >
• My Expert answered my question promptly and he resolved the issue totally. This is a great service. I am so glad I found it I will definitely use the service again if needed. One Happy Customer
• Wonderful service, prompt, efficient, and accurate. Couldn't have asked for more. I cannot thank you enough for your help. Mary C.
• This expert is wonderful. They truly know what they are talking about, and they actually care about you. They really helped put my nerves at ease. Thank you so much!!!! Alex
• Thank you for all your help. It is nice to know that this service is here for people like myself, who need answers fast and are not sure who to consult. GP
• I couldn't be more satisfied! This is the site I will always come to when I need a second opinion. Justin
• Just let me say that this encounter has been entirely professional and most helpful. I liked that I could ask additional questions and get answered in a very short turn around. Esther
• Wonderful service, prompt, efficient, and accurate. Couldn't have asked for more. I cannot thank you enough for your help. Mary C.

• ### ATLPROG

#### Satisfied Customers:

7260
MS in IT.Several years of programming experience in Java C++ C C# Python VB Javascript HTML
< Previous | Next >

### ATLPROG

#### Satisfied Customers:

7260
MS in IT.Several years of programming experience in Java C++ C C# Python VB Javascript HTML

### LogicPro

#### Satisfied Customers:

5514
Expert in C, C++, Java, DOT NET, Python, HTML, Javascript, Design.

### lifesaver

#### Satisfied Customers:

936
Several years of intensive programming and application development experience in various platforms.

### ehabtutor

#### Satisfied Customers:

766
Bachelor of computer science, 5+ years experience in software development, software company owner

### Eljon

#### Satisfied Customers:

558
Founder of StockCanvas.com

### Rafael Martins

#### Satisfied Customers:

446
Desktop, Mobile and Web Developer. 7+ years of experience. Creative solutions provider.

### The-PC-Guy

#### Satisfied Customers:

320
Extensive Knowledge in PHP, MYSQL, CSS & Javascript