Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

image text in transcribed

image text in transcribed

image text in transcribed

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

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Fundamentals Of Database Management Systems

Authors: Mark L. Gillenson

3rd Edition

978-1119907466

More Books

Students also viewed these Databases questions