in order list

Implement an inorder list using a dummy head node and a doubly linked list. Your
implementation should have the following methods: first, next, insert, remove,
print and reverse. The default should be for inserting elements in an ascending
order, but a call to the reverse function should reverse the contents of the list as well
as reverse the order in which elements are to be inserted so if it was ascending it
should be descending and vice versa. The following code should thus result in the
shown output:
L.insert (5); L.insert(6); L.insert (1); L.insert (2); L. print();
Output: 1, 2, 5, 6
L.reverse(); L. print();
Output: 6, 5, 2, 1
L.insert(7); L.insert (3); L.print()
Output: 7, 6, 5, 3, 2, 1
L.reverse();L.insert(4); L.insert (9); L.print()
Output: 1, 2,3, 4, 5, 6, 7, 9
L.remove(2); L.remove(9); L.print()
Output: 1, 3, 4, 5, 6, 7
closed account (z05DSL3A)
http://www.cplusplus.com/articles/how_to_ask/
Uni assignment?
Couldnt you ask a specific problem rather than asking us to do your homework?
Topic archived. No new replies allowed.