Posts

Showing posts from August, 2015

Java program to check if an array is bitonic

This blog post is about a java program to check whether an array is bitonic or not. Introduction A bitonic array for this program is defined as an array of length 'N" and for an index 'K' in this array, where 0<K<N-1, the sequence from 0 to K should be increasing order and from K to N-1 should be in decreasing order. Eg: {1,5,3}, {1,2,3,10,9,8} Solution From starting position, find the element K , upto which the sequence is in increasing order. Check whether the sequence is in decreasing order from K to last element in the array. If not return false. Return true after execution of the method. Program package techjourney.programs; /** * Created by Sujith Mohan on 7/20/2015. * This java program is for checking whether a given array is bitonic or not. * A bitonic array for this program is defined as an array of length 'N' and * for an index 'K' in this array, where 0<K<N-1, the sequence from 0 to K should be * incre