Skip to main content

Command Palette

Search for a command to run...

Mountain Array

Published
•1 min read•View as Markdown

An array of numbers is considered a mountain array if numbers increase up till one point, then decreases till the end.

it is also called BITONIC ARRAY.

whenever you encounter such questions and asks you to find peak , always note:

1.check if you are in the ascending or descending part of the array.

2.after verifying make the changes accordingly .

here below are the cases that finds peak in the mountan array using binary search.

case 1. if you are in decreasing part

arr[mid]>arr[mid+1]

check LHS// END=MID;

case 2. if you are in INCREASING part

arr[mid]<arr[mid+1]

check RHS// START=MID+1;

LOOP BREAK CONDITION: (START==END)

R

Hello everyone,

I hope you're all doing well. I recently launched an open-source project called the Ultimate JavaScript Project, and I'd love your support. Please check it out and give it a star on GitHub: Ultimate JavaScript Project. Your support would mean a lot to me and greatly help in the project's growth.

Thank you!