CS8381 - Data Structures Laboratory Manual - by LearnEngineering - in
CS8381 - Data Structures Laboratory Manual - by LearnEngineering - in
in
SYLLABUS
COURSE OBJECTIVES
To implement linear and non-linear data structures
To understand the different operations of search trees
To implement graph traversal algorithms
To get familiarized to sorting and searching algorithms
LIST OF EXPERIMENTS:
n
1. Array implementation of Stack and Queue ADTs
g.i
2. Array implementation of List ADT
3. Linked list implementation of Stack, Queue and List ADTs
rin
4. Applications of List, Stack and Queue ADTs
5. Implementation of Binary Trees and operations of Binary Trees
ee
6. Implementation of Binary Search Trees
7. Implementation of AVL Trees
gin
8. Implementation of Heaps using Priority Queues.
9. Graph representation and Traversal algorithms
En
COURSE OUTCOMES
Le
given problem
Appropriately use the linear / non-linear data structure operations for a given
problem
Apply appropriate hash functions that result in a collision free scenario for data
storage and retrieval
Page 5 of 43
Page
Sl.No. Name of the Experiment
No.
1.a) Array implementation of Stack ADT
n
3. b)
g.i
3. c) Linked list implementation of List ADT
rin
4. b) Application of Queue ADT
a. Graph Representation
5.
ee
b. Graph Traversal – DFS and BFS
gin
6. Implementation of Searching algorithms - Linear Search and Binary Search
8. Implementation of Heaps
Page 6 of 43
Aim:
Algorithm:
1. Create a Stack[ ] with MAX size as your wish.
2. Write function for all the basic operations of stack - PUSH(), POP() and DISPLAY().
3. By using Switch case, select push() operation to insert element in the stack.
Step 1: Check whether stack is FULL. (top == SIZE-1)
Step 2: If it is FULL, then display "Stack is FULL!!! Insertion is not possible!!!" and
n
terminate the function.
g.i
Step 3: If it is NOT FULL, then increment top value by one (top++) and set stack[top]
to value (stack[top] = value).
rin
4. Similarly, By using Switch case, select pop() operation to delete element from the stack.
Step 1: Check whether stack is EMPTY. (top == -1)
Step 2: If it is EMPTY, then display "Stack is EMPTY!!! Deletion is not possible!!!" and
ee
terminate the function.
Step 3: If it is NOT EMPTY, then delete stack[top] and decrement top value by one
gin
(top--).
5. Similarly, By using Switch case, select display() operation to display all element from the
stack.
En
Sample output :
w.
--------------------------------
1.PUSH
2.POP
3.DISPLAY
4.EXIT
Enter the Choice:1
Enter a value to be pushed:12
Page 7 of 43
98
24
12
Press Next Choice
Enter the Choice:2
n
Enter the Choice:3
g.i
The elements in STACK
rin
24
12
Press Next Choice
Enter the Choice:4
EXIT POINT
ee
gin
Result:
En
Thus the C program to implement Stack ADT by using array is executed successfully and
the output is verified.
arn
Program Outcome:
Le
Thus the student can know to implement Linear Data Structure – Stack by using array
w.
Applications:
ww
1. Expression evaluation
2. Function call and return process.
Page 8 of 43
Aim:
To write a C program to implement Queue ADT by using arrays
Algorithm:
1. Create a Queue[ ] with MAX size as your wish.
2. Write function for all the basic operations of stack - Enqueue(), Dequeue() and Display().
3. By using Switch case, select Enqueue() operation to insert element in to the rear/back end
of the queue.
Check whether queue is FULL. (rear == SIZE-1)
If it is FULL, then display "Queue is FULL!!! Insertion is not possible!!!" and terminate
n
the function.
g.i
If it is NOT FULL, then increment rear value by one (rear++) and set queue[rear] =
value
rin
4. Similarly, by using Switch case, select Dequeue() function is used to remove the element
from the front end of the queue.
Check whether queue is EMPTY. (front == rear)
ee
If it is EMPTY, then display "Queue is EMPTY!!! Deletion is not possible!!!" and
gin
terminate the function.
Step 3: If it is NOT EMPTY, then increment the front value by one (front ++). Then
display queue[front] as deleted element. Then check whether both front and rear are
En
equal (front == rear), if it TRUE, then set both front and rear to '-1' (front = rear = -1).
5. Similarly, by using Switch case, select display() operation to display all element of the
queue.
arn
Step 3: Display 'queue[i]' value and increment 'i' value by one (i++). Repeat the same
until 'i' value is equal to rear (i <= rear)
w.
Output:
1.Insert element to queue
2.Delete element from queue
3.Display all elements of queue
4.Quit
Enter your choice : 1
Inset the element in queue : 10
Page 9 of 43
n
2.Delete element from queue
g.i
3.Display all elements of queue
4.Quit
rin
Enter your choice : 1
Inset the element in queue : 30
4.Quit
Enter your choice : 3
w.
Queue is :
15 20 30
1.Insert element to queue
ww
Page 10 of 43
Result:
Thus the C program to implement Stack ADT by using array is executed successfully and
the output is verified.
Program Outcome:
Thus the student can know to implement Linear Data Structure – Queue by using array
Applications:
1. Queue is used by Operating systems for job scheduling.
2. Queue is used in networking to handle congestion.
n
g.i
Viva Voce:
rin
1. What is linear and Non-linear data structure?
2. What is array?
3. Define ADT. ee
gin
4. What is Stack and list the operations of stack?
5. What is Queue and list the operations of queue?
6. How the insertion and deletion takes plays in stack?
En
Page 11 of 43
Aim:
To write a C program to implement List ADT by using arrays
Algorithm:
1. Create an array[ ] with MAX size as your wish.
2. Write function for all the basic operations of list - create(), insert(), deletion(), search(),
display().
3. By using Switch case, select create() operation to create the list.
List Will be in the form: A1, A2, A3, .... An
n
First Element of the List: A1
g.i
Last Element of the List: An
ith Element of the List: Ai ,
rin
Position of Element Ai : i , Position ranges from 0 to N
Size of the List: N
ee
Empty List: If Size of the list is Zero (i.e N=0), it is Empty List.
Precedes and Succeeds: For any list except empty list, we say that Ai+1 follows
gin
(or succeeds) Ai (i<N) and that Ai-1 precedes Ai (i>1)
4. Similarly, by using Switch case, select insert() operation to insert element in the list.
Insert x at position p in list L
En
6. Similarly, by using Switch case, select search() function is used to retrieve the required
element from the list if it is available.
w.
Output:
Main Menu
1. Create
2. Delete
3. Search
Page 12 of 43
4. Insert
5.Display
6.Exit
Enter your Choice: 3
Enter the number of nodes 3
Enter the element: 67
Enter the element: 69
Enter the element: 71
Do You Want to continue: y
Main Menu
1. Create
2. Delete
3. Search
4. Insert
n
5.Display
6.Exit
g.i
Enter your Choice: 4
Enter the position u need to insert: 2
rin
Enter the element to insert: 56
The list after insertion:
The elements of the list ADT are:
67
69
56
ee
gin
71
Do You Want to continue: y
Main Menu
En
1.Create
2. Delete
3. Search
arn
4. Insert
5.Display
6.Exit
Le
1.Create
2. Delete
3. Search
4. Insert
5.Display
6.Exit
Enter your Choice: 3
Enter the element to be searched: 69
Value is in 1 position
Do You Want to continue: y
Main Menu
Page 13 of 43
1.Create
2. Delete
3. Search
4. Insert
5.Display
6.Exit
Enter your Choice: 5
The elements of the list ADT are:
67
69
71
Do You Want to continue: N
Result:
n
Thus the C program to implement List ADT by using array is executed successfully and the
g.i
output is verified.
Program Outcome:
rin
Thus the student can know to implement Linear Data Structure – List by using array
Applications:
ee
1. It is very much useful in sorting algorithms.
Example: Selection sort
gin
Viva Voce:
1. What is array?
En
2. Define ADT.
3. What is List?
arn
Page 14 of 43
Aim:
To write a C program to implement Stack ADT by using linked list
Algorithm:
1. Include all the header files which are used in the program. And declare all the user defined
functions.
2. Define a 'Node' structure with two members data and next.
3. Define a Node pointer 'top' and set it to NULL.
4. Implement the main method by displaying Menu with list of operations and make suitable
n
function calls in the main method.
g.i
5. push(value) - Inserting an element into the Stack
Create a newNode with given value.
rin
Check whether stack is Empty (top == NULL)
If it is Empty, then set newNode → next = NULL.
If it is Not Empty, then set newNode → next = top.
ee
Finally, set top = newNode.
6. pop() - Deleting an Element from a Stack
gin
1. Check whether stack is Empty (top == NULL).
2. If it is Empty, then display "Stack is Empty!!! Deletion is not possible!!!" and terminate
En
the function
3. If it is Not Empty, then define a Node pointer 'temp' and set it to 'top'.
4. Then set 'top = top → next'.
arn
4. Display 'temp → data --->' and move it to the next node. Repeat the same until temp
reaches to the first node in the stack (temp → next != NULL).
5. Finally! Display 'temp → data ---> NULL'.
ww
Output
****** MENU ******
1. Push
2. Pop
3. Display
4. Exit
Enter your choice:1
Enter the value to be insert: 3
Page 15 of 43
Insertion Success
****** MENU ******
1. Push
2. Pop
3. Display
4. Exit
Enter your choice:1
Enter the value to be insert: 5
Insertion Success
****** MENU ******
1. Push
2. Pop
n
3. Display
g.i
4. Exit
Enter your choice:2
Deleted Element: 5
rin
****** MENU ******
1. Push
2. Pop
3. Display
ee
gin
4. Exit
Enter your choice:3
3->NULL
En
2. Pop
3. Display
4. Exit
Le
Thus the C program to implement Stack ADT by using linked list is executed successfully
ww
Page 16 of 43
Ex. No. : 3b
Date: LINKED LIST IMPLEMENTATION OF QUEUE ADT
Aim:
To write a C program to implement Queue ADT by using linked list
Algorithm:
1. Include all the header files which are used in the program. And declare all the user defined
functions.
2. Define a 'Node' structure with two members data and next.
3. Define two Node pointers 'front' and 'rear' and set both to NULL.
n
4. Implement the main method by displaying Menu of list of operations and make suitable
g.i
function calls in the main method to perform user selected operation.
5. enqueue(value) - Inserting an element into the queue
Create a newNode with given value and set 'newNode → next' to NULL.
rin
Check whether queue is Empty (rear == NULL)
If it is Empty then, set front = newNode and rear = newNode.
ee
If it is Not Empty then, set rear → next = newNode and rear = newNode.
6. dequeue() - Deleting an Element from queue
Check whether queue is Empty (front == NULL).
gin
If it is Empty, then display "Queue is Empty!!! Deletion is not possible!!!" and terminate
from the function
If it is Not Empty then, define a Node pointer 'temp' and set it to 'front'.
En
Sample Output
ww
Page 17 of 43
Insertion is Success!!!
Insertion is Success!!!
n
2. Delete
3. Display
g.i
4. Exit
Enter your choice: 2
rin
Deleted element : 5
****** MENU ******
1. Insert
2. Delete
3. Display
ee
gin
4. Exit
Enter your choice: 3
7>>> NULL
En
arn
Result:
Thus the C program to implement Queue ADT by using linked list is executed successfully
and the output is verified.
Le
Program Outcome:
Thus the student can know to implement Linear Data Structure – Queue by using linked
w.
list
ww
Applications:
1. CPU scheduling algorithms implemented by using queue
2. In real life, Call Center phone systems will use Queues, to hold people calling them in an
order, until a service representative is free.
3.
Page 18 of 43
Ex. No. : 3c
Date: LINKED LIST IMPLEMENTATION OF LIST ADT
Aim:
To write a C program to implement List ADT by using linked list
Algorithm:
1. Create the header file Llist.h header file and we are include there header file into the main
function program by through #include<Llist.h>
2. Write function for all the basic operations of list - create(), insert(), deletion(), search(),
display().
n
3. By using Switch case, select create() operation to create the list.
g.i
List Will be in the form: A1, A2, A3, .... An
First Element of the List: A1
rin
Last Element of the List: An
ith Element of the List: Ai ,
Position of Element Ai : i , Position ranges from 0 to N
Size of the List: Nee
Empty List: If Size of the list is Zero (i.e N=0), it is Empty List.
gin
Precedes and Succeeds: For any list except empty list, we say that Ai+1 follows
(or succeeds) Ai (i<N) and that Ai-1 precedes Ai (i>1)
En
4. Similarly, by using Switch case, select insert() operation to insert element in the list.
Insert x at position p in list L
If p = END(L), insert x at the end
arn
6. Similarly, by using Switch case, select search() function is used to retrieve the required
element from the list if it is available.
returns element at position p on L
ww
Sample Output:
List Adt Using Linked List
1.Create
2.Insert
Page 19 of 43
3.Delete
4.MakeEmpty
5.Find
6.IsEmpty
7.Display
8.Deletelist
9.Exit
Enter ur Option: 1
List is Created.
Enter ur Option: 2
Enter the value: 100
Enter the Option: 2
Enter the value: 200
Enter the Option: 2
n
Enter the value: 300
Enter the Option: 2
g.i
Enter the value: 400
Enter the Option: 2
rin
Enter the value: 500
Enter the Option: 7
100
200
300
400
ee
gin
500
Enter the Option: 3
Enter the value to delete: 200
En
400
500
Enter the Option: 5
Le
Result:
Page 20 of 43
Thus the C program to implement List ADT by using linked list is executed successfully
and the output is verified.
Program Outcome:
Thus the student can know to implement Linear Data Structure – List by using linked list
Applications:
1. It is very much useful in sorting algorithms.
Example: Selection sort
Viva Voce:
1. What is list?
2. Define ADT.
n
3. What is linked List?
g.i
4. What are the different operations involved in List?
5. How the search operation works in list?
rin
6. How will you find the list is full?
7. How will you find the list is empty?
8. Define pointers in c. ee
gin
9. How the list used in computer memory?
10. What are the different types of linked list?
En
arn
Le
w.
ww
Page 21 of 43
Aim:
To write a C program to convert infix expression to postfix expression
Algorithm:
n
4. If a left parenthesis is encountered, push it onto Stack.
g.i
5. If an operator is encountered ,then:
1. Repeatedly pop from Stack and add to Y each operator (on the top of Stack) which
has the same precedence as or higher precedence than operator.
rin
2. Add operator to Stack.
[End of If]
6. If a right parenthesis is encountered ,then:
ee
1. Repeatedly pop from Stack and add to Y each operator (on the top of Stack) until
a left parenthesis is encountered.
gin
2. Remove the left Parenthesis.
[End of If]
[End of If]
7. END.
En
Sample Output:
arn
Result:
ww
Thus the C program to convert infix to postfix is executed successfully and the output is
verified.
Program Outcome:
Thus the student can know to implement infix to postfix by using stack
Page 22 of 43
Aim:
To write a C program to add two polynomials
Algorithm:
Algorithm to add two polynomials using linked list is as follows:-
Let p and q be the two polynomials represented by linked lists
1. While p and q are not null, repeat step 2.
n
2. If powers of the two terms are equal
g.i
then if the terms do not cancel
rin
then insert the sum of the terms into the sum Polynomial
Advance p
Advance q ee
gin
Else if the power of the first polynomial> power of second
Then insert the term from first polynomial into sum polynomial
En
Advance p
Else insert the term from second polynomial into sum polynomial
arn
Advance q
3. copy the remaining terms from the non empty polynomial into the sum polynomial.
Le
The third step of the algorithm is to be processed till the end of the polynomials has not been
reached.
w.
ww
Sample Output:
Create 1st expression
Enter Coeff:1
Enter Pow:2
Continue adding more terms to the polynomial list?(Y = 1/N = 0): 0
Stored the 1st expression
The polynomial expression is:
1x^2
Page 23 of 43
Result:
n
g.i
Thus the C program to implement polynomial addition by using linked list is executed
successfully and the output is verified.
rin
Program Outcome:
Thus the student can know to implement polynomial addition by using linked list
Viva Voce:
1. What is Stack?
ee
gin
2. List the operations of stack.
3. What is linked List?
En
Page 24 of 43
Aim:
To write a C program implement adjacent matrix and adjacency list
Algorithm:
1. Create a graph with getting no. of vertices and no. of edges
2. Implement adjacency matrix
3. Implement adjacency list
4. Close the program
n
g.i
Sample Output:
rin
A Program to represent a Graph by using an Adjacency Matrix method
1. Directed Graph
2. Un-Directed Graph
3. Exit ee
gin
Select a proper option :
How Many Vertices ? :
Vertices 1 & 2 are Adjacent ? (Y/N) : N
Vertices 1 & 3 are Adjacent ? (Y/N) : Y
En
1 2 0 2
ww
2 1 2 3
3 0 1 1
4 1 1 2
Page 25 of 43
1. Directed Graph
2. Un-Directed Graph
3. Exit
Select a proper option :
How Many Vertices ? :
Vertices 1 & 2 are Adjacent ? (Y/N) : N
Vertices 1 & 3 are Adjacent ? (Y/N) : Y
Vertices 1 & 4 are Adjacent ? (Y/N) : Y
Vertices 2 & 1 are Adjacent ? (Y/N) : Y
Vertices 2 & 3 are Adjacent ? (Y/N) : Y
Vertices 2 & 4 are Adjacent ? (Y/N) : N
Vertices 3 & 1 are Adjacent ? (Y/N) : Y
Vertices 3 & 2 are Adjacent ? (Y/N) : Y
Vertices 3 & 4 are Adjacent ? (Y/N) : Y
Vertices 4 & 1 are Adjacent ? (Y/N) : Y
n
Vertices 4 & 2 are Adjacent ? (Y/N) : N
g.i
Vertices 4 & 3 are Adjacent ? (Y/N) : Y
rin
ee
gin
En
arn
Le
w.
ww
Page 26 of 43
Aim:
To write a C program implement DFS and BFS graph traversal.
Algorithm:
DFS
1. Define a Stack of size total number of vertices in the graph.
2. Select any vertex as starting point for traversal. Visit that vertex and push it on
to the Stack.
3. Visit any one of the adjacent vertex of the verex which is at top of the stack
n
which is not visited and push it on to the stack.
g.i
4. Repeat step 3 until there are no new vertex to be visit from the vertex on top of
the stack.
5. When there is no new vertex to be visit then use back tracking and pop one
rin
vertex from the stack.
6. Repeat steps 3, 4 and 5 until stack becomes Empty.
7. When stack becomes Empty, then produce final spanning tree by removing
ee
unused edges from the graph
gin
BFS
2. Select any vertex as starting point for traversal. Visit that vertex and insert it into
the Queue.
3. Visit all the adjacent vertices of the verex which is at front of the Queue which is
arn
Sample Output:
Page 27 of 43
n
g.i
rin
Result: ee
gin
Thus the C programs to implement graph representation, Adjacency matrix and Adjacency
List, DFS and BFS are executed successfully and the outputs are verified.
En
Program Outcome:
arn
Thus the student can know to implement graph representation and graph traversal.
Viva Voce:
1. Define Graph
Le
5. Define DFS.
6. Define BFS.
7. List the application of DFS.
8. List the application of BFS.
9. Define Indegree
10. Define Outdegree.
Page 28 of 43
Aim:
To write a C Program to implement different searching techniques – Linear and Binary
search.
Algorithm:
Linear Search:
n
g.i
1. Read the search element from the user
2. Compare, the search element with the first element in the list.
rin
3. If both are matching, then display "Given element found!!!" and terminate the function
4. If both are not matching, then compare search element with the next element in the list.
5. Repeat steps 3 and 4 until the search element is compared with the last element in the list.
6.
terminate the function.
ee
If the last element in the list is also doesn't match, then display "Element not found!!!" and
gin
Binary search is implemented using following steps...
En
4. If both are matching, then display "Given element found!!!" and terminate the
function
5. If both are not matching, then check whether the search element is smaller or
Le
7. If the search element is larger than middle element, then repeat steps 2, 3, 4 and 5
for the right sublist of the middle element.
8. Repeat the same process until we find the search element in the list or until sublist
ww
Sample Output:
Linear Search
Enter size of the list: 4 Enter any
4 integer values: 4 8 1 9
Enter the element to be Search: 9
Page 29 of 43
Binary Search
Enter the size of the list: 4 Enter 4 i
nteger values in Assending order 1 6 9 12
Result:
Thus the C programs to implement Linear search and binary search are executed
n
g.i
successfully and output are verified.
Program Outcome:
rin
Thus the student can know to implement graph representation and graph traversal.
Viva Voce:
1. Define Search
2. Define Sequential Search.
ee
gin
3. What is Linear Search?
4. What is the time complexity of linear search?
En
Page 30 of 43
Date:
Aim:
To write a C program to implement different sorting algorithms - Bubble Sort, Radix Sort,
Shell Sort
Algorithm:
n
Bubble Sort:
g.i
1. Read the value of n
2. Get the inputs for array[n].
rin
3. Implement Bubble sort
Step 1: Repeat Steps 2 and 3 for i=1 to 10
Step 2: Set j=1
ee
Step 3: Repeat while j<=n
gin
(A) if a[i] < a[j]
Then interchange a[i] and a[j]
[End of if]
(B) Set j = j+1
En
Shell Sort
1. Read the value of n
w.
Radix Sort
1. Read the value of n
2. Get the inputs for array[n].
3. Implement radix sort
4. Stop the program
Page 31 of 43
Sample Output
Bubble sort
n
g.i
rin
Shell sort
Enter total no. of elements : 10
ee
Enter numbers : 36 432 43 44 57 63 94 3 5 6
gin
Sorted array is : 3 5 6 36 43 44 57 63 94 432
Radix sort
En
$ gcc RadixSort.c
$ ./a.out
Enter total no. of elements : 8
arn
Result:
Le
Thus the C programs to implement different sorting algorithms are executed successfully
and outputs are verified.
w.
Program Outcome:
ww
Page 32 of 43
n
g.i
rin
ee
gin
En
arn
Le
w.
ww
Page 33 of 43
Aim:
To write a Cprogram to implement heap data structure
Algorithm:
1. Start the program
2. Initially, declare n=0 for number of nodes in the heap’
3. By using while, create a menu for all operations of heaps
n
4. Perform all the operation and display the result
g.i
5. Stop the program
rin
Output:
$ cc pgm66.c
$ a.out
1.Insert the element ee
gin
2.Delete the element
3.Display all elements
4.Quit
Enter your choice : 1
En
4.Quit
Enter your choice : 1
Enter the element to be inserted to the list : 50
1.Insert the element
Le
Page 34 of 43
Result:
n
Thus the C programs to implement heap is executed successfully and output is verified.
g.i
Program Outcome:
Thus the student can know to implement heap data structure.
rin
Viva Voce:
1. What is heap?
ee
2. What are called heap property?
gin
3. List the operations of heap.
4. What is order property?
En
Page 35 of 43
Aim:
To write a Cprogram to implement binary tree and its operation
Algorithm:
1. Start the program
2. Create a tree
n
3. Perform the Insertion, Deletion and Search operation
g.i
4. Display Preorder, Postorder, Inorder traversal data
5. Stop the program
rin
Sample Output
> IN ORDER - ee
gin
> 0 2 2 8 9 9 16 17 18 19 19 20 20 21 21 22 23 26 28 29 35 37 40 41 45 50 51 54 62 63 6
3 64 66 66 68 69 7
0 71 73 75 76 76 78 79 79 80 83 83 85 86 89 91 91 95 96 96 101 101 101 102 103 104 10
4 104 106 107 108 108 109 111 112
En
113 114 115 115 115 116 117 117 119 120 123 124 125 127 127 129 129 129 130 130 1
34 134 137 139 139 140 142 143 143
arn
Page 36 of 43
-9
- 16
- 17
- 18
- 19
- 20
- 21
- 22
- 23
- 26
- 28
- 29
- 35
- 37
n
- 40
g.i
- 41
- 45
- 50
rin
- 51
- 54
- 62
- 63
- 64 ee
gin
- 66
- 68
- 69
- 70
En
- 71
- 73
- 75
arn
- 76
- 78
- 79
Le
- 80
- 83
- 85
w.
- 86
- 89
ww
- 91
- 95
- 96
<SUCCESS> = 43 <FAILED> = 57
Page 37 of 43
Result:
Thus the C programs to implement Binary tree is executed successfully and output is
verified.
Program Outcome:
Thus the student can know to implement binary tree.
n
g.i
rin
ee
gin
En
arn
Le
w.
ww
Page 38 of 43
Aim:
To write a Cprogram to implement binary search tree
Algorithm:
1. Start the program
2. Create a tree
3. Perform the Insertion, Deletion and Search operation
n
4. Display Preorder, Postorder, Inorder traversal data
g.i
5. Stop the program
rin
Sample Output:
cc tree43.c
$ a.out
OPERATIONS ---
1 - Insert an element into tree
ee
gin
2 - Delete an element from the tree
3 - Inorder Traversal
4 - Preorder Traversal
5 - Postorder Traversal
En
6 - Exit
40
Page 39 of 43
Result:
Thus the C programs to implement Binary search tree is executed successfully and output
is verified.
Program Outcome:
Thus the student can know to implement binary search tree.
n
g.i
Viva Voce:
1. What is tree?
rin
2. What are called binary tree?
3. List the operations of binary tree.
ee
4. What are the condition for left sub tree and right sub tree?
gin
5. What are called tree traversal?
6. What is In-order?
7. What is preorder?
En
8. What is postorder?
9. What are called binary search tree?
arn
Page 40 of 43
Aim:
To write a Cprogram to implement hash table
Algorithm:
1. Create a structure, data (hash table item) with key and value as data.
2. Now create an array of structure, data of some certain size (10, in this case). But,
the size of array must be immediately updated to a prime number just greater than
n
initial array capacity (i.e 10, in this case).
g.i
3. A menu is displayed on the screen.
4. User must choose one option from four choices given in the menu
rin
5. Perform all the operations
6. Stop the program
Sample Output ee
gin
Implementation of Hash Table in C
MENU-:
1. Inserting item in the Hash Table
En
Page 41 of 43
n
array[2] has no elements
g.i
array[3] has no elements
array[4] has no elements
rin
array[5] has no elements
array[6] has no elements
array[7] has no elements
array[8] has no elements
array[9] has no elements
ee
gin
*****************************
Page 42 of 43
Result:
n
g.i
Thus the C programs to implement hash table is executed successfully and output is
verified.
rin
Program Outcome:
Thus the student can know to implement hash table.
Viva Voce:
ee
gin
1. What is hash?
2. What are called bucket?
En
3. What is key?
4. What are called hash function.
arn
Page 43 of 43