Page 1 of 1

as soon as possible and please post the code as text, so I can copy it.

Posted: Fri May 20, 2022 10:47 am
by answerhappygod
as soon as possible
As Soon As Possible And Please Post The Code As Text So I Can Copy It 1
As Soon As Possible And Please Post The Code As Text So I Can Copy It 1 (35.51 KiB) Viewed 32 times
and please post the code as text, so I can copy it.
As Soon As Possible And Please Post The Code As Text So I Can Copy It 2
As Soon As Possible And Please Post The Code As Text So I Can Copy It 2 (35.51 KiB) Viewed 32 times
As Soon As Possible And Please Post The Code As Text So I Can Copy It 3
As Soon As Possible And Please Post The Code As Text So I Can Copy It 3 (35.51 KiB) Viewed 32 times
As Soon As Possible And Please Post The Code As Text So I Can Copy It 4
As Soon As Possible And Please Post The Code As Text So I Can Copy It 4 (35.51 KiB) Viewed 32 times
As Soon As Possible And Please Post The Code As Text So I Can Copy It 5
As Soon As Possible And Please Post The Code As Text So I Can Copy It 5 (34.42 KiB) Viewed 32 times
As Soon As Possible And Please Post The Code As Text So I Can Copy It 6
As Soon As Possible And Please Post The Code As Text So I Can Copy It 6 (31.72 KiB) Viewed 32 times
As Soon As Possible And Please Post The Code As Text So I Can Copy It 7
As Soon As Possible And Please Post The Code As Text So I Can Copy It 7 (26.46 KiB) Viewed 32 times
As Soon As Possible And Please Post The Code As Text So I Can Copy It 8
As Soon As Possible And Please Post The Code As Text So I Can Copy It 8 (29.82 KiB) Viewed 32 times
Lab 8: Binary Search Tree - Part 2 Objectives: 1. To be able to create and manipulate binary search tree. 2. To print (pre/in/post order), find the height and number of leaf node in a binary search tree. Background: There are many methods that can be implemented to manipulate a BST. Some of these methods are as follow: • Pre-order Display the data part of root element Traverse the left subtree Traverse the right subtree • In-order Traverse the left subtree Display the data part of root element Traverse the right subtree • Post-order Traverse the left subtree Traverse the right subtree Display the data part of root element • Height of a tree It represents the number of layers in a BST - 1 A leaf node is considered at height o • Printing leaf nodes A leaf in a BST is a node that has no children Note: Remember each node may have two children. Lab Exercise: Using the classes and methods implemented in Lab 7 do the following: 39

Add the following methods to class BSTree: preoder() preorderRec (root) Traverses and prints the contents of the tree pre-order according to the ID. • postoder() postorder Rec (root) Traverses and prints the contents of the tree post-order according to the ID. • height() heightRec (root) Returns the height of the tree. countLeaf Nodes 0) countLeaf NodesRec (root) Returns the number of leaf nodes in the tree. Write the expected time and space complexity as a comment at the beginning of each method of your class. Modify the test program form lab 7 to do the following: The program can perform the following: 1. Insert Students 2- Remove a Student 3. Check if a Student Exists 4- Print in order 5. Print preorder 6- Print postOrder 7- Height 8- Number of leaf nodes 9. Exit Please enter your selection: Sample Output Please, choose a number from the following list: 1 - Insert Students 40

2 - Remove a Student 3 - Check if a Student Exists 4 - Print inOrder 5 - Print preorder 6- Print postorder 7 - Height 8 - Number of leaf nodes 9 - exit Your choice is: 1 Enter the student's details or -1 or stop Enter a student's ID: 117 Enter the GPA: 2.3 Enter a student's ID: 113 Enter the GPA: Enter a student's ID: 121 Enter the GPA: 4.0 Enter a student's ID: 112 Enter the GPA: Enter a student's ID: 118 Enter the GPA: Enter a student's ID: 119 Enter the GPA: 3.3 Enter a student's ID: 116 Enter the GPA: 2.8 Enter a student's ID: 115 Enter the GPA: 3.5 Enter a student's ID: 122 Enter the GPA: 2.6 Enter a student's ID: -1 Please, choose a number from the following list: 1 - Insert Students 2 - Remove a Student 3 - Check if a Student Exists 4 - Print inOrder 5 - Print preorder 6 - Print postorder 7 - Height 8 - Number of leaf nodes 9 - exit Your choice is: 4 (112, 3.8) (113, 3.1) (115, 3.5) (116,2.8) (117,2.3) (118,1.9) (119,3.3) 41

(121, 4.0) (122,2.6) Please, choose a number from the following list: 1 - Insert Students 2 - Remove a Student 3 - Check if a Student Exists 4 - Print inOrder 5 - Print preorder 6- Print postorder 7 - Height 8 - Number of leaf nodes 9 - exit Your choice is: 5 (117,2.3) 13, 3.1) (112,3.8) (116,2.8) (115, 3.5) (121, 4.0) (118,1.9) (119,3.3) (122,2.6) Please, choose a number from the following list: 1 - Insert Students 2 - Remove a Student 3 - Check if a Student Exists 4 - Print inOrder 5 - Print preOrder 6 - Print postorder 7 - Height 8 - Number of leaf nodes 9 - exit Your choice is: 6 (112,3.8) (115, 3.5) (116,2.8) (113, 3.1) (119,3.3) (118,1.9) (122,2.6) (121, 4.0) (117,2.3) Please, choose a number from the following list: 1 - Insert Students 2 - Remove a Student 3 - Check if a Student Exists 42

4 - Print in order 5 - Print preorder 6 - Print postOrder 7 - Height 8 - Number of leaf nodes 9 - exit Your choice is: The height of the tree is: 3 Please, choose a number from the following list: 1 - Insert Students 2 - Remove a Student 3 - Check if a Student Exists 4 - Print inOrder 5 - Print preOrder 6- Print postorder 7 - Height 8 - Number of leaf nodes 9 - exit Your choice is: 8 The number of leaf nodes is: 4 Please, choose a number from the following list: 1 - Insert Students 2 - Remove a Student 3 - Check if a Student Exists 4 - Print inOrder 5 - Print preorder 6 - Print postorder 7 - Height 8 - Number of leaf nodes 9 - exit Your choice is: 9 Exiting the program Process finished with exit code o Additional Exercise: - Add the necessary methods to find and return the highest GPA in the BST. - Add the necessary methods to count and return the number of students whose GPA is greater than 2.67. 43