1. Engineering
  2. Computer Science
  3. problem 1 15 points suppose you are given an...

Question: problem 1 15 points suppose you are given an...

Question details

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 < a2 < < ap) and then decrease thereafter .e., ap>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.)
Solution by an expert tutor
Blurred Solution
This question has been solved
Subscribe to see this solution