8.9k views
3 votes
Assume that you have implemented a sequence class. Describe the mySequence object (i.e., items with the correct order and the position of the current index) after each line of the following code

sequence mySequence;
mySequence.insert(3)
mySequence.insert(2);
mySequence.attach(10);
mySequece.advance();
mySequence.attach(11);
mySequence.insert(4);
mySequence.insert(6);
mySequece.advance();
mySequence.remove_current();
mySequence.insert(9);

User Renjith
by
4.4k points

1 Answer

5 votes

Answer:

The final sequence is: 2 10 3 6 9(c) 11

Step-by-step explanation:

The first line of code creates the sequence object "mySequence". Every insert() method inserts the item before the current item to make a new current item. The attach() method adds a new current item after the previous current item. The advance() method makes the next item to the current item the new current item.

The remove_current method of the sequence object removes the current item of the sequence.

User Yoosuf
by
4.7k points