Question: General Algorithm Questions The Following three questions are sample interview questions for programmers, students should probably know how to answer them Write an ALGORITHM (not

 General Algorithm Questions The Following three questions are sample interview questions

General Algorithm Questions The Following three questions are sample interview questions for programmers, students should probably know how to answer them Write an ALGORITHM (not a program) that, given an array al] of N distinct integers, finds a local maximum: an index i such that ali-1] ali 1]. Your Algorithm should use "2lg N compares in the worst case (this is a binary search variant). How would you change this algorithm to account for plateaus' (e.g. (1,2,3,4,5,5,5,5,5,5,4,3,21? 3. 4. Given an integer x and an unsorted array of integers, describe an algorithm to determine whether two of the numbers add up to x. Consider the same question but now where the array is sorted (does this change your answer? How?). Develop an algorithm for a given array that will find the all possible sub arrays with a sum less than some input value K. Strictly speaking a sub array can contain only 1 element, but we're interested in sub arrays of more than one element. E.g. given an array [1, 2, 3, 4, 5,6, 7, 8,9, 10) and an input K-6, sub arrays 11,21, (2,3) are both less than 6. If K 7 (1,2,3] now becomes a valid sub array as well. You can write a program for this or just describe the algorithm. 5

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!