DS Lab (CS29001) Lesson Plan - CRP
DS Lab (CS29001) Lesson Plan - CRP
L-T-P-Cr : 0-0-2-1
Course Contents:
The course focuses on basic and essential topics in data structures and algorithms, including:
1
List of Experiments (Day wise):
Lab 1 (Introduction)
1.1. WAP to store one student’s information (i.e. student’s roll no, name, gender, marks etc) of an
educational institute and display all the data, using structure (Access the structure members using
pointer).
1.2. WAP to store n book’s data (title, author, publication, price etc.) using structures with dynamic
memory allocation. Display all the books information of a particular author.
Input: Orange
Output: The length of String: 6
1.4. WAP using dynamic memory allocation to find out the smallest and largest element stored in an array
of n integers.
1.5. WAP using pointer, dynamic memory allocation to search an element in an array of n numbers.
2
Lab 2 (Array)
2.2. WAP that takes an array as input and removes any duplicate elements, keeping only the first
occurrence of each element.
2.3. WAP a menu driven program to create an array and perform the following operations:
a. Traverse elements
b. Insert an element
c. Delete an element
d. Merging elements of two arrays
420
654
Output:
3
Row1, Sum=6, average=2
Lab 3 (Array)
4
3 3 71
3 4 21
3.3. WAP to represent the polynomial of single variable using 1-D array and perform the addition of two
polynomial equations.
Input: Enter maximum degree of x: 2
Enter Polynomial-1 from lowest degree to highest degree : 4 2 3 (Hint: 4+2x+3x^2)
Enter Polynomial-2: 6 5 2
4.1. Write a menu driven program to perform the following operations in a single linked list (using self-
referencing structure) by using suitable user defined functions for each case.
Output:
1.Create a Node
2.Display the list
3.Insert the element at beginning
4.Insert the element at the end
5.Insert the element at specific position
6.Delete the element from the beginning
7.Delete the element from the end
8.Delete the element from specific position
9.Count the total number of nodes
10.Search an element in the linked list
11.Exit
5
6.Delete the element from the beginning
7.Delete the element from the end
8.Delete the element from specific position
9.Count the total number of nodes
10.Search an element in the linked list
11.Exit
4.2. Write a menu driven program to perform the following operations in a double linked list (using self-
referencing structure) by using suitable user defined functions for each case.
6
b. Display the list
c. Insert a node (at beginning/ at end / at any position)
d. Delete a node (at beginning/ at end / at any position)
e. Count the total number of nodes
f. Search for an element in the linked list
Output:
1.Create a Node
2.Display the list
3.Insert the element at beginning
4.Insert the element at the end
5.Insert the element at specific position
6.Delete the element from the beginning
7.Delete the element from the end
8.Delete the element from specific position
9.Count the total number of nodes
10.Search an element in the linked list
11.Exit
7
6.Delete the element from the beginning
7.Delete the element from the end
8.Delete the element from specific position
9.Count the total number of nodes
10.Search an element in the linked list
11.Exit
Enter your choice: 1
Enter the data item: 30
Do you want to Continue (Y/N): Y
1.Create a Node
2.Display the list
3.Insert the element at beginning
4.Insert the element at the end
5.Insert the element at specific position
6.Delete the element from the beginning
7.Delete the element from the end
8.Delete the element from specific position
9.Count the total number of nodes
10.Search an element in the linked list
11.Exit
Enter your choice: 2
The Elements of the list are: 10 20 30
Do you want to Continue (Y/N): N
5.1. Write a program to represent the polynomial equation of single variable using single linked list and
perform the addition of two polynomial equations.
Input:
Polynomial-1:
Enter the Maximum power of x: 2
Enter the coefficient of degree 2: 4
Enter the coefficient of degree 1: 3
8
5.2. Write a program to represent the given sparse matrix using header single linked list and display it.
6.1. Write a menu driven program to demonstrate the operations performed on stack using array and
suitable user defined functions for each case.
9
Enter Your Choice: 2
The deleted element is: 7
Do you want to continue (Y/N): Y
1.PUSH
2.POP
3.DISPLAY
4.EXIT
Enter Your Choice: 3
The Elements of the stack are: 5 3
Do you want to continue (Y/N): N
NB: Like wise other options can test
6.2. Write a menu driven program to demonstrate the operations performed on stack using linked list and
suitable user defined functions for each case.
10
The deleted element is: 7
Do you want to continue (Y/N): Y
1.PUSH
2.POP
3.DISPLAY
4.EXIT
Enter Your Choice: 3
The Elements of the stack are: 5 3
Do you want to continue (Y/N): N
6.3. Write a Program to convert an infix expression into its equivalent postfix expression using suitable
user defined function.
Input : a+b
Output:
Enter the infix expression
a+b
Equivalent Postfix Expression is:
ab+
6.4. Write a Program to convert an infix expression into its equivalent prefix expression using suitable
user defined function.
Input : a+b
Output:
Enter the infix expression
a+b
Equivalent Postfix Expression is:
+ab
Lab 7 (Queue)
7.1. Write a menu driven program to implement the following queue operations :
Output:
a. Add
b. Delete
11
c. Traverse
d. Exit
Enter your Choice: 1
Enter the Data 4
a. Add
b. Delete
c. Traverse
d. Exit
a. Add
b. Delete
c. Traverse
d. Exit
No=5 no=6
a. Add
b. Delete
c. Traverse
d. Exit
7.2. Write a menu driven program to implementation of dequeue operations using linked list. The
operation are such as :-
12
1. Insert at rear end
2. Insert at front end
3. Delete at front end
4. Delete at rear end
5. Display
6. Quit
Output:
5.Display
6. Quit
5.Display
6. Quit
13
Enter your Choice: 2
5.Display
6. Quit
5.Display
6. Quit
7.3. Write a menu driven program to implement of Circular queue operations using array. The operation
are such as :-
1. Insert
2. Delete
3. Display
4. Exit
Output:
1.Insert
2.Delete
14
3.Display
4.Exit
1.Insert
2.Delete
3.Display
4.Exit
1.Insert
2.Delete
3.Display
4.Exit
1.Insert
2.Delete
3.Display
4.Exit
Deleted Element is = 5
15
1.Insert
2.Delete
3.Display
4.Exit
Deleted Element is = 6
7.4. Write a menu driven program to implement of Circular queue operations using linked list. The
operation are such as :-
1. Insert
2. Delete
3. Display
4. Exit
Output:
1.Insert
2.Delete
3.Display
4.Exit
1.Insert
2.Delete
3.Display
4.Exit
16
Enter the Element to be inserted: 6
1.Insert
2.Delete
3.Display
4.Exit
1.Insert
2.Delete
3.Display
4.Exit
Deleted Element is = 5
Lab 8 (Tree)
8.1. Write a menu driven program to perform the following operations in a binary search tree:
17
82 77 90 346 35 0
Output: Number=: 35
Lab 9 (Graph)
9.1. WAP to create an un-directed graph using Adjacency Matrix Method and display the degree of each
vertex.
Input:
Output:
Vertex Degree
1 1
2 2
3 1
9.2. In addition to Q1, display DFS traversal sequence of the undirected graph.
Input:
Adjacency Matrix:
0 1 1 1 0
1 0 0 0 1
1 0 0 0 1
1 0 0 0 1
0 1 1 1 0
Enter start vertex: 0
18
9.1. In addition to Q1, display BFS traversal sequence of the undirected graph.
Input:
Lab 10 (Sorting)
10.1. Write a program to sort array of n elements in ascending and descending order by bubble sort using
function.
10.2. Write a program to sort array of elements in ascending and descending order by insertion sort using
function.
Descending order: 88 55 44 33 22
10.3. Write a program to sort array of elements in ascending and descending order by selection sort using
function.
Descending order: 66 55 33 22 11
19
10.4. Write a program to perform quick sort on array of elements to arrange it in ascending order using
function.
Enter elements: 70 50 40 20 10
10.5. Write a program to perform merge sort on array of elements to arrange it in ascending order using
function.
Enter elements: 10 30 40 60 20 80
11.1. Write a program to perform heap sort on array of elements to arrange it in ascending order using
function.
Enter elements: 52 31 25 14 27 38 46 50
Output: 14 25 27 31 38 46 50 52
11.2. WAP to sort all even numbers in ascending order and all odd numbers in descending order.
11.4. WAP to search an element from list of elements using binary search technique
20
Output:44 is found at position 4
Grading Policies:
Reference Materials:-
Reference Book:
Data Structures and Algorithm Analysis in C, Mark Allen Weiss, Pearson Education, 2nd Edition.
Reference Site:
NPTEL - https://onlinecourses.nptel.ac.in/explorer
Tutorials Point - https://www.tutorialspoint.com/data_structures_algorithms/
Geeks for geeks - http://www.geeksforgeeks.org/
21