please very importent ( double linked list )

Please support our C++ advertiser: Intel Parallel Studio Home
Reply

Join Date: Aug 2009
Posts: 3
Reputation: ju_10_ve is an unknown quantity at this point 
Solved Threads: 0
ju_10_ve ju_10_ve is offline Offline
Newbie Poster

please very importent ( double linked list )

 
0
  #1
Aug 1st, 2009


plz i wont soulotion of my questions by codes :


where list is the node pointer for the whole double linked list
how i can :

1- add a node after the node that has 30

2- delete a node at the beginning of the list

3- delete a node before 30

4- count how many nodes are in the list

5- count how many nodes are greater than 10

6- count how many even %odd nodes in the list !!

7- print all the nodes in the list but ( backwards )

8- split the double list into 2 , where the first list has a pointer list and the other one has the pointer head , and it starts with the node 15 !!


make answer what you know plz

Last edited by ju_10_ve; Aug 1st, 2009 at 8:03 pm.
Reply With Quote Quick reply to this message  
Join Date: Dec 2008
Posts: 1,235
Reputation: firstPerson is just really nice firstPerson is just really nice firstPerson is just really nice firstPerson is just really nice firstPerson is just really nice 
Solved Threads: 153
firstPerson's Avatar
firstPerson firstPerson is offline Offline
Nearly a Posting Virtuoso

Re: please very importent ( double linked list )

 
0
  #2
Aug 1st, 2009
What have you tried?
Reply With Quote Quick reply to this message  
Join Date: Jun 2008
Posts: 255
Reputation: Hiroshe is a jewel in the rough Hiroshe is a jewel in the rough Hiroshe is a jewel in the rough Hiroshe is a jewel in the rough 
Solved Threads: 16
Hiroshe's Avatar
Hiroshe Hiroshe is offline Offline
Posting Whiz in Training

Re: please very importent ( double linked list )

 
1
  #3
Aug 1st, 2009
1. We will not just give you the code. We might however, help you find problems in code you have already written or tell you how to approch a particular problem.

2. What do you mean by a double linked list? Do you mean a nested linked list (a list inside a list).

3. Make that list of question's more clear! Look at question 1:
>1- add a node after the node that has 30
30 what?

4. Don't bold your entire message.
"Sometimes, when I lie in bed at night and look up at the stars, I think to myself, "Man! I really need to fix that roof."-Jack Handy
Reply With Quote Quick reply to this message  
Join Date: Aug 2009
Posts: 3
Reputation: ju_10_ve is an unknown quantity at this point 
Solved Threads: 0
ju_10_ve ju_10_ve is offline Offline
Newbie Poster

Re: please very importent ( double linked list )

 
0
  #4
Aug 2nd, 2009
Originally Posted by firstPerson View Post
What have you tried?
i solved other questions !!
Reply With Quote Quick reply to this message  
Join Date: Aug 2009
Posts: 3
Reputation: ju_10_ve is an unknown quantity at this point 
Solved Threads: 0
ju_10_ve ju_10_ve is offline Offline
Newbie Poster

Re: please very importent ( double linked list )

 
0
  #5
Aug 2nd, 2009
Originally Posted by Hiroshe View Post
1. We will not just give you the code. We might however, help you find problems in code you have already written or tell you how to approch a particular problem.

2. What do you mean by a double linked list? Do you mean a nested linked list (a list inside a list).

3. Make that list of question's more clear! Look at question 1:
>1- add a node after the node that has 30
30 what?

4. Don't bold your entire message.



double linked list .. in the web :

http://upload.wikimedia.org/wikipedi...inked_list.png


and the question 1 its mean the 30 inside the node
Reply With Quote Quick reply to this message  
Join Date: Jun 2008
Posts: 255
Reputation: Hiroshe is a jewel in the rough Hiroshe is a jewel in the rough Hiroshe is a jewel in the rough Hiroshe is a jewel in the rough 
Solved Threads: 16
Hiroshe's Avatar
Hiroshe Hiroshe is offline Offline
Posting Whiz in Training

Re: please very importent ( double linked list )

 
0
  #6
Aug 2nd, 2009
Originally Posted by ju_10_ve View Post
double linked list .. in the web :

http://upload.wikimedia.org/wikipedi...inked_list.png


and the question 1 its mean the 30 inside the node
Again, 30 what? Do you mean the value 30 in an integer?
Why not get your hands a little dirty, eh? Post your code of a doubly linked list. Also post the for a node counter function, even if it dosen't work. If it dosen't work, post your compiler output and tell us why you think it dosen't work.
If you can do that, we will gladly help you. Good luck.
"Sometimes, when I lie in bed at night and look up at the stars, I think to myself, "Man! I really need to fix that roof."-Jack Handy
Reply With Quote Quick reply to this message  
Join Date: Mar 2005
Posts: 464
Reputation: invisal is a jewel in the rough invisal is a jewel in the rough invisal is a jewel in the rough 
Solved Threads: 49
invisal's Avatar
invisal invisal is offline Offline
Posting Pro in Training

Re: please very importent ( double linked list )

 
1
  #7
Aug 2nd, 2009
If you truly understand the concept of doubly-linked list, these problems would be very easy. Lets start with basic doubly-linked list concept. Doubly-linked list data structure consist of 3 important components: set of data, pointer to address of previous data (*prev), and pointer to address of next data (*next). When you learn linked-list, you will often heard the term "node". Node is simply just a record.

NULL <---  [*prev|data|*next] <---> [*prev|data2|*next] <--> [*prev|data3|*next] --> NULL

Let say that we have kth nodes and we want to display all of data out into the screen. Assuming plist is the address of our first node.

  1. while (plist != NULL) {
  2. std::cout << plist->data;
  3. plist = plist->next;
  4. }

To count total nodes, to count nodes that have even or odd data value, or to print backward also use this technique except with some extra conditions.

To add new node in, no matter at what position it will be inserted in (at beginning, at middle, or at the end), you need to allocate memory location to store new node and assign proper *next and *prev address. For example, you want to insert new node at the end of your list. To do so, you need to know the address of your last node. Then, assign the *prev of the new node to the address of the last node and then *next of the new node point to NULL which to determine that it is the end of the list. Then *next of the last node must assign to the address of the new node.

1. Allocating memory for new node (the red text represent new node)
NULL <---  [*prev|data|*next] <---> [*prev|data2|*next] --> NULL        [*prev|new_data|*next]
2. Assign *prev of new node and *next of last node (Connecting)
NULL <---  [*prev|data|*next] <---> [*prev|data2|*next] <-->  [*prev|new_data|*next]
3. Assign *next of the new node to NULL
NULL <---  [*prev|data|*next] <---> [*prev|data2|*next] <-->  [*prev|new_data|*next] --> NULL

Last but not least, removing the node from the list is also important. First you need to know the address of the node you want to delete. Then connect the previous node of node you want to delete to its next node. Then de-allocate its memory

1. (Red-text represent node you want to delete)
NULL <---  [*prev|data|*next] <---> [*prev|data2|*next] <--> [*prev|data3|*next] --> NULL

2. Connect its previous node to its next node
NULL <---  [*prev|data|*next] <-------------------------> [*prev|data3|*next] --> NULL
                               [*prev|data2|*next]

3. De-allocating its memory
NULL <---  [*prev|data|*next] <---> [*prev|data3|*next] --> NULL

So the most important thing about linked-list is about assigning the right address of next and previous node. More information, go to http://en.wikipedia.org/wiki/Doubly-linked_list.

These should give half of the answer of your questions and it's matter of how to figure another half of the answer.
Last edited by invisal; Aug 2nd, 2009 at 3:13 pm.
Yesterday is a history, tomorrow is a mystery, today is a gift.
Behind every smile is a tear.
Visal .In
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:


Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC