You are on page 1of 1

Sheet 6

For questions 1:6, use files in the “NodeList” folder that contains the doubly linked
list class with iterator class starting at P.242 in your textbook.
1- Test your code by reading as many numbers as the user wishes and store them in
a NodeList then using an iterator print the stored numbers.
2- Add a public function called copy that copies a fraction of a NodeList and pastes it
in the same NodeList. The function takes the start, stop iterators for the source,
and the start iterator for the destination.
3- Add to the class functions similar to those of vector of P.251, 252.
4- Add to the class functions similar to those of vector of P.253 except for_each.
5- Add operator +() that concatenates two NodeLists (using iterators) in a third one.
6- Add operator −() that returns a NodeList containing the difference between two
NodeLists( using iterator).
A−B={ai ∈ A , ai ∉ B }
7- Implement sequence and rewrite 5 using sequence and iterator.

1- Implement a LinkedStack and add an iterator that looks like that in P.243 except
operato−−( ) and iterates only from the top of the stack to the bottom.
2- Use the iterator written in 7 to print a Stack in the main from top to bottom.
3- Use the iterator written in 7 to sort a Stack in the main.
4- Update 7 to Implement StackSquence. Implement the operations stated in P.255 and test
the sequence in printing the stack.
5- Update 7 to add the algorithm functions stated in P.253 except for_each. Each returns an
STL vector of P.236.

You might also like