8.2 Searching in Arrays | Linear and Binary Search | C++ Placement Course |

preview_player
Показать описание
Notes of this video will be uploaded in a short while :)
Рекомендации по теме
Комментарии
Автор

0:49 linear search
3:30 binary concept
8:00 binary code

severemage
Автор

Addition : : Binary Search applicable only when the given array is sorted. If not, we first need to sort the array and then find the element using the binary search function.

couldbenimish
Автор

This approach of problem solving is called
"divide and conquer". As we are dividing our array into halves.

Another examples of D&C :
- finding GCM ( greatest common divisor )
- merge sort and quick sort algorithms

binary search will only work if array is sorted. This should be in mind.

The same example of the video can be easily written by Recursion.

binarySearch(int arr[], int item, int l, int r)
{
int n = sizeof(arr)/sizeof(arr[0]);
int m = (l+r)/2;
if (m < 0 || m> n-1){ return -1; }
if (arr[m] == item){ return item; }
else if(arr[m] > item) {
return binarySearch(arr, item, l, m-1);
}
else{
return binarySearch(arr, item, m+1, r);
}

return -1;
}

rutvikrana
Автор

8:52 the value of e = n-1, because the indexing starts from 0.

devilhunter
Автор

your teaching style is quite good and i want notes of this lecture. i saw previous request for notes But you didn't upload on this video.
kindly upload the notes as soon as possible its my humble request to you. Keep Growing.

sagarrajkumargupta
Автор

These guys are just amazing.And they were doing such a great work.
They were giving a very quality education for free.
Please guys support them all.🙏🙏🙏

kiranp
Автор

Everyone is first until you refresh 😂🔥

bengaltiger
Автор

I think you all will hate me after this comment but
1.Everyone in comment section:
This guy will ruin this system
The world ia going to change

But no one have any doubt 🙄
I had too many doubts and i commented in videos but that comment got ignored and this 🔥 appreciation only getting likes

rsh
Автор

Well done bhaiya
We love you and always support you

sanketkumar
Автор

After k iteration, length of array=n/2^k-1
As
In 1st iteration length =n/2^0
In 2nd iteration length =n/2^1
So
In k iteration length =n/2^k-1
It is simple gm series

rajgupta
Автор

Notes -
Linear Search - {Time Complexity - O(n)} - 0:49
Binary Search - Concept - 3:30
Binary Search - Code - 8:00
Binary Search - Time Complexity - O(logn base 2) - 11:32

shreyaschavhan
Автор

There is mistake in finding time complexity of binary search. After 1s iteration our array size has reduced to half but in video they took full size of array .

This is the correct form of solution

Time complexity:
After 1st iteration, lenght of array = n/2
After 2nd iteration, lenght of array = n/4
After 3rd iteration, lenght of array = n/8
After 4th iteration, lenght of array = n/16
After kth iteration, lenght of array = n/(2)^k

Let length of array becomes 1 after kth iteration
n/(2)^k = 1
n= 2^k
log2(n) = k log2(2)
k = log2(n)
Time complexity = log2(n)

abdurrehmanali
Автор

Explaining Binary search complexity is awesome. I like it

kpsaini
Автор

Mam you are really god for us, likes poor and middle class background students
Your technique of teaching is just amazing
your video makes easy to understand any topics...tqqqq my fav mam

Csharpian.
Автор

Shraddha mam speaking so sweetly..😂 ... I am watching this video on 31/03/2024 ...❤

hqoyuyn
Автор

whenever mam say 'thik hai' i feel very good

astatosiseverywhere
Автор

one thing i want to add:
mere jese slow learner ko jab koi kuch concept samjhaye or fir programme likhne k baad usi chiz ko dubara samjhaye pura
no words for this
thank you so much

amanjaiswal
Автор

Binary Search works in sorted array only.
We have to sort the array first in ascending or descending order if the array entered in unsorted .
Linear Search is better for unsorted array

-shashankgupta
Автор

Why use binary search??

Simple answer:
If n will become very large then simple search will take hours to find element, but same with binarysearch becomes log(n) ( aka in seconds ... ) 👌

rutvikrana
Автор

Didi afer kth iteration shouldn't it be n/(2^k-1)

excalibur