Fundamentals of Data Structures

Problem 1: [15%] ( [GTG] Exercise R-8.11, page 350 )
Draw an arithmetic expression tree that has four external nodes, storing the 
numbers 1, 5, 6, and 7 (with each number stored in a distinct external node, 
but not necessarily in this order), and has three internal nodes, each storing 
an operator from the set { +, –, *, / }, so that the value of the root is 21. 
Any of these operators may be used more than once, and they are real (not 
integer) operators, i.e., they may operate on and return fractions.
Problem 2: [35%] ( [GTG] Exercise C-8.57, page 355 )
Let � be a given binary tree with � nodes. The distance between two nodes 
� and � in � is the number of edges along the unique simple path between 
� and �, i.e., ��+ �� – 2��, where � is the lowest common ancestor (LCA) 
of � and �, and �� denotes the depth of node � in �. The diameter of � is 
the maximum distance between two nodes in � (i.e., the distance between 
the farthest pair of nodes in �). Give an efficient algorithm for computing 
the diameter of � and analyze its running time. 
Problem 3: [20%] ( [GTG] Exercise C-9.38, page 398 )
Tamarindo Airlines wants to give a first-class upgrade coupon to the top log �
of their frequent flyers, based on the number of miles accumulated, where 
� is the number of the airlines’ frequent flyers. The algorithm they currently 
use, which runs in �(� log �) time, sorts the flyers by the number of miles 
flown and then scans the sorted list to pick the top log � flyers. 
They have hired you as their chief software engineer.
Give an algorithm that identifies the top log � flyers in �(�) time.
Problem 4: [30%] Dynamic Median Finder (DMF):
We want to design a DMF ADT that maintains a collection of comparable 
elements and supports the following operations on the collection: 
• insert(e): inserts a given element � in �(log �) time,
• getMed(): returns the median in �(1) time, 
• removeMed(): removes and returns the median in �(log �) time, 
where � denotes the current number of elements in the collection.
Give an implementation of the DMF ADT using two heaps as the only 
instance variables.


High quality administrations being provided by assignmenthelp4me make it one of the highest rated online task help websites.

ORDER NOW is online assignment assistance Provider Company with a difference. As we are in this field for several years, we have matured our processes over the period of time, to ensure delivery of high quality assignments with consistency. Our success in touching high quality levels and positive feedback from the customers has given us confidence to expand ourselves into new geographies. As a result, we have been innovative and creative in getting clients’ delight and establishing good customer relationship.