Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!


need help in this question of linklist

vnayakvnayak Member Posts: 16
hi everyone..I had a test today and one thing which i could not answer of this question..this is given .

typedef int elementType;

class node1{
friend class list1;
elementType data;
node1 * next;

class node2{
friend class list2;
elementType data;
node2 * next;
node2 * prev;

class list1 {
list1() {first =NULL;}//constructor
. . . //other member functions

node1 * first;

class list2 {
list2() {first =NULL;}//constructor
. . . //other member functions

node2 * first;

question is..

1. Consider the following code in a member function of the list1 class. Draw the linked list that is the result of executing the following code.

node1 * q = new node1;
first = new node1;
first->data = 33;
q->data =44;
node1 * p = new node1;
p->data = 55;
p->next = q;
q->next = first;
q = new node1;
q->data =45;
q->next = NULL;
first->next = q;
first = p;

plz let me know if anyone knows its answer..

Sign In or Register to comment.