Professional Documents
Culture Documents
Total Marks: 04
Obtained Marks:
Question
Write a program that prompts the user for a number, inserts it in the
BST and displays the contents of the tree using inorder
traversal. Give the source code and the runtime screen. Use the
data 50,30,20,40,70,60,80 to test your program.
Note:
⦁ Change the filename to your ID, e.g. 2073105.doc
⦁ Upload the .doc on Google Classroom.
⦁ Make sure that the output screen does not have black
background.
⦁ Poor indentation and wrong format will result in deduction of
marks.
Code:
#include <iostream>
using namespace std;
struct Node {
int key;
struct Node *left, *right;
};
{
if (root != NULL) {
inorder(root->left);
cout << root->key << " ";
inorder(root->right);
}
}
return node;
}
int main()
{
system("color F1");
insert(root, 50);
insert(root, 30);
insert(root, 20);
insert(root, 40);
insert(root, 70);
insert(root, 60);
DSA 3-B SZABIST-ISB
Shaheed Zulfikar Ali Bhutto Institute of Science & Technology
insert(root, 80);
return 0;
}
Output: