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

:'(

What have you tried?

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.

commented: Many fine points +36

What have you tried?

i solved other questions !!

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 :

and the question 1 its mean the 30 inside the node

double linked list .. in the web :

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.

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|[B]data[/B]|*next] <---> [*prev|[B]data2[/B]|*next] <--> [*prev|[B]data3[/B]|*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.

while (plist != NULL) {
std::cout << plist->data;
plist = plist->next;
}

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|[B]data[/B]|*next] <---> [*prev|[B]data2[/B]|*next] --> NULL        [*prev|[B]new_data[/B]|*next]

2. Assign *prev of new node and *next of last node (Connecting)

NULL <---  [*prev|[B]data[/B]|*next] <---> [*prev|[B]data2[/B]|*next] <-->  [*prev|[B]new_data[/B]|*next]

3. Assign *next of the new node to NULL

NULL <---  [*prev|[B]data[/B]|*next] <---> [*prev|[B]data2[/B]|*next] <-->  [*prev|[B]new_data[/B]|*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|[B]data[/B]|*next] <---> [*prev|[B]data2[/B]|*next] <--> [*prev|[B]data3[/B]|*next] --> NULL

2. Connect its previous node to its next node

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

3. De-allocating its memory

NULL <---  [*prev|[B]data[/B]|*next] <---> [*prev|[B]data3[/B]|*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.

commented: Consider posting this as a tutorial! +4
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.