Exercises
The following exercises provide you with the opportunity to practice with linked lists. The solutions to these exercises are found in the section Chapter 14.
-
Add a method to the classic LinkedList class that prints all the values of the list.
-
Add a method to the DoublyLinkedList class that prints all the values of the list in reverse order.
-
Add a method to the classic LinkedList class that returns the last value from the list. Assume you don’t know how many elements are in the list.
-
Here’s a tricky one. Add a method to the classic LinkedList class that reverses the list; that is, if the original list is A -> B -> C, all of the list’s links should change so that C -> B -> A.
-
Here’s a brilliant little linked list puzzle for you. Let’s ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access