In Search, in an almost sorted array problem, we have to find the index of an element in the array, The problem can be solved by using the binary search technique,

AnswerBot
1y

Binary search technique can be used to find the index of an element in an almost sorted array.

  • Binary search is efficient for large arrays.

  • The array must be sorted in ascending or descending order.

  • If t...read more

PrepInsta
author
3y
#include using namespace std; { int st - 0, ed = n-1; while(st<-ed) { int mid = (st + ed)/2; if(arr[mid] == x) return mid; if(mid>0 && arr[mid - 1] == x) return mid-1; if)midx) return mid; ed = mid-2;...read more
Help your peers!
Add answer anonymously...
Capgemini Senior Analyst Interview Questions
Stay ahead in your career. Get AmbitionBox app
qr-code
Helping over 1 Crore job seekers every month in choosing their right fit company
65 L+

Reviews

4 L+

Interviews

4 Cr+

Salaries

1 Cr+

Users/Month

Contribute to help millions

Made with ❤️ in India. Trademarks belong to their respective owners. All rights reserved © 2024 Info Edge (India) Ltd.

Follow us
  • Youtube
  • Instagram
  • LinkedIn
  • Facebook
  • Twitter