Professional Documents
Culture Documents
Assinent DSA
Assinent DSA
Subject:
DATA STRUCTURE AND ALGORITHM
Year : 2023-24
Submitted by-
Name : Birdao Swargiary
Roll No : UG108P220002
Class : BCA 2nd Semester
Experiment no : 1
Aim : To write a program to create a singly linked list and insert an
element at the beginning, end, and at a given position of the linked list.
Program code :
2|Page
Program code :
3|Page
Program code :
4|Page
Output :
5|Page
Explanation :
In above program, we are going to perform some operation like
insert an element at the beginning, end, and at a given position of the
linked list. So first I create a singly linked list and after that I used
switch statement to user can select their choice which they want to
perform. After selecting the choice, perform the user selected
operation.
6|Page
Experiment no : 2
Aim : To write a program to create a singly linked list and delete an
element from any position of the linked list.
Program code :
7|Page
Program code :
8|Page
Program code :
9|Page
Program code :
10 | P a g e
Output :
11 | P a g e
Explanation : In above program, we are going to perform element
deleting operation , where element is delete from the user entered
position of the linked list. So first I create a linked list and after that
perform the element deleting operation.
12 | P a g e
Experiment no : 3
Aim : To write a program to create a singly linked list and perform some
operation like counting the number of elements in a list, search for the
given element in a list etc.
Program code :
13 | P a g e
Program code :
14 | P a g e
Program code :
Output :
15 | P a g e
Output :
16 | P a g e
Explanation : In this program we are going to perform some
operation like counting the number of elements in a list, search for the
given element in a list etc. So first I create a singly linked list and after
that I used switch statement to user can select their choice which they
want to perform. After selecting the choice, performed the user
selected operation.
17 | P a g e
Experiment no : 4
Aim : To write a program to create a doubly linked list and insert an
element at any position.
Program code :
18 | P a g e
Program code :
19 | P a g e
Program code :
20 | P a g e
Output :
21 | P a g e
Explanation : In this program we are going to perform element
Inserting operation, where element is insert at user entered position.
So first I create a double doubly linked list and after that performed the
element inserting operation.
22 | P a g e
Experiment no : 5
Aim : To write a program to create a doubly linked list and delete an
element from a given position.
Program code :
23 | P a g e
Program code :
24 | P a g e
Program code :
25 | P a g e
Program code :
Output :
26 | P a g e
Explanation : In above program, we are going to perform element
deleting operation , where element is delete from the user entered
position of the doubly linked list. So first I create a doubly linked list
and after that performed the element deleting operation.
27 | P a g e
Experiment no : 6
Aim : To write a program to implement a stack using linked list
Structure.
Program code :
28 | P a g e
Program code :
29 | P a g e
Output :
30 | P a g e
Explanation : In this program we are going to implement a stack using
linked list Structure. So, I used push() function to insert an element in
a stack and used pop() function to delete an element from the stack. I
used switch statement to user can select their choice which they want
to perform. After selecting the choice, performed the user selected
operation.
31 | P a g e
Experiment no : 7
Aim : To write a program to implement a queue using linked list.
Program code :
32 | P a g e
Program code :
33 | P a g e
Program code :
Output :
34 | P a g e
Output :
35 | P a g e
Explanation : In this program we are going to implement a queue using
linked list Structure. So, I used enqueue() function to insert an element
in a queue and used dequeue() function to delete an element from the
queue. I used switch statement to user can select their choice which
they want to perform. After selecting the choice, performed the user
selected operation.
36 | P a g e
Experiment no : 8
Aim : To write a program to implement a queue using doubly
linked list.
Program code :
37 | P a g e
Program code :
38 | P a g e
Output :
39 | P a g e
Explanation : In this program we are going to implement a queue using
doubly linked list Structure. So, I used enqueue() function to insert an
element in a queue and used dequeue() function to delete an element
from the queue. I used switch statement to user can select their choice
which they want to perform. After selecting the choice, performed the
user selected operation.
40 | P a g e