Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

image text in transcribed

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

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

PostgreSQL Up And Running A Practical Guide To The Advanced Open Source Database

Authors: Regina Obe, Leo Hsu

3rd Edition

1491963417, 978-1491963418

More Books

Students also viewed these Databases questions

Question

What are the types of contract? Explain them in brief. AppendixLO1

Answered: 1 week ago

Question

8. Managers are not trained to be innovation leaders.

Answered: 1 week ago