Question: QUESTION 7 a) Given an arithmetic expression as follows: E * F * (G + H) / (J - K) i. Draw the expression tree

 QUESTION 7 a) Given an arithmetic expression as follows: E *

F * (G + H) / (J - K) i. Draw the

expression tree of the given arithmetic expression. (3 marks) ii. Traverse the

QUESTION 7 a) Given an arithmetic expression as follows: E * F * (G + H) / (J - K) i. Draw the expression tree of the given arithmetic expression. (3 marks) ii. Traverse the tree using preorder traversal. (2 marks) iii. Traverse the tree using postorder traversal. (2 marks) iv. What are the ancestors of the tree node 'J'? (2 marks) v. What is the height of the tree drawn in question (i) above? (1 mark) b) Given the ADTs of Bus, TreeNode, and BSTBus: public class Bus { private int busID; private String route; private int seatCapacity; private String plateNo; public Bus (...) (...) //Constructor public String toString() {...} public String getRoute() {...} public int getSeat Capacity () {...} /*** Definition of the other methods ***/ } public class TreeNode { Bus data; TreeNode left, right; /*** Definition of the other methods ***/ } public class BSTBus { TreeNode root; public BSTBus() {...} //Constructor public int countByRoute (String str) (...) public void displayMiniBus() {...} /*** Definition of the ther methods ***/ 40 40 i. Using the Bus ID as the key value, draw a Binary Search Tree diagram that stored the data from the following table: Bus ID Route Seat Plate From Capacity Number 10 UITM Shopping Mall WPA123 3 Hospital UITM 20 WAK567 21 Shopping Mall Airport 20 PNN765 12 LRT Station Airport MAR8421 (2 marks) ii. Write the definition of countByRoute (String) method and its recursive method to count and return the number of buses that travel to the destination specified by a parameter. (8 marks) iii. Write the definition of displayMiniBus () method and its recursive method to display the information of all busses that have 20 seats

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!