SCHOOL OF ARTS AND SCIENCE
VINAYAKA MISSION'S CHENNAI CAMPUS
PAIYANOOR
DEPARTMENT OF COMPUTER SCIENCE
LAB MANNUAL FOR
CC-IV DATA STRUCTURES LAB
SECOND YEAR BCA, III SEMESTER
PREPARED BY
Dr. B. SRINIVASAN
ASSOCIATE PROFESSOR OF CS, SAS
Exercise No: 1
LIST OPERATIONS
Date: 17-06-2025
Aim :
To perform various list operations like creation, deletion, search, and display the list
elements in both forward and reverse order.
Steps:
1. Open the Jupyter Notebook and create a new Python 3 file
2. Do the following
a. Create: Create an empty dynamic list and fix a size
b. Insert: Get the given input, and insert it into the list
c. Delete: Get the position of the element to be deleted, and delete
d. Search: Get the element to be searched, find, if it exists, say found, else, say not
found.
e. Forward/ Reverse display: Display the list in both directions
3. Stop the process
Result :
The list operations are implemented as a Python program and tested on Jupyter
Notebook editor with sample data.
Exercise No: 2
QUEUE OPERATIONS
Date: 24-06-2025
Aim:
To implement the Enqueue, Dequeue, and print processing of the Queue data structure
with front and rear pointers to maintain First In First Out (FIFO) order.
Steps:
1. Open the Jupyter Notebook and create a new Python 3 file
2. Implement the following steps
Enqueue operation
1. Initialize or check Front and Rear pointers
2. Check for overflow error; if overflow, print “Queue Full”; else, go to step 3
3. Get a new element and insert it into the position pointed by Rear
4. Increment the Rear pointer for the next position
5. Stop
Dequeue operation
1. Check front and rear pointers
2. Check for underflow error; if overflow, print “Queue Empty”; else, go to step 3
3. Delete the element pointed by the Front pointer
4. Increment the Front pointer to point next element
5. Stop
Print Operation
1. Check front and rear pointers
2. Check for underflow error; if overflow, print “Queue Empty”; else, go to step 3
3. Print the element pointed by Front
4. Increment the Front pointer to point next element
5. Stop
Result :
The Enqueue, Dequeue and Printing operations on a queue are implemented as a
Python program, and tested with sample values
Exercise No: 3
INFIX TO POSTFIX CONVERSION
Date: 24-06-2025
Aim:
To convert the given infix arithmetic expression into its equivalent postfix notation by
using stack operations
Steps:
1. Open the Jupyter Notebook and create a new Python 3 file
2. Implement the following steps
3. Scan infix expression from left to right
4. If operand add to postfix
5. If operator
a. Pop from stack if top has same preference
b. Push current operator
5. If “(“, push to stack
6. If “)”, pop from stack till “(“
7. Pop remaining operators
8. Stop process
Result :
The given infix expression is converted into its equivalent postfix format by using
stack operations
Exercise No: 4
EVALUATION OF ARITHMETIC EXPRESSION
Date: 01-07-2025
Aim:
To evaluate the given arithmetic expression in infix notation by using stack operations
Steps:
1. Open the Jupyter Notebook and create a new Python 3 file
2. Implement the following steps
3. Scan the infix expression from left to right
4. If the character is an operand, push it into the stack
5. If the character is an operator, pop two operands from the stack and perform the
operation
6. Push the result into the stack
7. At the end, the final result is on the stack, display the result
8. Stop the process
Result :
The given arithmetic expression is evaluated by using the stack operations, and
the evaluated result is printed.
Exercise No: 5
SINGLE SOURCE SHORTEST PATH (DIJKSTRA ALGORITHM)
Date: 08-07-2025
Aim:
To find the shortest path in between nodes of a weighted graph by using Dijkstra
algorithm
Steps:
1. Open the Jupyter Notebook and create a new Python 3 file
2. Implement the following steps
3. Set start node distance as 0 and others to ∞
4. Select a node with smallest distance
5. Update neighbour’s distances, if shortest path found
6. Repeat steps 3-4 until all nodes processed
7. Get shortest distance
8. Stop process
Result :
The singe source of shortest path is found for the given weighted graph by using
Dijkstra’s Algorithm
Exercise No: 6
BINARY TREE TRAVERSAL
Date: 22-07-2025
Aim:
To do inorder, preorder and postorder traversal in the given binary tree by using a
Python program
Steps:
1. Open the Jupyter Notebook and create a new Python 3 file
2. Implement the following steps
In order Traversal
1. Start from root
2. Traverse
I. Left Subtree(Recursively)
II. Current node/ Root Node (Visit & Print)
III. Right Subtree(Recursively)
3. Repeat until all nodes are visited
Pre order Traversal
1. Start from root
2. Traverse
I. Current node/Root Node (Visit & Print)
II. Left Subtree(Recursively)
III. Right Subtree(Recursively)
3. Repeat until all nodes are visited
Post order Traversal
1. Start from root
2. Traverse
I. Left Subtree(Recursively)
II. Right Subtree(Recursively)
III. Current node/ Root Node(Visit & Print)
3. Repeat until all nodes are visited
Result :
The inorder, preorder and postorder traversals over the constructed tree are
carried out and verified.
Exercise No: 7
SORTING
Date: 29-07-2025
Aim:
To implement various Quicksort, Merge sort, Bubble sort, Selection sort and Insertion
sort algorithms.
Steps
Steps:
1. Open the Jupyter Notebook and create a new Python 3 file
2. Implement the following steps
Quicksort
1. Select Pivot element
2. Divide smaller elements <Pivot< greater elements
3. Recursively sort both groups
4. Combine the result to get sorted list & stop
Merge sort
1. Divide the given list into two halves
2. Recursively sort both halves
3. Merge both sorted halves to combine result & stop
Bubble sort
1. Compare the adjacent elements
2. Bubble up the largest towards right or bottom
3. Repeat till all elements are sorted & stop
Selection sort
1. Find smallest from the given list
2. Swap it with the first unsorted element
3. Repeat till all elements are sorted & stop
Insertion sort
1. Select an element & compare with others
2. Shift larger element & place insert the element into correct position
3. Repeat till all elements are sorted & stop
Result :
The various sorting methods are applied over the given unsorted lists and the
sorted output is verified
Exercise No: 8
GRAPH TRAVERSAL ( DFS & BFS)
Date: 05-08-2025
Aim:
To perform Graph Traversals by using Depth-First-Search and Breadth-First-Search
Algorithms
Steps:
1. Open the Jupyter Notebook and create a new Python 3 file
2. Implement the following steps
Depth-First-Search
1. Mark Current node as visited
2. Add the current into visited list
3. Explore its unvisited neighbours
4. Repeat 1-3 for all unvisited neighbours
5. Return traverse order & stop
Breadth-First-Search
1. Enqueue the starting nodes
2. While queue is not empty
i. Dequeue a node
ii. If not visited, mark it as visited
iii. Enqueue its unvisited neighbours
3. Return the visited nodes & Stop
Result :
The DFS and BFS traversals over the given graph are carried out and the result is
observed
Exercise No: 9
LINEAR SEARCH
Date: 19-08-2025
Aim:
To perform simple linear search for the given element over the given list.
Steps:
1. Check each element in the given list
2. If element matches the target, return its index
else, move to the next element
3. If no element found after checking all, return not found
4. Stop
Result :
The given element is searched against the list of n given array by using linear
search method, and the result is observed.
Exercise No: 10
BINARY SEARCH
Date: 02-09-2025
Aim:
To find the search element on the given list of sorted array by using binary search
method
Steps:
1. Find the middle element of the array
2. If middle element== search element, return its index
3. If search element < middle element, search left half
Else search the right half
4. Repeat 1-3, until target found, or search space is empty
5. stop
Result :
The given element is searched against the list of n given array by using binary
search method, and the result is observed.