0% found this document useful (0 votes)
3 views2 pages

LinkedList and DLL Methods Tutorial

The document outlines problems related to list and double linked list (DLL) operations in a tutorial for CSC 212. It includes tasks such as writing methods for reversing a list, performing circular left shifts, removing elements between two specified elements, and copying elements in reverse order from one list to another. Each problem is accompanied by examples to illustrate the expected outcomes.

Uploaded by

nmnq2015
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
3 views2 pages

LinkedList and DLL Methods Tutorial

The document outlines problems related to list and double linked list (DLL) operations in a tutorial for CSC 212. It includes tasks such as writing methods for reversing a list, performing circular left shifts, removing elements between two specified elements, and copying elements in reverse order from one list to another. Each problem is accompanied by examples to illustrate the expected outcomes.

Uploaded by

nmnq2015
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

CSC 212 Tutorial #3

List & DLL

Problem 1
Method: reverse( ): requires: none. input: none. results: elements of the list
will be stored in reverse order. output: none.

Example 1.1. Given the list: 20, 11, 44, 33, 50, 44, reverse() results in: 44, 50, 33, 44, 11, 20

1. Write the reverse method as an implementer of the LinkedList ADT

2. Write the reverse method as a user of the List ADT

Problem 2
Write the method circularLeftShift, user of List ADT, that takes as input a non-empty
List list and an integer n > 0 and performs n circular left shift of the list.

Example 2.1. Given the list l : A, B, C, D, E, circularShiftLeft(l, 1) results in


B, C, D, E, A, circularShiftLeft(l, 2) results in C, D, E, A, B.

Problem 3
Write the method removeBetween, member of the class DoubleLinkedList. The method
takes two elements e1 and e1 , and removes all the elements between the two elements
(e1 and e2 not included). If e1 or e2 or both doesn’t exist, no element will be re-
moved. You can assume the elements to be unique, and that e1 6= e2 . Do not call
any methods and do not use any auxiliary data structures. The method
signature is: public void removeBetween(T e1, T e2).

Example 3.1. Given the list: A ↔ B ↔ C ↔ D ↔ E ↔ F , removeBetween(’B’,


’E’) results in: A ↔ B ↔ E ↔ F .

1
Problem 4
Write the method reverseCopy, user of DoubleLinkedList, which copies the elements
of l1 to l2 in reverse order. The list l1 must not change. Assume that l2 is empty.
The method signature is public static <T> void reverseCopy(DoubleLinkedList<T> l1,
DoubleLinkedList<T> l2).

Example 4.1. If l1 : A ↔ B ↔ C ↔ D, then calling reverseCopy(l1, l2) results in


l2 : D ↔ C ↔ B ↔ A.

You might also like