Binary Search
@ Sabbir · Wednesday, Jun 3, 2020 · 1 minute read · Update at Jun 3, 2020

📌 CODE-LIBRARY:

  //  author:  MSA
int BinarySearch(int a[],int n,int target)
{
	int low=0, high =n-1;
	while(low<=high)
	{
		int mid=low+(high-low)/2;  // best formula to ignore overflow

		if(target==a[mid]) return mid; //mid element is the ans

		else if(a[mid]<target)    low=mid+1; //moving to right side

		else   high=mid-1; // moving to left side
	}
	return -1;  //no value found
}

📌 VIDEO-TUTORIALS :

1. mycodeschool

2. Errichto

3. AfterAcademy

4. Nick White

📌 PDF-TUTORIALS :

1. Binary Search »»»»»👨‍💻 I_Love_Equinox

📌 SCREENSHOT-BREAKDOWN :

1. Iterative Binary Search - [Method -01]::

source: mycodeschool


mid=(low+high)/2

bin1

2. Iterative Binary Search - [Method -02]::


mid=low+(high-low)/2

source: mycodeschool

bin2

source: Errichto

bin12

source: mycodeschool


bin3

source: mycodeschool


if(x==A[mid])
{
  result=mid;
  high=mid-1;
}

bin4

source: mycodeschool


if(x==A[mid])
{
  result=mid;
  low=mid+1;
}

bin5

source: mycodeschool


//array is sorted so at the beginning  find  the first and last element then
(last element-first element)+1

2 3

7. Rotated Sorted Array


source: AfterAcademy

bin14

source: Nick White

bin13

algo
Save as image

About Me

Hello there , i am Sabbir.

2nd year undergraduate student at University of Asia Pacific

[i will write remaining parts later , brain is not working now !]

– Last Updated 01 June 2020

SKILLS

PROGRAMMING LANGUAGE SKILLS:

LANGUAGE Proficiency
C 60%
Java 35%
Python 50%
C++ 40%

OTHERS:

Topic Proficiency
Git 50%
Filmora 70%
Markdown 40%

Achievements

অনেক খুঁজছি , কিছুই পাই নাই , পুরা জীবনটাই বৃথা