0% found this document useful (0 votes)
4 views131 pages

ds

The document outlines the Data Structures Laboratory course for B.Tech in Artificial Intelligence and Machine Learning at VR Siddhartha Engineering College. It includes a detailed record of experiments, evaluation criteria, and various programming tasks related to searching, sorting, and data structure operations such as stacks and queues. The document serves as a laboratory record for students to document their experiments and evaluations throughout the academic year 2023-2024.

Uploaded by

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

ds

The document outlines the Data Structures Laboratory course for B.Tech in Artificial Intelligence and Machine Learning at VR Siddhartha Engineering College. It includes a detailed record of experiments, evaluation criteria, and various programming tasks related to searching, sorting, and data structure operations such as stacks and queues. The document serves as a laboratory record for students to document their experiments and evaluations throughout the academic year 2023-2024.

Uploaded by

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

VR SIDDHARTHA ENGINEERING COLLEGE

DEPARTMENT OF COMPUTER SCIENCE AND ENGINEERING

B.Tech in Artificial Intelligence and Machine Learning


II/IV B.Tech. 3rd Semester

DATA STRUCTURES LABORATORY


(20AI&ML3353)

Laboratory Record

VR20 A.Y. 2023-2024 AI&ML II/IV B.Tech III SEMESTER


V R SIDDHARTHA ENGINEERING COLLEGE
DATA STRUCTURES LABORATORY
(20AI&DS3353)

STUDENT NAME:

REGISTERED
NUMBER:

ACADEMIC YEAR:

BRANCH& YEAR:

SEMESTER:

SECTION:

COURSE
INSTRUCTOR:

No. of Experiments Recorded: …………………….

Marks Awarded : …………………….

VR20 A.Y. 2023-2024 AI&ML II/IV B.Tech III SEMESTER


V R SIDDHARTHA ENGINEERING COLLEGE
List of Experiments

S No. Experiment Name Page No.

VR20 A.Y. 2023-2024 AI&ML II/IV B.Tech III SEMESTER


V R SIDDHARTHA ENGINEERING COLLEGE
ACADEMIC YEAR 2023-2024 Data Structures Lab 20AI&ML3353
CONTINUOUS EVALUATION REPORT

S.No. Date Experiment Name Pre- In-Lab Post- Viva Total Faculty
Lab Lab Voce (10M) Signature
(1M) (1M) (1M)
Logic Exec Result Analysis
(2M) (2M) (2M) (1M)
For Evaluator’s use only

Comments of the Evaluator (if Any) Evaluator’s Observation


Full Name of the Evaluator:

Total Experiments recorded: ___________

Marks Secured: _______ out of ________ Signature of the Evaluator Date of Evaluation Signature of the Head of the Department
2023-2024
VR20 Registration No.

Lab Session-1
Date Time of the Session: to

CO-1 Implement different searching and sorting algorithms.

Program Title: Implement Linear and Binary Search.

Pre Lab:

1. Write an algorithm for reading a string from the keyboard and count number of vowels in
the given string.

20AI&ML3353: Data Structures Laboratory


Page No-
2023-2024
VR20 Registration No.

2. Write an algorithm to read n integer values through keyboard, find the middle element in
the given list. Also find the smallest element in the list from the starting to middle
position and find the big element from the mid+1 location to ending of the list.

20AI&ML3353: Data Structures Laboratory


Page No-
2023-2024
VR20 Registration No.

In Lab:

1. If you have the attendance statement of an examination in an array, read student roll
number from the keyboard as an integer, find the student attended for the exam or not
using linear search.(assume the statement contains roll numbers in random)

Test Case:

Input: No of students attended: 10


15, 33, 45, 6, 79, 2, 32, 53, 99, 48

Case 1: Student roll number: 79


Output: Attended for the Exam

Case 2: Student roll number: 13


Output: Absent for the Exam

20AI&ML3353: Data Structures Laboratory


Page No-
2023-2024
VR20 Registration No.

20AI&ML3353: Data Structures Laboratory


Page No-
2023-2024
VR20 Registration No.

2. Assume result is an array contains list of student roll numbers those who clear or pass the
Data structures course in the ascending order. Read the student roll number as an integer
and check the result of the student whether he/she pass or fail using binary search
technique.

Test Case:

Input: No of students attended: 10


2, 6, 15, 32, 33, 45, 48, 53, 79, 99

Case 1: Student roll number: 79


Output: Data Structures Course Completed

Case 2: Student roll number: 13


Output: Data Structures Course Not Completed

20AI&ML3353: Data Structures Laboratory


Page No-
2023-2024
VR20 Registration No.

20AI&ML3353: Data Structures Laboratory


Page No-
2023-2024
VR20 Registration No.

Post Lab:

a. Compare Linear Search and Binary Search

20AI&ML3353: Data Structures Laboratory


Page No-
2023-2024
VR20 Registration No.

b. Calculate the time complexity of Linear Search

c. Calculate the time complexity of Binary Search

d. Define Time Complexity and Space Complexity.

(Faculty use only)

Comments of the Evaluator: Evaluator’s Observation

Marks Secured: out of

20AI&ML3353: Data Structures Laboratory


Page No-
2023-2024
VR20 Registration No.

Lab Session-2
Date Time of the Session : to

CO-1: Sorting techniques: Insertion, Merge and Quick sorts.

Pre Lab:

Implement Insertion sort technique to arrange the elements in ascending order.

Input:
Number of elements: 10
Dataset: 30, 70, 20, 90, 34, 12, 32, 54, 71, 89

20AI&ML3353: Data Structures Laboratory


Page No-
2023-2024
VR20 Registration No.

In Lab

1. Develop a program to implement Merge Sort technique (Divide and conquer method)

Input:
Number of elements: 10
Dataset: 315, 219, 2, 678, 153, 248, 332, 464, 540, 49

20AI&ML3353: Data Structures Laboratory


Page No-
2023-2024
VR20 Registration No.

20AI&ML3353: Data Structures Laboratory


Page No-
2023-2024
VR20 Registration No.

20AI&ML3353: Data Structures Laboratory


Page No-
2023-2024
VR20 Registration No.

2. Develop a program to implement Quick sort technique (Divide and conquer method)

Input:
Number of elements: 10
Dataset: 5, 9, 2, 7, 3, 8, 1, 6, 0, 4

20AI&ML3353: Data Structures Laboratory


Page No-
2023-2024
VR20 Registration No.

20AI&ML3353: Data Structures Laboratory


Page No-
2023-2024
VR20 Registration No.

20AI&ML3353: Data Structures Laboratory


Page No-
2023-2024
VR20 Registration No.

Post Lab:

a. Write the time complexity of Quick sort


Best Case :
Average Case :
Worst Case :

b. Write the time complexity of Merge sort


Best Case :
Average Case :
Worst Case :

c. Write the time complexity of Insertion sort


Best Case :
Average Case :
Worst Case :

d. Write the recurrence for Merge sort

20AI&ML3353: Data Structures Laboratory


Page No-
2023-2024
VR20 Registration No.

(Faculty use only)

Comments of the Evaluator: Evaluator’s Observation

Marks Secured: out of

20AI&ML3353: Data Structures Laboratory


Page No-
2023-2024
VR20 Registration No.

Lab Session-3
Date Time of the Session : to

CO-1 Apply linear data structures to different applications.

Program Title: Implement Stack Operations

Pre Lab:

a. Define Data structure and Abstract Data Type (ADT)

b. Define Stack. List the Operations of Stack

c. How can you find the top of the element?

d. Write the condition for stack is full and stack is empty.

20AI&ML3353: Data Structures Laboratory


Page No-
2023-2024
VR20 Registration No.

In Lab:

1. Develop a program to implement Stack Operations using arrays.

Test Case:

Input: Stack Maximum Size : 5


List of Operations
1. PUSH
2. POP
3. Display Stack elements
4. Stack is Full
5. Stack is empty

Case 1: Initial Stack is empty, if you are trying to perform POP Operation
Output: Stack Underflow

Case 2: If your stack contains three elements, you are trying to perform PUSH
Operation.
Output: Top is updated by one and new element is inserted…

Case 3: If your stack contains four elements, you are trying to perform POP
Operation.
Output: Top reduced by one and top element is deleted from the stack

20AI&ML3353: Data Structures Laboratory


Page No-
2023-2024
VR20 Registration No.

20AI&ML3353: Data Structures Laboratory


Page No-
2023-2024
VR20 Registration No.

20AI&ML3353: Data Structures Laboratory


Page No-
2023-2024
VR20 Registration No.

Post Lab:

a. After Completion of the following Stack Operations what are the element on the stack
(assume stack size is five)
PUSH (Stack, ’V’)
PUSH (Stack, ’R’)
PUSH (Stack, ’S’)
PUSH (Stack, ’E’)
PUSH (Stack, ’C’)
POP (Stack)
POP (Stack)
POP (Stack)
PUSH (Stack, ’C’)
PUSH (Stack, ’E’) Initially stack is empty
PUSH (Stack, ’S’)

20AI&ML3353: Data Structures Laboratory


Page No-
2023-2024
VR20 Registration No.

b. If your stack is empty, you are trying to delete an element from the stack what happened?

c. If your stack is full, you are trying to perform PUSH() operation then what happened?

(Faculty use only)

Comments of the Evaluator: Evaluator’s Observation

Marks Secured: out of

20AI&ML3353: Data Structures Laboratory


Page No-
2023-2024
VR20 Registration No.

Lab Session-4
Date Time of the Session : to

CO-1 Apply linear data structures to different applications.

Program Title: Implement Stack Applications

Pre Lab:

1. Write an algorithm for push and pop operations of the stack.

20AI&ML3353: Data Structures Laboratory


Page No-
2023-2024
VR20 Registration No.

2. List out real time applications for Stack.

3. Define recursion.

4. What is an expression? What are the different types of expressions?

5. What is need of converting infix expression into postfix expression?

20AI&ML3353: Data Structures Laboratory


Page No-
2023-2024
VR20 Registration No.

In Lab:

1. Develop a program to implement Infix to Postfix Conversion (applications of Stack)

Test case:
Input : a + b
Output: a b +

Input : a – b * c
Output: a b c * -

20AI&ML3353: Data Structures Laboratory


Page No-
2023-2024
VR20 Registration No.

20AI&ML3353: Data Structures Laboratory


Page No-
2023-2024
VR20 Registration No.

20AI&ML3353: Data Structures Laboratory


Page No-
2023-2024
VR20 Registration No.

20AI&ML3353: Data Structures Laboratory


Page No-
2023-2024
VR20 Registration No.

2. Develop a program to implement Postfix Expression Evaluation (applications of Stack)


Test case:
Input : 4 5+
Output: 9

Input : 9 2 3 * -
Output: 3

20AI&ML3353: Data Structures Laboratory


Page No-
2023-2024
VR20 Registration No.

20AI&ML3353: Data Structures Laboratory


Page No-
2023-2024
VR20 Registration No.

20AI&ML3353: Data Structures Laboratory


Page No-
2023-2024
VR20 Registration No.

20AI&ML3353: Data Structures Laboratory


Page No-
2023-2024
VR20 Registration No.

Post Lab:
a. Write the postfix expression for the following infix expression
a. a+b*c/d-e+f

b. a*(b-c*d)+(e/f)-g

20AI&ML3353: Data Structures Laboratory


Page No-
2023-2024
VR20 Registration No.

b. Evaluate the following postfix expression


i. 35*46-/2 +

ii. AB–C*D+
A=4 B=2 C=6 D=3

(Faculty use only)

Comments of the Evaluator: Evaluator’s Observation

Marks Secured: out of

20AI&ML3353: Data Structures Laboratory


Page No-
2023-2024
VR20 Registration No.

Lab Session-5
Date Time of the Session : to

CO-1 Apply linear data structures to different applications.

Program Title: Implement Queue Operations

Pre Lab:

a. Define Queue

b. List the Operations of Queue

c. Write real time applications to Queue data structures.

20AI&ML3353: Data Structures Laboratory


Page No-
2023-2024
VR20 Registration No.

In Lab:

1. Develop a program to implement Queue Operations using arrays.

Input: Queue Maximum Size : 4


List of Operations
1. Enqueue
2. Dequeue
3. Display Queue elements
4. Queue is Full
5. Queue is empty

Case 1: Initial Queue is empty, if you are trying to perform Enqueu Operation
Output: front and rear pointers\variables updated by one

Case 2: If your Queue contains three elements, you are trying to perform
Enqueue Operation.
Output: Rear position is updated by one and new element is inserted…

Case 3: If your Queue contains four elements, you are trying to perform
Dequeue Operation.
Output: Front reduced by one and one element is deleted from the Queue

20AI&ML3353: Data Structures Laboratory


Page No-
2023-2024
VR20 Registration No.

20AI&ML3353: Data Structures Laboratory


Page No-
2023-2024
VR20 Registration No.

20AI&ML3353: Data Structures Laboratory


Page No-
2023-2024
VR20 Registration No.

20AI&ML3353: Data Structures Laboratory


Page No-
2023-2024
VR20 Registration No.

Post Lab:
a. Compare Stacks and Queues

b. Write the condition to check whether queue is full or not.

c. After Completion of the following Queue Operations what are the element on the Queue
(Assume queue size is 10)

ENQUEUE (Queue, ’V’)


ENQUEUE (Queue, ’R’)
ENQUEUE (Queue, ’S’)
DEENQUEUE (Queue) Initially Queue is
ENQUEUE (Queue, ’E’) empty Front =0rear=
DE ENQUEUE (Queue) 0

20AI&ML3353: Data Structures Laboratory


Page No-
2023-2024
VR20 Registration No.

ENQUEUE (Queue, ’C’)


ENQUEUE (Queue, ’C’)
DE ENQUEUE (Queue)
ENQUEUE (Queue, ’E’)
ENQUEUE (Queue, ’S’)

Front = rear= Front = rear=

Front = rear= Front = rear=

Front = rear= Front = rear=

Front = rear= Front = rear=

Front = rear= Front = rear=

(Faculty use only)

Comments of the Evaluator: Evaluator’s Observation

Marks Secured: out of

20AI&ML3353: Data Structures Laboratory


Page No-
2023-2024
VR20 Registration No.

Lab Session-6
Date Time of the Session : _to

CO-1 Apply linear data structures to different applications.

Program Title: Implement Circular Queue Operations

Pre Lab:

1. Define Circular Queue

2. What is the drawback of Linear Queue?

3. List the applications of circular queue

20AI&ML3353: Data Structures Laboratory


Page No-
2023-2024
VR20 Registration No.

In Lab:

2. Develop a program to implement Circular Queue Operations using arrays.

Input: Circular Queue Maximum Size : 5


List of Operations
1. Enqueue
2. Dequeue
3. Display Queue elements
4. Queue is Full
5. Queue is empty

Case 1: If your Circular Queue contains four (index 1 to index 5) elements, you
are trying to perform Enqueue Operation.
Output: Update rear position to index 0 and new element is inserted…

Case 2: If your Queue contains four elements, you are trying to perform
Dequeue Operation.
Output: Update front position and one element is deleted from the Queue

20AI&ML3353: Data Structures Laboratory


Page No-
2023-2024
VR20 Registration No.

20AI&ML3353: Data Structures Laboratory


Page No-
2023-2024
VR20 Registration No.

20AI&ML3353: Data Structures Laboratory


Page No-
2023-2024
VR20 Registration No.

20AI&ML3353: Data Structures Laboratory


Page No-
2023-2024
VR20 Registration No.

20AI&ML3353: Data Structures Laboratory


Page No-
2023-2024
VR20 Registration No.

Post Lab:

a. If circular queue implemented using an arrays, size of the circular queue is MAX_SIZE.
Write the conditions for circular queue getting full and empty?

b. A data structure in which elements can be inserted or deleted at/from both the
ends butnot in the middle is?

(Faculty use only)

Comments of the Evaluator: Evaluator’s Observation

Marks Secured: out of

20AI&ML3353: Data Structures Laboratory


Page No-
2023-2024
VR20 Registration No.

Lab Session- 7
Date Time of the Session : _to

CO-2 Solve problems using linked list.

Program Title: Implement Singly Linked List Operations

Pre Lab:

1. What is self-referential Structure?

2. Write about Dynamic memory management functions.

20AI&ML3353: Data Structures Laboratory


Page No-
2023-2024
VR20 Registration No.

20AI&ML3353: Data Structures Laboratory


Page No-
2023-2024
VR20 Registration No.

3. Define Structure variable with the name college and the structure members are
department name, department code and number of students in each department. Define
one structure type (and Pointer) variable to read and write the structure members.

20AI&ML3353: Data Structures Laboratory


Page No-
2023-2024
VR20 Registration No.

20AI&ML3353: Data Structures Laboratory


Page No-
2023-2024
VR20 Registration No.

In Lab:
Develop a Program to implement Singly Linked Operations
a) Insertion at the end b) Delete at the end c) Display the list elements

Test Case: Head


NULL

1. Insert the new node (10) in the empty List

Head
2024 10

2. Insert the new node (20) at the end of the list

Head
2024 10 20

3. Insert the new node (30) at the end of the list

Head
2024 10 20 30

4. Delete a node from the end of the list


Head 10 20
2024
5. Delete a node from the end of the list

Head
2024 10
6. Delete a node from the end of the list

Head
NULL

7. Delete a node from the end of the list

List is empty

20AI&ML3353: Data Structures Laboratory


Page No-
2023-2024
VR20 Registration No.

20AI&ML3353: Data Structures Laboratory


Page No-
2023-2024
VR20 Registration No.

20AI&ML3353: Data Structures Laboratory


Page No-
2023-2024
VR20 Registration No.

20AI&ML3353: Data Structures Laboratory


Page No-
2023-2024
VR20 Registration No.

20AI&ML3353: Data Structures Laboratory


Page No-
2023-2024
VR20 Registration No.

Post Lab:
a. What are the advantages and disadvantages of linked list?

b. What is the time complexity for inserting an element into the Singly linked list (end
of the list)?

c. Write a code for inserting an element into the Singly linked list at the specific
location.

20AI&ML3353: Data Structures Laboratory


Page No-
2023-2024
VR20 Registration No.

(Faculty use only)

Comments of the Evaluator: Evaluator’s Observation

Marks Secured: out of

20AI&ML3353: Data Structures Laboratory


Page No-
2023-2024
VR20 Registration No.

Lab Session-8
Date Time of the Session : _to

CO-2 Solve problems using linked list.

Program Title: Implement Stack and Queue Operations using Linked List

Pre Lab:

1. Develop a function to insert an element in the Singly linked list at the beginning
position.

20AI&ML3353: Data Structures Laboratory


Page No-
2023-2024
VR20 Registration No.

2. Develop a function to delete an element from the Singly linked list. (from beginning
position)

20AI&ML3353: Data Structures Laboratory


Page No-
2023-2024
VR20 Registration No.

In Lab:
Develop a Program to implement Stack Operations using Linked List

Test Case:

Head
3024 30 20 10

1. Perform PUSH Operation (40)

Head
4024 40 30 20 10

2. Perform PUSH Operation (50)

Head
5024 50 40 30 20 10
3. Print Top element in the stack

Head 5024 Top of the stack is 50

(Print head node value (i.e value @


5024))

4. Perform POP Operation


40 30 20 10
Head
4024
50 is deleted from the stack

5. Perform POP Operation

30 20 10
Head
3024
40 is deleted from the stack

20AI&ML3353: Data Structures Laboratory


Page No-
2023-2024
VR20 Registration No.

20AI&ML3353: Data Structures Laboratory


Page No-
2023-2024
VR20 Registration No.

20AI&ML3353: Data Structures Laboratory


Page No-
2023-2024
VR20 Registration No.

20AI&ML3353: Data Structures Laboratory


Page No-
2023-2024
VR20 Registration No.

20AI&ML3353: Data Structures Laboratory


Page No-
2023-2024
VR20 Registration No.

Develop a Program to implement Queue Operations using Linked List

Test Case:

Front Rear
1024 3024 10 20 30

1. Perform ENQUEUE Operation (40)

Front Rear
1024 4024 10 20 30 40

2. Perform ENQUEUE Operation (50)

Front Rear
1024 5024 10 20 30 40 50

3. Print Front and rear elements in the Queue

Rear 5024 Front is 10 and Rear is 50


Front
1024 (i.e value @ 1024 and value @ 5024)

4. Perform DEQUEUE Operation

Front Rear 5024 20 30 40 50


2024
10 is deleted from the Queue

5. Perform POP Operation

Front Rear 5024 30 40 50


3024
40 is deleted from the stack

20AI&ML3353: Data Structures Laboratory


Page No-
2023-2024
VR20 Registration No.

20AI&ML3353: Data Structures Laboratory


Page No-
2023-2024
VR20 Registration No.

20AI&ML3353: Data Structures Laboratory


Page No-
2023-2024
VR20 Registration No.

20AI&ML3353: Data Structures Laboratory


Page No-
2023-2024
VR20 Registration No.

20AI&ML3353: Data Structures Laboratory


Page No-
2023-2024
VR20 Registration No.

20AI&ML3353: Data Structures Laboratory


Page No-
2023-2024
VR20 Registration No.

Post Lab:
a. Write an algorithm to implement the stack operations using Queue.

20AI&ML3353: Data Structures Laboratory


Page No-
2023-2024
VR20 Registration No.

20AI&ML3353: Data Structures Laboratory


Page No-
2023-2024
VR20 Registration No.

b. Write an algorithm to compare two stacks.

20AI&ML3353: Data Structures Laboratory


Page No-
2023-2024
VR20 Registration No.

c. How will you traverse linked list in reverse order

(Faculty use only)

Comments of the Evaluator: Evaluator’s Observation

Marks Secured: out of

20AI&ML3353: Data Structures Laboratory


Page No-
2023-2024
VR20 Registration No.

Lab Session-9
Date Time of the Session : to

CO-2 Solve problems using linked list.

Program Title: Implement Doubly Linked List Operations

Pre Lab:

1. What is Doubly linked list?

2. How to represent a node in Doubly linkedlist?

3. Differentiate between Singly and Doubly linked list.

20AI&ML3353: Data Structures Laboratory


Page No-
2023-2024
VR20 Registration No.

In Lab:
Develop a Program to implement Doubly Linked Operations
a) Insertion at the end b) Delete from the end c)Display the list elements

Test Case:
Head
NULL
1. Insert the new node (10) in the empty List

Head

1024 10

2. Insert the new node (20) at the end of the list


Head
1024 10 20

3. Insert the new node (30) at the end of the list

Head
1024 10 20 30

4. Delete a node from the end of the list

Head 10 20
1024

5. Delete a node from the end of the list

Head
1024
10

6. Delete a node from the end of the list


Head
NULL

7. Delete a node from the end of the list List is empty

20AI&ML3353: Data Structures Laboratory


Page No-
2023-2024
VR20 Registration No.

20AI&ML3353: Data Structures Laboratory


Page No-
2023-2024
VR20 Registration No.

20AI&ML3353: Data Structures Laboratory


Page No-
2023-2024
VR20 Registration No.

20AI&ML3353: Data Structures Laboratory


Page No-
2023-2024
VR20 Registration No.

20AI&ML3353: Data Structures Laboratory


Page No-
2023-2024
VR20 Registration No.

20AI&ML3353: Data Structures Laboratory


Page No-
2023-2024
VR20 Registration No.

20AI&ML3353: Data Structures Laboratory


Page No-
2023-2024
VR20 Registration No.

20AI&ML3353: Data Structures Laboratory


Page No-
2023-2024
VR20 Registration No.

Post Lab:

a. What are the advantages of Doubly linked list compare with Singly linked list (show
withdiagrammatic form)?

b. Draw Singly and Doubly linked list for the following Operations
Insert(list, ‘A’)
Insert(list, ‘E’)
Insert(List,’I’)
Delete(List)
Insert(List,’O’)
Delete(List)
Insert(List,’U’)

20AI&ML3353: Data Structures Laboratory


Page No-
2023-2024
VR20 Registration No.

c. What is the time complexity for finding the element in the Doubly linked list?

(Faculty use only)

Comments of the Evaluator: Evaluator’s Observation

Marks Secured: out of

20AI&ML3353: Data Structures Laboratory


Page No-
2023-2024
VR20 Registration No.

Lab Session - 10
Date of Time of the Session : _to

CO-3 Implement operations on binary trees and binary search trees.

Program Title: Implement Binary Search Tree Operations

Pre Lab:
1. Write Tree terminology

20AI&ML3353: Data Structures Laboratory


Page No-
2023-2024
VR20 Registration No.

2. How can we represent trees in computer memory?

20AI&ML3353: Data Structures Laboratory


Page No-
2023-2024
VR20 Registration No.

3. Define Binary Search. What are the different ways we can traverse Binary Search Tree?

20AI&ML3353: Data Structures Laboratory


Page No-
2023-2024
VR20 Registration No.

4. What are the properties of Binary Tree.

5. In a Full Binary Tree, how many nodes exists of a given height ’h’?

20AI&ML3353: Data Structures Laboratory


Page No-
2023-2024
VR20 Registration No.

In Lab:
Develop a program to implement Binary Tree with following Operations
a. BST - Find, findmax, findmin, insert
b. BST- Delete, Inorder, Preorder, Postorder traversal

Binary Search Tree Operations

BST Insert(7) Insert(19) Insert(29)

31 45
31 45

45
45 16 16
16 16

29 29
24
19

29 19 19
19

Delete(7) Delete(24) Delete(31) Delete(29)

Find Minimum Value : 16


Find Maximum Value: 45
In order Traversals : 16 24 31 45
Pre Order Traversals: 31 16 24 45
Post Order Traversals: 24 16 45 16

20AI&ML3353: Data Structures Laboratory


Page No-
2023-2024
VR20 Registration No.

20AI&ML3353: Data Structures Laboratory


Page No-
2023-2024
VR20 Registration No.

20AI&ML3353: Data Structures Laboratory


Page No-
2023-2024
VR20 Registration No.

20AI&ML3353: Data Structures Laboratory


Page No-
2023-2024
VR20 Registration No.

20AI&ML3353: Data Structures Laboratory


Page No-
2023-2024
VR20 Registration No.

20AI&ML3353: Data Structures Laboratory


Page No-
2023-2024
VR20 Registration No.

20AI&ML3353: Data Structures Laboratory


Page No-
2023-2024
VR20 Registration No.

Post Lab:

a. You are going to delete a node from the Binary search tree, if the selected node has two
children’s what we need to do?

b. Define Complete Binary Tree and Full Binary Tree.

20AI&ML3353: Data Structures Laboratory


Page No-
2023-2024
VR20 Registration No.

c. List different types of tree traversing methods.

d. What are the applications of Binary Search Tree (BST)?

20AI&ML3353: Data Structures Laboratory


Page No-
2023-2024
VR20 Registration No.

e. Construct a binary tree for the given In-order and Pre order traversal
In Order traversal: D B H E A I F J C G
Pre Order reversal: A B D E H C F I J G

20AI&ML3353: Data Structures Laboratory


Page No-
2023-2024
VR20 Registration No.

f. Construct a Binary Search Tree for the following datasets


i. Jan, Feb, Mar, Apr, May, Jun, Jul, Aug, Sep, Oct, Nov and Dec

20AI&ML3353: Data Structures Laboratory


Page No-
2023-2024
VR20 Registration No.

ii. Sunday, Monday, Tuesday, Wednesday, Thursday, Friday and Saturday

(Faculty Use only)

Comments of the Evaluator: Evaluator’s Observation


(Faculty use only)

Marks Secured: out of

20AI&ML3353: Data Structures Laboratory


Page No-
2023-2024
VR20 Registration No.

Lab Session-11
Date Time of the Session: _to

CO-3 Understand the operations on binary search tree and heap

Program Title: Operations on Heap and Heap Sort.

Pre Lab:

1. Write an algorithm for performing insert operations in a Max heap tree.

20AI&ML3353: Data Structures Laboratory


Page No-
2023-2024
VR20 Registration No.

2. Discuss the construction of a Min heap and how following operations are performed on a
Min heap

a. Find minimum operation


b. Deletion operation

20AI&ML3353: Data Structures Laboratory


Page No-
2023-2024
VR20 Registration No.

3. Explain array implementation of priority queue through an example.

20AI&ML3353: Data Structures Laboratory


Page No-
2023-2024
VR20 Registration No.

4. Construct Max heap and Min heap trees for the following data.

48, 8, 53, 40, 99, 68, 34, 2

20AI&ML3353: Data Structures Laboratory


Page No-
2023-2024
VR20 Registration No.

In-Lab

1. Write a C program to implement the following operations of a priority queue using a


single linked list.
a. Insert b. Delete c. Display

20AI&ML3353: Data Structures Laboratory


Page No-
2023-2024
VR20 Registration No.

20AI&ML3353: Data Structures Laboratory


Page No-
2023-2024
VR20 Registration No.

2. Develop a C program to implement Heap sort technique.

Input:

Number of elements: 10
Data: 15, 19, 2, 78, 53, 48, 32, 64, 40, 9

20AI&ML3353: Data Structures Laboratory


Page No-
2023-2024
VR20 Registration No.

20AI&ML3353: Data Structures Laboratory


Page No-
2023-2024
VR20 Registration No.

Post Lab

1. Describe each step while sorting the following numbers in ascending order using heap
sort.

9, 6, 8, 7, 21, 14, 15, 19, 13, 12

20AI&ML3353: Data Structures Laboratory


Page No-
2023-2024
VR20 Registration No.

20AI&ML3353: Data Structures Laboratory


Page No-
2023-2024
VR20 Registration No.

(Faculty use only)

Comments of the Evaluator: Evaluator’s Observation

Marks Secured: out of

20AI&ML3353: Data Structures Laboratory


Page No-
2023-2024
VR20 Registration No.

Lab Session-12
Date Time of the Session: _to

CO-4 Apply different graph traversal algorithms and hashing techniques to solve problems.

Program Title: Graph Traversal algorithms: Depth First Search and Breadth First Search

Pre Lab:

1. Write an algorithm for adjacency matrix representation of a graph.

20AI&ML3353: Data Structures Laboratory


Page No-
2023-2024
VR20 Registration No.

2. Write an algorithm for incident matrix representation of a digraph.

20AI&ML3353: Data Structures Laboratory


Page No-
2023-2024
VR20 Registration No.

3. Draw the following graphs.


a. A graph with five vertices and seven edges. Exactly one of the edges should be a loop, and
do not have any multiple edges.
b. A directed graph that corresponds to this adjacency matrix:
0 1 2 3
1 | true false true false |
2 | true false false false |
3 | false false false true |
4 | true false true false |

20AI&ML3353: Data Structures Laboratory


Page No-
2023-2024
VR20 Registration No.

4. Consider this graph: v0 < v2


/ \
/ \
-> v1 <-/ \-> v4
/ \
/ \
/ \->v3 -------> v5
/ /
/ /
v6 < /

In what order are the vertices visited for a depth-first search that starts at v0? In what order are
the vertices visited for a breadth-first search that starts at v0?

20AI&ML3353: Data Structures Laboratory


Page No-
2023-2024
VR20 Registration No.

5. Write an algorithm for adjacency list representation of a graph.

20AI&ML3353: Data Structures Laboratory


Page No-
2023-2024
VR20 Registration No.

In Lab

1. Write a C program to perform Depth First Search traversal on a graph.

20AI&ML3353: Data Structures Laboratory


Page No-
2023-2024
VR20 Registration No.

20AI&ML3353: Data Structures Laboratory


Page No-
2023-2024
VR20 Registration No.

2. Write a C program to perform Breadth First Search Traversal on a graph.

20AI&ML3353: Data Structures Laboratory


Page No-
2023-2024
VR20 Registration No.

20AI&ML3353: Data Structures Laboratory


Page No-
2023-2024
VR20 Registration No.

Post Lab

1. Draw the adjacency list representation of the following graph.

20AI&ML3353: Data Structures Laboratory


Page No-
2023-2024
VR20 Registration No.

2. Write the time complexities of the following graph algorithms.

a. Adjacency matrix:

b. Incidence matrix:

c. Breadth First Search:

d. Depth First Search:

3. Write the space complexities of the following graph algorithms.

a. Adjacency matrix:

b. Incidence matrix:

c. Breadth First Search:

d. Depth First Search:

(Faculty use only)

Comments of the Evaluator: Evaluator’s Observation

Marks Secured: out of

20AI&ML3353: Data Structures Laboratory


Page No-

You might also like