0% found this document useful (0 votes)
15 views4 pages

Exp4 RAI DSA SLL 24-25

Uploaded by

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

Exp4 RAI DSA SLL 24-25

Uploaded by

sujay.kamuni
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 4

KJSCE/RAI/SY BTech/SEM III/DSA/2024-25

Experiment No. : 4

Title: Demonstrate the use of structures and pointer to


implement Singly Linked List (SLL).

A Constituent College of Somaiya Vidyavihar University


KJSCE/RAI/SY BTech/SEM III/DSA/2024-25

Batch: Roll No.: Experiment No.:4

Aim: Implementing Singly Linked List (SLL) supporting following operations using
menu driven program.
1. Insert at the Begin
2. Insert after the specified existing node
3. Delete before the specified existing node
4. Display all elements in tabular form.
__________________________________________________________________________________

Resources Used: Turbo C/ C++ editor and compiler (online or offline).

__________________________________________________________________________________

Theory:

Singly Linked List:-


Singly Linked Lists are a type of Linear data structure. It is a type of list. In a singly
linked list each node in the list stores the contents of the node and a pointer or
reference to the next node in the list. It does not store any pointer or reference to the
previous node. It is called a singly linked list because each node only has a single
link to another node. To create a single linked list, you only need to store a
reference or pointer to the first node in that list. The last node has a null pointer to
indicate that it is the last node.

A linked list is a linear data structure where each element is a separate object.

Fig 1.1 : Example of Singly Linked List


Each element (we will call it a node) of a list is comprising of two items - the data
and a reference to the next node. The last node has a reference to null. The entry point
into a linked list is called the head of the list. It should be noted that head is not a
separate node, but the reference to the first node. If the list is empty then the head is a
null reference.

A linked list is a dynamic data structure. The number of nodes in a list is not fixed
and can grow and shrink on demand. Any application which has to deal with an
unknown number of objects will need to use a linked list.

One disadvantage of a linked list against an array is that it does not allow direct
access to the individual elements. If you want to access a particular item then you
have to start at the head and follow the references until you get to that item.

Another disadvantage is that a linked list uses more memory compare with an array -
we need extra 4 bytes (on 32-bit CPU) to store a reference to the next node.

A Constituent College of Somaiya Vidyavihar University


KJSCE/RAI/SY BTech/SEM III/DSA/2024-25

Algorithm:

Program should implement the specified operations in the following manner. Also
implement a support method isempty() and make use of it at appropriate places.

1. typdef createSLL() – This function should create a START/HEAD pointer with NULL
value as empty SLL and return the pointer.
2. insertBegin( typedef HEAD, typedef newelement ) – This void function should take a
newelement as an argument to be inserted on an existing SLL and insert it before the element
pointed by the START/HEAD pointer.
3. insertAfter( Typedef HEAD, typedef newelement, typedef existingelement) – This void
function should take newelement and existingelement (after which new has to be inserted) as
arguments. The function should search for an existingelement on non-empty SLL and insert
newelement after this element.
4. typedef deleteBefore(Typedef HEAD, typedef existingelement ) – This function should
search for the existing element passed to the function in the non-empty SLL, delete the node
siting before it and return the deleted element.
5. display(Typedef HEAD ) – This is a void function which should go through non- empty
SLL starting from START/HEAD pointer and display each element of the SLL till the end.

NOTE : All functions should be able to handle boundary(exceptional) conditions.


___________________________________________________________________________

Program : (copy-paste code here)

___________________________________________________________________________

Output :

___________________________________________________________________________

Conclusion :

__________________________________________________________________________

Outcomes achieved: (refer Experiment list)

__________________________________________________________________________

Grade: AA / AB / BB / BC / CC / CD /DD

Signature of faculty in-charge with date


_______________________________________________________________________
A Constituent College of Somaiya Vidyavihar University
KJSCE/RAI/SY BTech/SEM III/DSA/2024-25

References:

Books/ Journals/ Websites:

● Y. Langsam, M. Augenstin and A. Tannenbaum, “Data Structures using C”, Pearson


Education Asia, 1st Edition, 2002.
● E. Horowitz, S. Sahni, S.Anderson-freed, “Fundamentals of Data Structures in C”, 2nd Edition,
University Press

A Constituent College of Somaiya Vidyavihar University

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy