Question: Problem 1 [15 points] : Suppose you are given an array of unique integers A A: a2: . . . , an], such that the
Problem 1 [15 points] : Suppose you are given an array of unique integers A A: a2: . . . , an], such that the values in A increase until reaching a peak value ap (Le', al apti > an). Define (in English or pseudo code) a procedure that finds the ndex of the peak value in A in O(logn) time. Also give a brief explanation of why your procedure is correct and runs in O(log n) time Problem 2 15 points: that a queue is a linear data structure that behaves in a FIFO (first in, first out) manner. In particular, a queue maintains a sequential ordering of the elements contained within the queue and supports the following operations/methods eca ENQUEUE(): Add element to the end of the queue DEQUEUEO: Remove the element at the front of the queue and return it Suppose you are given two stacks Si and S2. Describe how to implement a queue with just St and S2. In particular, you should give a description for how both and ENQUEUEO and DEQUEUE) are implemented. Note that you are not permitted to use any other data structures other than S or S2 in your implementation (an array, a linked list, etc.)
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
