Please read the new rule regarding the restriction on the use of AI tools. ×

generally found binary search pattern for ( beginner )

Revision en1, by viraj777, 2022-10-08 15:41:29

One mandatory requirement to apply binary search is our searching space should be in sorted range . Otherwise there is no meaning of this algorithm.

One type of question in that given array or any data structure is in sorted manner or we have to sort it , But in sort searching space is given , in this only one function will be needed

Second and most famous method is in that we have to make our own search space, our answer will be lie in that range , so in that range apply binary search , check that whether this answer satisfied conditions or not , Now if condition satisfied , then there two choice to go left or right , this depends on que , If it asks for minimum then go for left and otherwise go for right side .

You can find this type of pattern in leetcode , here I have attached one codeforces link of this type question :

https://codeforces.me/problemset/problem/1119/B https://codeforces.me/problemset/problem/279/B

Tags binary search

History

 
 
 
 
Revisions
 
 
  Rev. Lang. By When Δ Comment
en2 English viraj777 2022-10-08 15:49:19 13
en1 English viraj777 2022-10-08 15:41:29 1117 Initial revision (published)