Showing posts with label DS LAB (II). Show all posts
Showing posts with label DS LAB (II). Show all posts

Wednesday, 16 June 2021

DS LAB (II) Assignment 1 Binary Search Tree and Traversals

Binary Search Tree and Traversals

It is a binary tree with the property that the value in a node is greater than any value in a node's left sub-tree and less than any value in the node's right sub-tree.

The Operations on Binary Search Tree are:

init (T)

creates an empty Binary search tree by initializing T to NULL

insert (T, x)

inserts the value x in the proper position in the Binary search tree

search (T, x)

searches if the value x is present in the search tree

inorder (T)

displays the node using inorder traversal of binary search tree

postorder (T)

displays the node using postorder traversal of binary search tree

preorder (T)

displays the node using preorder traversal of binary search tree

delete(T, x)

Deletes node x from binary search tree

Set A

a) Implement a Binary search tree (BST) library (btree.h) with operations – create, search, insert, inorder, preorder and postorder. Write a menu driven program that performs the above operations.

b) Write a program which uses binary search tree library and counts the total nodes and total leaf nodes in the tree.
int count(T) – returns the total number of nodes from BST
int countLeaf(T) – returns the total number of leaf nodes from BST 

Set B

a) Write a C program which uses Binary search tree library and implements following function with recursion:


Set C
a) Write a C program which uses Binary search tree library and implements following two functions: 

DS LAB(II) Assignment 2 Binary Tree Applications

Binary Tree Applications


 
Set A
a) Write a C program which uses Binary search tree library and displays nodes at each level, count of node at each level and total levels in the tree.
 
Set B
a) Write a program to sort n randomly generated elements using Heapsort method.

DS LAB (II) Assignment 3 Graph as Adjacency Matrix

Graph as Adjacency Matrix


Set B
a) Write a C program that accepts the vertices and edges of a graph and store it as an adjacency matrix. Implement function to traverse the graph using Breadth First Search (BFS) traversal.
b) Write a C program that accepts the vertices and edges of a graph and store it as an adjacency matrix. Implement function to traverse the graph using Depth First Search (BFS) traversal.

DS LAB (II) Assignment 4 Graph as Adjacency List

Graph as Adjacency List


 

Set B
a) Write a C program that accepts the vertices and edges of a graph and store it as an adjacency list. Implement function to traverse the graph using Breadth First Search (BFS) traversal.

b) Write a C program that accepts the vertices and edges of a graph and store it as an adjacency list. Implement function to traverse the graph using Depth First Search (BFS) traversal.