AI in Healthcare Innovative use cases and applications.pdf
Assignment-6 (2).docx
1. Assignment-6
Data Structures and Algorithms lab
Write a program to implement the following recursive functions for Binary Search Tree. You
may choose any programming language.
Define a class or structure for defining the node structure. Sample One:
typedef struct NODE
{
int data;
struct NODE *left, *right;
}node;
Implement the following recursive functions with the given prototypes:
1.node* insert(node *root, int ele); // Insert an element into the Binary Search Tree
2.node* delete(node *root, int element_to_delete); // Delete a specified element
3.int findheight(node *root); // Find the height of a given node
4.int count_leaf_nodes(node *root); // Count the No. of leaf nodes present in the Tree
5.void inOrderTraversal(node *root); // Inorder Traversal of the Tree
6. node* findMaxElementTree(node *root); // Find the maximum element of the Tree
7. node* findMinimumElement(node *root); // Find the minimum element of the Tree
8.node* search (node *root, int SearchEle); // Search an element
9.node* findkthSmallestElement(node *root, int k); // Find kth Smallest element of the Tree
Write a main() and do the following operations in the main() in the order given below:
1. Insert 500, 400, 300, 700, 600, 650, 550, 450, 350, 200, 100, 50, 25, 375, 475
2. Print the inOrder Traversal
3. Delete 25
4. Print the InOrder Traversal
5. Find the Height of 500 (root node)
6. Delete 600
7. Print the InOrder Traversal
8. Delete 350
9. Print the InOrder Traversal
10. Delete 400
11. Print the InOrder Traversal
12. Search 300
13. Search 800
14. Search 75
15. Find the 3rd
Smallest element
16. Count the number of leaf nodes and print it
17. Find the height of right subtree of 500
18. Find the maximum element of the Tree
19. Find the minimum element of the Tree