# H2-ie514 - IE 514 HOMEWORK#2 DUE Question 1 Suppose C is an array of n integers with the following property Its elements are first strictly

This preview shows pages 1–2. Sign up to view the full content.

IE 514 HOMEWORK #2 DUE: February 26, 2010 Question 1) Suppose C is an array of n integers with the following property: Its elements are first strictly increasing and after reaching a maximum value, they are strictly decreasing. In other words, for some index j, 0 ≤ j ≤ n-1, the array C is strictly increasing up to element C[j], that is, C[0] < C[1] < . .. C[j] and is strictly decreasing after that, meaning C[j] > C[j+1] > . .. > C[n-1]. Write an algorithm (in pseudo-code form) which is not “recursive” and which takes as input such an array and returns the maximum element in it. The algorithm should run in O(logn) time. Hint: Remember binary search algorithm. ----- Let A be an array of integers. We say that A is bitonic if the elements of A are first strictly increasing and after reaching a maximum value, they are strictly decreasing. More precisely, suppose that A has n elements. Then for some index j , 0 ≤ j n -1, the array A is strictly increasing up to element A[j] , that is, A[0] < A[1] < . .. A[j] and is strictly decreasing after that, meaning A[j] > A[j+1] > . .. > A[n-1]. Note that j could be 0 or n -1. Write a non-recursive java function called findMax that takes a bitonic integer array of size n and returns the maximum element. The function header should

This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document
This is the end of the preview. Sign up to access the rest of the document.

## This note was uploaded on 04/15/2010 for the course INDUSTRIAL ie513 taught by Professor Zeynephuygur during the Spring '10 term at Bilkent University.

### Page1 / 4

H2-ie514 - IE 514 HOMEWORK#2 DUE Question 1 Suppose C is an array of n integers with the following property Its elements are first strictly

This preview shows document pages 1 - 2. Sign up to view the full document.

View Full Document
Ask a homework question - tutors are online