Mudit88 / hacktoberfest_2022-Repo_for_Newbie

This Repo is for Newbie who wants to start their journey in open source. Make sure not to make multiple pull requests otherwise will be identified as spammy .
10 stars 19 forks source link

Binary Search in Cpp #17

Closed AnkitMajee closed 2 years ago

AnkitMajee commented 2 years ago

Binary Search to find element is an array .

array=[10,12,20,21,27,34,54] Key=27 It finds the middle element and compare greater or less than key element if less start moves to element after 21 now find the middle element again and compare greater of less than key element if greater we get thekey value 27
Binary search reduces the searching process initially the array was of N size than N/2 , N/4 ,N/16.............,N/k^2

Time Complexity :- O(log2n)

Mudit88 commented 2 years ago

Good work ! Merged