Great video. One very important point I realized that for finding mid we should use start + (end -start)/2 instead of (start + end)/2. This will help to handle int overflow error when array is big.
. Given a binary string (e.g. 01, 101, 011), in each iteration 0 becomes 01 and 1 becomes 10, find kth character in the string after nth iteration simple approach, time complexity, express time complexity in terms of n only efficient approach, explanation, time complexity. can u please make a video to solve this problem
Hi the video is awesome and super easy to understand, keep it going. Small suggestion : - But kindly record with a better mic as there seems to be lot of noise in the background.
#include using namespace std; int findindex(int s ,int e,int arr[]) { int m = s+e/2; if(arr[m]>arr[m+1]) { int pivot; pivot=m+1; return pivot; } else if (arr[s]>arr[m]) { findindex(s,m-1,arr); } else { findindex(m+1,e,arr); } } int binarysearch(int s , int e ,int arr[], int ele) { int mid = (s + e)/2; while (s
wrong approach: cant solve even simple test cases. Suppose if my array is: 9,12,15,1,2,38,40,42,22,45,50,55. Now according to your algorithm mid index is 5 here and arr[s]=9 < arr[m]=38 , so according to your algo it will move to else part and search for PIVOT after 38. But PIVOT is arr[4] which is before 38. So wrong approach.
His algorithm is not foolproof as is. It should first check the start element against the end element to detect whether the array is simply a sorted array with no rotations. It can also fail in situations where duplicates exist such as: 5, 1, 3, 5, 5, 5, 5, 5, 5, 5, 5. keep in mind that i could have placed the 1, 3 in either half of the array. In cases like this linear search may have to be used.
Great video. One very important point I realized that for finding mid we should use start + (end -start)/2 instead of (start + end)/2. This will help to handle int overflow error when array is big.
Thank you ... you are doing great job for us...smoothly explained even all the smallest term to heighest term...
Please continue posting videos, very good explanation
Thank you so much .. Really helpful .. Slow and steady, so it is understandable even for beginners..Thanks a lot.
Sir you are great in explaining these concepts!
Thanks😊 for the effort ur putting in. They're very helpful
awesome explaination!!!!!!!!!!!!!!
Great explanation for pivot element. Thanks
Great Explanation. Never stop making videos.
Thankyou Vivek !
great 👌got it
Nice explanation
Great explanation sir. Thank you!
You are amazing man🙌🙌👏👏
Do mention also , how to go about duplicate elements in the array. Nice explanation anyways !!
Hi Vivekananda, please change the condition where a[s] > a[mid] here it should be a[s] < a[mid] to select the portion from "s" to "m-1"
nahi brother , it is right .. recheck it bro..thoda ghumakar likha h .. par sahi hai..
@@nishantsaxena7500 I agree with sunil
Thank you sir!
thanks. can you please do serialising/deserialising a string to a binary tree?
will this algorithm work when the array has either 1 or 2 elements?
Sir please make videos on timecomplexity
i like your videeeos sir... plz keep making videos
try to give clear description sir
Great Job Vivek..
thank you
You are the best
Thanks, I've always looked at ur utube explanations. They are great and saved me a lot of effort. But please have a better mic LOLOL
. Given a binary string (e.g. 01, 101, 011), in each iteration 0 becomes 01 and 1 becomes 10, find kth character in the string after nth iteration
simple approach, time complexity, express time complexity in terms of n only
efficient approach, explanation, time complexity. can u please make a video to solve this problem
is this code correct when we have duplicate elements in a array?
Thanks a lot for great explanation.
Please make a video on removing duplicate elements from Array
Thanks in advance...
owsome
can u make a video on shuffle a deck of cards in array or randomize a given array
implementation of heap
Thanks
Hi the video is awesome and super easy to understand, keep it going.
Small suggestion : -
But kindly record with a better mic as there seems to be lot of noise in the background.
What if arrays contains duplicates?
A[]={16,15,14,13,12,11,10,8,7,6,3,2}; what if i pass this extreme case, it returns (m+1), while ans is 11 ??
Vivekanand ji. There is no link in description bar of this video.
I will put it.
sir please include in python language please sir
whats space complexity?
sir can u pls provide with a code it will be very grateful
Hi Vivekanand,
Please upload videos on different sorting algorithms.
Let us assume that m came 8 than algo will not work bro....
#include
using namespace std;
int findindex(int s ,int e,int arr[])
{
int m = s+e/2;
if(arr[m]>arr[m+1])
{
int pivot;
pivot=m+1;
return pivot;
}
else if (arr[s]>arr[m])
{
findindex(s,m-1,arr);
}
else
{
findindex(m+1,e,arr);
}
}
int binarysearch(int s , int e ,int arr[], int ele)
{ int mid = (s + e)/2;
while (s
Finding an element is nothing but finding a minimum element in the array
And space complexity is O(n) -> for recursive call stack.
boom
Good explanation but speed in too slow, many repeatation, 10 to 15 min is sufficient
You can increase the speed of the video. By clicking on the wheel on the right bottom
m = s + (e-s)/2
Harsh Baheti can you explain why this way is better than (s + e) / 2
Play at 1.5 times the speed and thank me later!
wrong approach: cant solve even simple test cases. Suppose if my array is: 9,12,15,1,2,38,40,42,22,45,50,55.
Now according to your algorithm mid index is 5 here and arr[s]=9 < arr[m]=38 , so according to your algo it will move to else part and search for PIVOT after 38. But PIVOT is arr[4] which is before 38. So wrong approach.
this isn't a sorted rotated array
take a circular sorted array and play using the algorithm
@@varunrao3349 I agree.
It has two pivots. 9 and 1 at indexes 0 and 3 respectively.
His algorithm is not foolproof as is.
It should first check the start element against the end element to detect whether the array is simply a sorted array with no rotations.
It can also fail in situations where duplicates exist such as: 5, 1, 3, 5, 5, 5, 5, 5, 5, 5, 5. keep in mind that i could have placed the 1, 3 in either half of the array.
In cases like this linear search may have to be used.
Thanks