Thanks to visit codestin.com
Credit goes to www.scribd.com

0% found this document useful (0 votes)
6 views6 pages

Lab 6 Manual

Uploaded by

alayak1122
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)
6 views6 pages

Lab 6 Manual

Uploaded by

alayak1122
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
You are on page 1/ 6

LAB 06

INTRODUCTION TO LINKED LISTS


Objective:

• To learn how to implement a singly linked list, doubly and circular


Equipment:

Personal Computer with Dev C++/Microsoft Visual Studio


Introduction:

This lab session introduces an initial idea of dynamic data structure — linked lists. Students are
required to complete the programming during the lab and get it checked by the instructor.
Besides, the students should also complete lab assignments, given end of this manual, during
the lab.
LINKED LISTS

Linked list is one of the fundamental data structures and can be used to implement other data
structures. It consists of s sequence of nodes, each containing arbitrary data fields and one or
two links to the next and/or previous nodes. The principal benefit of a linked list over
conventional array is that the order of linked list items may different from the order that the data
items are stored in or on disk, allowing the linked list of items to be traversed in a different
order. Besides a single node of linked list can have data of multiple data types. unlike arrays
where whole Array is defined for one data type only
Consider the following diagrammatic representation for a linked list

Data Next
i•st

myl.ist..
Lab Task:

After going through Lab tasks, submit a separate Word document which should include all the
results of the tasks Code should be in word and output should be screenshot.

First page should contain your Full name, Registration #, Course name and Date

The File Should be saved with your name only.


No copied or AI Should be in Code or Explanation.
Submit on Time Marks will be deducted on late submission.

1. Create a linked list with two data values, student registration number and student name
for a typical class data below.

B22F00CS135 Liam Johnson


B22F06CS082 Olivia Smith
B22F06CS032 Noah Williams
B22F05CS013 Emma Brown
B22F09CS086 Ava Jones
B22F07CS047 Oliver Patel
B22F01CS067 Sophia Nguyen
B22F05CS023 Jackson Kim
B22F02CS094 Amelia Lee
B22F01CS038 Aiden Garcia
B22F05CS114 Lucas Davis
B22F04CS089 Mia Rodriguez
B22F00CS084 Harper Martinez
B22F04CS124 Ethan Jackson
B22F06CS092 Alexander Hernandez
B22F09CS052 Sebastian Lopez
B22F06CS088 James Adams
B22F01CS009 Elijah Gonzalez
B22F04CS075 Grace Perez
B22F00CS010 Daniel Turner
B22F06CS115 Lily Taylor
B22F03CS123 Benjamin White
B21F09CS019 Mia Harris
B22F05CS035 Lucas Moore
B22F07CS039 Samuel Thomas
B22F09CS024 Henry Baker
B21F02AI021 Abigail Hall
• Write function for inserting the data in the linked list by inserting at random locations in the
linked list. The function should take care of the appropriate handling of the pointers.
• Write the function for searching the linked list using binary search technique
• Write function for displaying the whole list and a function for deallocation of memory.

2. Create a class with the name ‘car’ that contains the number plate of the car and a pointer
to point to the next car in the parking area. The number plate data would contain both
letters and numerals. For this you will have to declare a character array.

a. A method to insert a new car in the parking lot and to note down its number plate data. (modify
the function insert_node())
b. A method to delete data of a specific car when it leaves the parking lot. You have to search for
the car parked before the one that just left. Or you can simply delete the car by finding out its
position in the parking lot. (Modify remove_node_between(int data) method for linked lists.)
c. Say if a new car is parked in the place emptied by the car that just left. Implement a method to
insert this new car in the list in the place of the one that just left. Also note down the number
plate data of the new car. You can also insert the new car at a specific unoccupied position by
asking pos from the user. (modify the function insert_node_inbetween(int data))
d. At any time you may need to check if the parking lot is empty. (Implement function bool
isEmpty()which returns 0 if the lot is empty and 1 otherwise) e) Say the authorities ask you to
search in the parking lot if a car with a specific number plate data is still parked there. Implement
a method to fulfill their request (modify the function void search (int data)).

You need to keep a count of the number of cars parked in the parking lot at any time. You may do
this by assigning a variable to keep the count and displaying it whenever required.

You might also like