Labsheet 7

You might also like

Download as pdf or txt
Download as pdf or txt
You are on page 1of 1

CSE 2032Y – Data Structures and Algorithms

Labsheet7 (Week 9 and Week 10) on Linked Lists


Objectives: The objective of this labsheet is to work with Linked Lists in Java
Question 1
For the example discussed during lecture, implement the classes Node and LinkedList to
model a singly-linked list (SLL). Develop a class LinkedListApp to manipulate objects of type
LinkedLists e.g. creation of a list, insertion of nodes in the linked list (at the beginning, at the
end and in an ordered manner), deletion from the list (beginning and specific nodes),
modification of nodes data, finding of nodes, display of the linked list, counting the number
of nodes and merging of two linked lists.

Question 2
For the above example, now implement a double-ended SLL which will keep track of both
head and tail in the list and modify the methods which need to be modified, accordingly.

Question 3
Write program that creates a linked list to represent details of students at UoM. The
following details must be kept for each student:
• SID
• First name
• Last name
• Address
• Age
• Gender
• Course enrolled for

Your program must also display a menu to perform the following tasks:
• Create a linked list.
Note: The method to create a linked list makes use of the method insertFirst() or insertLast()
or insertOrdered()
• Insert new nodes to the linked list.
• Search for details pertaining to a particular student.
• Delete details of a particular student.
• Find number of nodes in the linked list.
• Display information pertaining to all students.

The menu options should be as follows:


1. Create linked list
2. Add new student
3. Search for a student
4. Delete a student
5. Find number of students
6. Print student details
7. Exit

You might also like