Question: Data Structure Design As we have seen in the lectures, priority queues can be implemented with a variety of underlying data structures. This question involves

 Data Structure Design As we have seen in the lectures, priority

Data Structure Design As we have seen in the lectures, priority queues can be implemented with a variety of underlying data structures. This question involves implementing the operations of a priority queue (INSERT and REMOVEMIN) using a particularly odd choice for the underlying data structure: a pair of stacks. For this question, the only operations you are permitted to use on the stacks are PUSH and POP. Your pseudocode may use any (constant) number of local variables, but no arrays or other O(n) storage structures are permitted except the two stacks. (a) Give pseudocode for the INSERT and REMOVEMIN operations using only two stacks S_1 and S_2 to store the underlying elements, such that the INSERT operation requires CircleMinus(1) time. You may assume that the PUSH and POP operations of the stacks are CircleMinus(1) in the worst case. Give a Big-Theta expression for the asymptotic worst case running time of the REMOVEMIN operation. (b) Give pseudocode for the INSERT and REMOVEMIN operations using only two stacks S_1 and S_2 to store the underlying elements, such that the REMOVEMIN operation requires CircleMinus(1) time. You may assume that the PUSH and POP operations of the stacks are CircleMinus(1) in the worst case. Give a Big-Theta expression for the asymptotic worst case running time of the INSERT operation

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!