What is the output of these statements, using your sequence ADT implemented as a linked list with Item defined as integer:
sequence x;
sequence y;
x.insert(41); // Inserts 41 into the sequence x
x.insert(42); // Inserts 42, so that x is now 42, 41 with cursor at front
y = x;
x.attach(43); // Attaches 43 so that x is now 42, 43, 41 with cursor at 43
y.advance( );
cout %26lt;%26lt; "y size is " %26lt;%26lt; y.size( );
cout %26lt;%26lt; " and y current item is " %26lt;%26lt; y.current( ) %26lt;%26lt; endl;
A. y size is 2 and y current item is 41.
B. y size is 2 and y current item is 43.
C. y size is 3 and y current item is 41.
D. y size is 3 and y current item is 43.
E. None of the above.
This is a Data Structure question ( linked lists) can anyone help?
I don't have your sequence ADT implemented as a linked list, but if I were to take an educated guess, C would have to be the answer.
No comments:
Post a Comment