The world’s Largest Sharp Brain Virtual Experts Marketplace Just a click Away
Levels Tought:
Elementary,Middle School,High School,College,University,PHD
| Teaching Since: | Jul 2017 |
| Last Sign in: | 304 Weeks Ago, 3 Days Ago |
| Questions Answered: | 15833 |
| Tutorials Posted: | 15827 |
MBA,PHD, Juris Doctor
Strayer,Devery,Harvard University
Mar-1995 - Mar-2002
Manager Planning
WalMart
Mar-2001 - Feb-2009
java
Please write clearly and use extra sheets of paper as needed.
Scans or good quality pictures of handwritten solutions are absolutely fine.
1- We are performing the following operations on the ADTs below. Show the value returned by the peek and remove operations in the a/b/c/d blank slots below for each of the ADTs.
Add 20, 7, 5, 8
Remove (a) Add 10, 14
Peek (b) Add 9
Remove (c) Add 3, 11
Peek (d) FIFO Queue
Remove (a) ________ Peek (b) _________ Remove (c) ________ Peek (d) _________
Stack
Remove (a) ________ Peek (b) _________ Remove (c) ________ Peek (d) _________
Min Priority Queue
Remove (a) ________ Peek (b) _________ Remove (c) ________ Peek (d) _________
Max Priority Queue
Remove (a) ________ Peek (b) _________ Remove (c) ________ Peek (d) _________
2- We are performing the following operations on a Deque implemented using an array. The initial capacity of the array is 5 ( _ _ _ _ _ )and the array doubles whenever the deque reaches its capacity. Please show the physical state (draw the array cells) of the array after each of the operations. For the array elements with “junk” values, leave any existing value in the array but cross it out. Show next to the array the values of the lo and hi indices. First one has been done to get you started.
a)pushFrontC b) pushFrontA c) pushBack Z d) popFront
e) pushBack U f) pushFront K g) popBack
h) pushBack J i) pushFront H j) pushBack P k) popFront
C____
lo=0 hi= 0
3 - Draw the max heap (in tree form) that results from the following values added to the heap one by one in the given order. Show the steps.
135274869
4 - Starting from the min heap obtained by inserting the values below in the order given (do not show the insert steps, just the final tree after all inserts. Do you notice some nice property this list of values has?), show the heap that results after performing 3 removes. Give the state of the tree after each remove.
132597468
----------- He-----------llo----------- Si-----------r/M-----------ada-----------m ----------- ----------- Th-----------ank----------- yo-----------u f-----------or -----------you-----------r i-----------nte-----------res-----------t a-----------nd -----------buy-----------ing----------- my----------- po-----------ste-----------d s-----------olu-----------tio-----------n. -----------Ple-----------ase----------- pi-----------ng -----------me -----------on -----------cha-----------t I----------- am----------- on-----------lin-----------e o-----------r i-----------nbo-----------x m-----------e a----------- me-----------ssa-----------ge -----------I w-----------ill----------- be-----------