Assignment No. 01
Data Structures (CLO-1)
Objective: Apply linear data structures (ArrayList, Singly Linked List, Doubly Linked List,
Circular Linked List) to solve real-world computing problems.
Question 01: ArrayList (Student Record Management System)
A university wants to maintain a dynamic list of student records where the number of students keeps changing every semester. Each student has the following attributes:
● Student ID
● Name
● GPA
You are required to use an ArrayList to perform the following operations:
Tasks:
1. Add at least 5 student records to the ArrayList.
2. Insert a new student at a specific index.
3. Remove a student record using Student ID.
4. Update the GPA of a specific student.
5. Display all student records.
6. Find and display the student with the highest GPA.
Requirement:
Implement the above operations using appropriate methods and explain the time complexity of insertion and deletion operations.
Question 02: Singly Linked List (Hospital Patient Queue System)
A hospital maintains a queue of patients waiting for consultation. Each patient has:
● Patient ID
● Name
● Disease
The hospital processes patients in the order they arrive, but sometimes emergency patients are inserted at the beginning.
Tasks:
1. Create a singly linked list to store patient records.
2. Insert a new patient at the beginning (emergency case).
3. Insert a patient at the end of the list.
4. Delete a patient record by Patient ID.
5. Search for a patient in the list.
6. Display all patients in the queue.
Requirement:
Explain why a singly linked list is more suitable than an array for this scenario.
Question 03: Doubly Linked List (Browser Navigation System)
A web browser allows users to navigate forward and backward between visited pages. Each page
contains:
● Page URL
● Page Title
You need to simulate this functionality using a doubly linked list.
Tasks:
1. Create a doubly linked list to store visited pages.
2. Insert new pages as the user visits them.
3. Implement “Back” functionality.
4. Implement “Forward” functionality.
5. Delete a specific page from history.
6. Display browsing history in forward and reverse order.
Requirement:
Explain how a doubly linked list helps in efficient forward and backward traversal compared to a singly linked list.
Question 04: Circular Linked List (Music Playlist System)
A music player plays songs in a continuous loop. Once the last song is played, it returns to the first song automatically. Each song contains:
● Song ID
● Song Name
● Artist
You are required to implement this system using a circular linked list.
Tasks:
1. Create a circular linked list to store songs.
2. Insert songs into the playlist.
3. Display all songs in a circular manner.
4. Simulate playing the next song.
5. Delete a song from the playlist.
6. Search for a song by name.
Requirement:
Explain how circular linked lists are useful in real-time systems like music players.
LAB Assignment # 01
Merging Two Linked Lists (CLO-1)
Scenario:
A logistics company maintains two separate delivery routes, each represented as a singly linked list. Each node in the list stores a package ID in sorted order (ascending).
Due to operational efficiency, the company wants to merge both delivery routes into a single sorted route so that all packages can be delivered in order without duplication of effort.
You are required to design a system that takes two linked lists as input and creates a third linked list that contains all elements of both lists in sorted order.
Tasks:
1. Create a singly linked list structure for storing package IDs.
2. Insert nodes in sorted order into both lists.
3. Implement a function:
mergeLists(List1, List2)
which merges both lists into a third new linked list.
4. Display all three linked lists (List1, List2, and Merged List).
5. Ensure that the original lists remain unchanged.
Submission Guidelines:
● Implement all questions in C++.
● Include proper comments in your code.
● Provide sample input/output.
● Write a brief explanation of each data structure used.
● Submit your assignment in soft as well as hard format.