Given snippet code below that you are required to complete. You are not allowed to make a new function or change any given code. Please complete each section that are marked with the notation “INSERT YOUR CODE HERE”. Once you complete the snippet below, your output should have the same result with the given output below

Database System Concepts
7th Edition
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Chapter1: Introduction
Section: Chapter Questions
Problem 1PE
icon
Related questions
Question

3. Snippet (LO1, LO2, LO3 - 20%)
Given snippet code below that you are required to complete. You are not allowed to make
a new function or change any given code. Please complete each section that are marked
with the notation “INSERT YOUR CODE HERE”. Once you complete the snippet below, your
output should have the same result with the given output below.
Description:
a. search()
This function is built for searching whether the data has the same value as the node
in the existing Binary Search Tree. If it is found then print “found”, otherwise print
“not found”
b. insert()
This function is built for inserting a new node in the existing Binary Search Tree
c. inorder_traversal ()
This function is built for printing out the existing Binary Search Tree in inorder way.
d. preorder_traversal ()
This function is built for printing out the existing Binary Search Tree in preorder way.
e. postorder_traversal ()
This function is built for printing out the existing Binary Search Tree in postorder
way.
f. executeDeleteNode ()
This function is built for deleting a node in the existing Binary Search Tree. If the
node is either root or parent, then find replacement for the node otherwise delete
the leaf node.
g. deleteNode()
This function is built for searching the node in the existing Binary Search Tree that
want to be deleted
h. minValue()
This function is built for searching the minimum value in the existing Binary Search
Tree.
i. maxValue()
This function is built for searching the maximum value in the existing Binary Search
Tree.

j. count()
This function is built for counting how many nodes in the existing Binary Search Tree
k. height_of_binary_tree()
This function is built for knowing the height of the existing Binary Search Tree
#include <stdio.h>
#include <conio.h>
#include <malloc.h>
struct node {
int key;
struct node *left;
struct node *right;
} *root;
void search(struct node* curr, int find) {
//INSERT YOUR CODE HERE
}
void insert(struct node* curr, int val) {
struct node *new_node = (struct node*) malloc(sizeof(struct node));
new_node->key = val;
new_node->left = NULL;
new_node->right = NULL;
if (root == NULL) {
root = new_node;
}
else if (val != curr->key) {
if (val < curr->key && curr->left == NULL) {
curr->left = new_node;
}
else if (val > curr->key && curr->right == NULL) {
curr->right = new_node;
}
else if (val < curr->key && curr->left != NULL) {
insert(curr->left, val);
}
else if (val > curr->key && curr->right != NULL) {
insert(curr->right, val);
}
}
}
void inorder_traversal(struct node* curr) {
if (curr == NULL) return;
inorder_traversal(curr->left);
printf("%d ", curr->key);
inorder_traversal(curr->right);
}
void preorder_traversal(struct node* curr) {
//INSERT YOUR CODE HERE
}
void postorder_traversal(struct node* curr) {
//INSERT YOUR CODE HERE
}
void executeDeleteNode(struct node* parent, struct node* curr) {
//INSERT YOUR CODE HERE

}
void deleteNode(struct node* curr, int find) {
struct node *parent;
parent = curr;
while (curr != NULL && curr->key != find) {
if (find < curr->key) {
parent = curr;
curr = curr->left;
}
else if (find > curr->key) {
parent = curr;
curr = curr->right;
}
}
if (curr == NULL) {
printf("%d is not found");
}
else if (curr->key == find) {
executeDeleteNode(parent, curr);
}
}
int minValue(struct node* node) {
//INSERT YOUR CODE HERE
}
int maxValue(struct node* node){
//INSERT YOUR CODE HERE
}
int count(struct node* node){
//INSERT YOUR CODE HERE
}
int height_of_binary_tree(struct node *node){
//INSERT YOUR CODE HERE
}
int main() {
root = NULL;
insert(root, 54);
insert(root, 81);
insert(root, 16);
insert(root, 27);
insert(root, 9);
insert(root, 36);
insert(root, 63);
insert(root, 72);
printf("Total node in BST: %d \n",count(root));
printf("Height of binary tree : %d\n ", height_of_binary_tree(root));
printf("\nInorder: "); inorder_traversal(root);
printf("\nPreorder: "); preorder_traversal(root);
printf("\nPostorder: "); postorder_traversal(root);
puts("");
deleteNode(root, 54);
printf("\nPreorder (after del 54): "); preorder_traversal(root);

deleteNode(root, 9);
printf("\nPostorder (after del 9): "); postorder_traversal(root);
deleteNode(root, 81);
printf("\nInorder (after del 81): "); inorder_traversal(root);
puts("");
printf("Min value: %d \n", minValue(root));
printf("Max value: %d \n", maxValue(root));
puts("");
search(root, 10);
search(root, 8);
_getch();
return 0;
}

PLEASE HELP SIR, THX.

b My Questions | bartleby
xe Exam Online
O Formulir Soal Ujian
C Tutor - Visualize C code exe X
G #include <stdio.h> #include
Wondershare Visual Stuc
My
Computer
8 https://databinuscampussolution.file.core.windows.net/bm5-filesync/exam_question/20210406033049_COM.
Filmora X
Code
->
- +
| D Page view A Read aloud V Draw
9 Highlight
of 7
File
Home
printi("Min value: ša \n", minvalue (root)I
printf("Max value: %d \n", maxValue(root));
Recycle Bin
* Cut
E Copy
Paste
Format Paint
puts ("");
search (root, 10);
search (root, 8);
Clipboard
Slides
Outline
My- --
Document..
18
getch ();
NUS
Evaluation: Postfix
return 0;
. la
buh)
MYNetwerk
4652 uhd)
2-+341n
pep 3
Output:
pep 3 d
Total node in BST: 8
Height of binary tree : 4
19
Google
Chrome
TeINUS
Evaluation: Prefix N
Fan framrigtn
Inorder: 9 16 27 36 54 63 72 81
Preorder: 54 16 9 27 36 81 63 72
Postorder: 9 36 27 16 72 63 81 54
VLC media
player
Preorder (after del 54): 36 16 9 27 81 63 72
Postorder (after del 9): 27 16 72 63 81 36
Inorder (after del 81): 16 27 36 63 72
Min value: 16
Max value: 72
20
Evaluation: Pref ix N
- Ueing a
- Daluating apnte restimrtart
nt thetingamadttgittod
Microsoft
Word 2010
- You anditby yunt
72 is found
8 is not found
21
Microsoft
MUS
PowerPoi.
Conversion: Infix to Post
Manually
Ngorithm
Santh tr the cprtahih hnthe
Put that gortrttndtecornd
Receat
unthit
13:47
P Type here to search
DEV
Pa
A ENG
LUNE
20/04/2021
Transcribed Image Text:b My Questions | bartleby xe Exam Online O Formulir Soal Ujian C Tutor - Visualize C code exe X G #include <stdio.h> #include Wondershare Visual Stuc My Computer 8 https://databinuscampussolution.file.core.windows.net/bm5-filesync/exam_question/20210406033049_COM. Filmora X Code -> - + | D Page view A Read aloud V Draw 9 Highlight of 7 File Home printi("Min value: ša \n", minvalue (root)I printf("Max value: %d \n", maxValue(root)); Recycle Bin * Cut E Copy Paste Format Paint puts (""); search (root, 10); search (root, 8); Clipboard Slides Outline My- -- Document.. 18 getch (); NUS Evaluation: Postfix return 0; . la buh) MYNetwerk 4652 uhd) 2-+341n pep 3 Output: pep 3 d Total node in BST: 8 Height of binary tree : 4 19 Google Chrome TeINUS Evaluation: Prefix N Fan framrigtn Inorder: 9 16 27 36 54 63 72 81 Preorder: 54 16 9 27 36 81 63 72 Postorder: 9 36 27 16 72 63 81 54 VLC media player Preorder (after del 54): 36 16 9 27 81 63 72 Postorder (after del 9): 27 16 72 63 81 36 Inorder (after del 81): 16 27 36 63 72 Min value: 16 Max value: 72 20 Evaluation: Pref ix N - Ueing a - Daluating apnte restimrtart nt thetingamadttgittod Microsoft Word 2010 - You anditby yunt 72 is found 8 is not found 21 Microsoft MUS PowerPoi. Conversion: Infix to Post Manually Ngorithm Santh tr the cprtahih hnthe Put that gortrttndtecornd Receat unthit 13:47 P Type here to search DEV Pa A ENG LUNE 20/04/2021
Expert Solution
steps

Step by step

Solved in 2 steps

Blurred answer
Knowledge Booster
Function Arguments
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
Database System Concepts
Database System Concepts
Computer Science
ISBN:
9780078022159
Author:
Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:
McGraw-Hill Education
Starting Out with Python (4th Edition)
Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON
Digital Fundamentals (11th Edition)
Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON
C How to Program (8th Edition)
C How to Program (8th Edition)
Computer Science
ISBN:
9780133976892
Author:
Paul J. Deitel, Harvey Deitel
Publisher:
PEARSON
Database Systems: Design, Implementation, & Manag…
Database Systems: Design, Implementation, & Manag…
Computer Science
ISBN:
9781337627900
Author:
Carlos Coronel, Steven Morris
Publisher:
Cengage Learning
Programmable Logic Controllers
Programmable Logic Controllers
Computer Science
ISBN:
9780073373843
Author:
Frank D. Petruzella
Publisher:
McGraw-Hill Education