Howdy, Stranger!

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

Categories

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;
private:
elementType data;
node1 * next;
};

class node2{
friend class list2;
private:
elementType data;
node2 * next;
node2 * prev;
};

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

private:
node1 * first;
};


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

private:
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.