0% found this document useful (0 votes)
4 views

Data Structure & Algorithm Lab syllabus

Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
4 views

Data Structure & Algorithm Lab syllabus

Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 6

CSE 218 DATA STRUCTURES Credits: 1.

5
Instruction: 3 Periods/week LAB USING C Sessional Marks: 50
End. Exam: 3 Hours End-Exam-Marks: 50

--------------------------------------------------------------------------------------------------------------

Outcomes of the Lab:

1. Implement the techniques for searching and sorting (quick and merge).
2. Implement of stack and queue and Linked list data structures and their applications.
3. Implement operations like insertion, deletion, search and traversing mechanism on
binary search tree
4. Apply BFS and DFS algorithms to implement graph traversal.

CO-POMapping:

PO PSO
Mapping
1 2 3 4 5 6 7 8 9 10 11 12 1 2

1 2 2 2 1 1 1 1 1 1 1

2 1 2 2 1 1 1 1 1 1 1
CO
3 2 2 2 1 1 1 1 1 1 2 1

4 2 2 2 1 1 1 1 1 1 2

Experiments:
1. Write a program to sort the given array of N elements using divide and conquer method
(merge sort and quick sort algorithms) CO1
Constraints: 1<N<1000
Sample Input array: 87, 36,9, 12,24, 5, 78, 567, 456, 34, 96, 45, 39, and 89,123
Sample Output array:5,9, 12, 24, 34, 36, 39, 45, 78, 87, 89, 96, 123, 456, and 567
2. Write a C Program to search whether an item K present in an array of N elements (Using
Linear and binary Search algorithms) CO1
Constraints: 1<K<1000
1<N<1000
Sample Input array: 45, 78,123, 48, 34, 89,67,54, and 74,543
Search Item: 34 Search Item: 343
Output: Key Found Output: Key Not Found
3. Write a C program to store k keys into an array of size n at the location computed using a
hash function, loc = key % n, where k<=n and k takes values from [1 to m], m>n. CO1
4. Design, Develop and Implement a C program to handle the collisions using the following
collision resolution Technique CO1
a) Linear probing: In linear probing, we linearly probe for next slot, let store k keys into an
array of size S at the location computed using a hash function, hash(x) where k<=n and k
takes values from [1 to m], m>n.
Constraints:If slot hash(x) % S is full, then we try (hash(x) + 1) % S
If (hash(x) + 1) % S is also full, then we try (hash(x) + 2) % S
If (hash(x) + 2) % S is also full, then we try (hash(x) + 3) % S
..................................................
..................................................
Sample Test Case:
Let us consider a simple hash function as “key mod 7” and sequence of keys as 50, 700, 76,
85, 92, 73, 101.

b) Quadratic probing: Quadratic Probing we look for i2‘th slot in i’th iteration, let store k
keys into an array of size S at the location computed using a hash function, hash(x) where
k<=n and k takes values from [1 to m], m>n.
Constraints: let hash(x) be the slot index computed using hash function.
If slot hash(x) % S is full, then we try (hash(x) + 1*1) % S
If (hash(x) + 1*1) % S is also full, then we try (hash(x) + 2*2) % S
If (hash(x) + 2*2) % S is also full, then we try (hash(x) + 3*3) % S
.................................................
Sample Test Case:

c) Separate Chaining: The idea is to make each cell of hash table points to a linked list of
records that have same hash function value.
Let us store K keys into hash table of size S, where k<=n and k takes values from [1 to m],
m>n.
Sample Test Case:
Let us consider a simple hash function as “key mod 7” and sequence of keys as 50, 700, 76,
85, 92, 73, 101.
5. Design, Develop and Implement a menu driven Program in C for the following. CO2
a) Operations on STACK of Integers (Array Implementation of Stack with maximum size
MAX)

1. Push an Element on to Stack


2. Pop an Element from Stack
3. Demonstrate Overflow and Underflow situations on Stack
4. Display the status of Stack
5. Exit
b) Operations on QUEUEof Characters (Array Implementation of Queue with maximum size
MAX)

1. Insert an Element on to QUEUE


2. Delete an Element from QUEUE
3. Demonstrate Overflow and Underflow situations on QUEUE
4. Display the status of QUEUE
5. Exit
Note: Support the program with appropriate functions for each of the above operations

6. Design, Develop and Implement aC program to do the following using a singly linked
list.CO2

a) Stack- In single linked list store the information in the form of nodes .Create nodes using
dynamic memory allocation method. All the single linked list operations perform based on
Stack operations LIFO(last in first out).
A stack contains a top pointer. Which is “head” of the stack where pushing and popping
items happens at the head of the list. first node have null in link field and second node link
have first node address in link field and so on and last node address in “top” pointer.
Stack Operations:
1. push() : Insert the element into linked list nothing but which is the top node of Stack.
2. pop() : Return top element from the Stack and move the top pointer to the second node
of linked list or Stack.
3. peek(): Return the top element.
4. display(): Print all element of Stack.

b) Queue- All the single linked list operations perform based on queue operations FIFO(First
in first out).
In a Queue data structure, we maintain two pointers, front and rear. The front points the first
item of queue and rear points to last item.
1. enQueue() This operation adds a new node after rear and moves rear to the next
node.
2. deQueue() This operation removes the front node and moves front to the next node.
3. Display() Display all elements of the queue.

Note: Sample node information: Student Data with the fields: USN, Name, Branch, Sem,
PhNo.

7. Design, Develop and Implement a Program in C for the following CO2


a) Converting an Infix Expression to Postfix Expression. Program should support for
both parenthesized and free parenthesized expressions with the operators: +, -, *, /,
%(Remainder), ^(Power) and alphanumeric operands.

b) Evaluation of postfix expression with single digit operands and operators: +,-, *, /, %,
^
8) Design, Develop and Implement a menu driven Program in C for the following : CO2
a) Circular Queue
1. Insert an Element on to Circular QUEUE
2. Delete an Element from Circular QUEUE
3. Demonstrate Overflow and Underflow situations on Circular QUEUE
4. Display the status of Circular QUEUE
5. Exit
b) Priority Queue
1. Insert an Element on to Priority QUEUE
2. Delete an Element with highest priority from Priority QUEUE
3. Demonstrate Overflow and Underflow situations on Priority QUEUE
4. Display the status of Priority QUEUE
5. Exit

Support the program with appropriate functions for each of the above operations

9. Design, Develop and Implement a menu driven C program to Perform Operations on


dequeue (double ended queue) using circular array. CO2
a) insertFront(): Adds an item at the front of Deque.
b) insertRear(): Adds an item at the rear of Deque.
c) deleteFront(): Deletes an item from front of Deque
d) deleteRear(): Deletes an item from rear of Deque
e) getFront(): Gets the front item from queue
f) getRear(): Gets the last item from queue
g) isEmpty(): Checks whether Deque is empty or not
h) isFull(): Checks whether Deque is full or not

Support the program with appropriate functions for each of the above operations

10. Design, Develop and Implement a menu driven Program in C for the following operations
on Binary Search Tree (BST) of Integers CO3
a. Create a BST of N Integers: 13, 3, 4, 12, 14, 10, 5, 1, 8, 2, 7, 9, 11, 6, 18
b. Traverse the BST(either inorder, predorder or postorder)
c. Search the BST for a given element (KEY) and report the appropriate message
d. Delete
e. Exit

11. Design, Develop and Implement a menu driven Program in C for the following operations
on Binary Search Tree (BST) of Integers CO3
a. Create a BST of N Integers: 6, 9, 5, 2, 8, 15, 24, 14, 7, 8, 5, 2
b. Traverse the BST in Inorder, Preorder and Post Order using non-recursive functions
c. exit
12. Design, Develop and Implement a Program in C for the following operations on
Graph(G) of Cities CO4
a. Create a Graph of N cities using Adjacency Matrix.
b. Print all the nodes reachable from a given starting node in a digraphusing
DFS/BFS method

13. Design, Develop and Implement a C Program to the problem is to find shortest distances
between every pair of vertices in a given edge weighted directed Graph using Warshall’s
Algorithm. The Graph is represented as Adjacency Matrix, and the Matrix denotes the weight
of the edges (if it exists) else INF (1e7).CO4

Input:
The first line of input contains an integer T denoting the no of test cases. Then T test cases
follow. The first line of each test case contains an integer V denoting the size of the
adjacency matrix. The next V lines contain V space separated values of the matrix (graph).
All input will be integer type.
Output:
For each test case output will be V*V space separated integers where the i-jth integer denote
the shortest distance of ith vertex from jth vertex. For INT_MAX integers output INF.

Constraints:
1 <= T <= 20
1 <= V <= 100
1 <= graph[][] <= 500

14. Design, Develop and Implement a C Program to Find the shortest distance from A to J on
the network below using Dijkstra’sAlgorithm CO4

You might also like