Search an element in sorted and rotated array( Find PIVOT)

  Рет қаралды 28,902

Vivekanand Khyade - Algorithm Every Day

Vivekanand Khyade - Algorithm Every Day

7 жыл бұрын

Search an element in sorted and rotated array. FInd pivot element in sorted and rotated array. Use Binary search to find pivot and then to find the element. O(log n) is the time complexity.
Sorted and Rotated Array :- • ROTATION of an array (...

Пікірлер: 62
@riteshparkhi8582
@riteshparkhi8582 4 жыл бұрын
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.
@ankitranjan88
@ankitranjan88 3 жыл бұрын
Thank you ... you are doing great job for us...smoothly explained even all the smallest term to heighest term...
@fathimasyed4232
@fathimasyed4232 4 жыл бұрын
Thank you so much .. Really helpful .. Slow and steady, so it is understandable even for beginners..Thanks a lot.
@swastikkanjilal2829
@swastikkanjilal2829 4 жыл бұрын
Sir you are great in explaining these concepts!
@akyt7595
@akyt7595 5 жыл бұрын
Great explanation sir. Thank you!
@MargulanTukhfatov
@MargulanTukhfatov 4 жыл бұрын
Please continue posting videos, very good explanation
@munishkumararora6429
@munishkumararora6429 4 жыл бұрын
Great explanation for pivot element. Thanks
@praveenchouhan6388
@praveenchouhan6388 4 жыл бұрын
awesome explaination!!!!!!!!!!!!!!
@karthikk1172
@karthikk1172 4 жыл бұрын
Great Explanation. Never stop making videos.
@duredurrani
@duredurrani 4 жыл бұрын
Nice explanation
@payalsagar1808
@payalsagar1808 4 жыл бұрын
Thankyou Vivek ! great 👌got it
@ManishaKumari-yv3nf
@ManishaKumari-yv3nf 3 жыл бұрын
Thanks😊 for the effort ur putting in. They're very helpful
@mikelee5691
@mikelee5691 7 жыл бұрын
thanks. can you please do serialising/deserialising a string to a binary tree?
@maheswarreddyu
@maheswarreddyu 5 жыл бұрын
will this algorithm work when the array has either 1 or 2 elements?
@amandeepchilani3999
@amandeepchilani3999 5 жыл бұрын
Great Job Vivek..
@priyaranjanPanda93
@priyaranjanPanda93 5 жыл бұрын
Do mention also , how to go about duplicate elements in the array. Nice explanation anyways !!
@RahulKumar-qu1if
@RahulKumar-qu1if 4 жыл бұрын
Thank you sir!
@gayatrijoshi5951
@gayatrijoshi5951 3 жыл бұрын
You are amazing man🙌🙌👏👏
@Dragondavid
@Dragondavid 6 жыл бұрын
You are the best
@helloyou4233
@helloyou4233 6 жыл бұрын
i like your videeeos sir... plz keep making videos
@yuanhe9890
@yuanhe9890 5 жыл бұрын
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
@FactifyFables1234
@FactifyFables1234 4 жыл бұрын
try to give clear description sir
@knightganesh
@knightganesh 6 жыл бұрын
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.
@rahulkhandelwal46578
@rahulkhandelwal46578 6 жыл бұрын
Thanks
@sammanluitel3018
@sammanluitel3018 6 жыл бұрын
. 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
@nidhisingh25_
@nidhisingh25_ 4 жыл бұрын
thank you
@avinashkaushik2313
@avinashkaushik2313 3 жыл бұрын
owsome
@sravankumar4750
@sravankumar4750 6 жыл бұрын
can u make a video on shuffle a deck of cards in array or randomize a given array
@SEVERANCE850
@SEVERANCE850 6 жыл бұрын
implementation of heap
@SunilKumar-cu8wm
@SunilKumar-cu8wm 5 жыл бұрын
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"
@nishantsaxena7500
@nishantsaxena7500 5 жыл бұрын
nahi brother , it is right .. recheck it bro..thoda ghumakar likha h .. par sahi hai..
@payalsagar1808
@payalsagar1808 4 жыл бұрын
@@nishantsaxena7500 I agree with sunil
@isonal2099
@isonal2099 7 жыл бұрын
Vivekanand ji. There is no link in description bar of this video.
@vivekanandkhyade
@vivekanandkhyade 3 жыл бұрын
I will put it.
@Saurabhnaik
@Saurabhnaik 6 жыл бұрын
Thanks a lot for great explanation. Please make a video on removing duplicate elements from Array Thanks in advance...
@lokeshsistu9996
@lokeshsistu9996 3 жыл бұрын
Sir please make videos on timecomplexity
@vikrantkumarsmvdu
@vikrantkumarsmvdu 6 жыл бұрын
Hi Vivekanand, Please upload videos on different sorting algorithms.
@LakshyaK_SE_
@LakshyaK_SE_ 3 жыл бұрын
is this code correct when we have duplicate elements in a array?
@karthikperavelli1735
@karthikperavelli1735 5 жыл бұрын
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 ??
@Shini1984
@Shini1984 4 жыл бұрын
What if arrays contains duplicates?
@dhruvajuloori4361
@dhruvajuloori4361 6 жыл бұрын
Finding an element is nothing but finding a minimum element in the array
@rrsonia10
@rrsonia10 4 жыл бұрын
whats space complexity?
@pankajverma892
@pankajverma892 4 жыл бұрын
Let us assume that m came 8 than algo will not work bro....
@FactifyFables1234
@FactifyFables1234 4 жыл бұрын
sir please include in python language please sir
@bhavyanayyer3391
@bhavyanayyer3391 4 жыл бұрын
sir can u pls provide with a code it will be very grateful
@tyler_ua6593
@tyler_ua6593 6 жыл бұрын
And space complexity is O(n) -> for recursive call stack.
@piyushpatelsrm
@piyushpatelsrm 5 жыл бұрын
boom
@bhavyanayyer3391
@bhavyanayyer3391 3 жыл бұрын
#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
@AshishShukla6
@AshishShukla6 6 жыл бұрын
Good explanation but speed in too slow, many repeatation, 10 to 15 min is sufficient
@tyler_ua6593
@tyler_ua6593 6 жыл бұрын
You can increase the speed of the video. By clicking on the wheel on the right bottom
@harsh4002
@harsh4002 5 жыл бұрын
m = s + (e-s)/2
@SimplyByNP
@SimplyByNP 5 жыл бұрын
Harsh Baheti can you explain why this way is better than (s + e) / 2
@ajay06bce012
@ajay06bce012 4 жыл бұрын
Play at 1.5 times the speed and thank me later!
@adityavashisth495
@adityavashisth495 6 жыл бұрын
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.
@varunrao3349
@varunrao3349 5 жыл бұрын
this isn't a sorted rotated array
@ShujathHussain0
@ShujathHussain0 5 жыл бұрын
take a circular sorted array and play using the algorithm
@lachlangro
@lachlangro 4 жыл бұрын
@@varunrao3349 I agree. It has two pivots. 9 and 1 at indexes 0 and 3 respectively.
@lachlangro
@lachlangro 4 жыл бұрын
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.
@bhaskarnaik5842
@bhaskarnaik5842 2 жыл бұрын
Thanks
Majority Element in an array (Algorithm)
4:12
Vivekanand Khyade - Algorithm Every Day
Рет қаралды 20 М.
Leader in an Array (Code / Algorithm)
15:24
Vivekanand Khyade - Algorithm Every Day
Рет қаралды 20 М.
Эффект Карбонаро и нестандартная коробка
01:00
История одного вокалиста
Рет қаралды 10 МЛН
Получилось у Миланы?😂
00:13
ХАБИБ
Рет қаралды 5 МЛН
Search in rotated sorted array | Leetcode #33
13:52
Techdose
Рет қаралды 83 М.
Lowest common ancestor of two nodes in Binary Tree Algorithm
13:49
Vivekanand Khyade - Algorithm Every Day
Рет қаралды 57 М.
Maximum Sum SubArray (Kadane's algorithm) (Largest Sum Contigous SubArray)
17:30
Vivekanand Khyade - Algorithm Every Day
Рет қаралды 91 М.
Total number of ways to reach to a cell in matrix
8:52
Vivekanand Khyade - Algorithm Every Day
Рет қаралды 24 М.
Subset Sum Problem Dynamic programming
28:54
Vivekanand Khyade - Algorithm Every Day
Рет қаралды 66 М.
BS-6. Minimum in Rotated Sorted Array
17:08
take U forward
Рет қаралды 147 М.
LeetCode 33. Search in Rotated Sorted Array
9:30
Nick White
Рет қаралды 97 М.
Remove Duplicates from sorted Array
21:22
Vivekanand Khyade - Algorithm Every Day
Рет қаралды 168 М.
BS-4. Search Element in Rotated Sorted Array - I
16:38
take U forward
Рет қаралды 223 М.
Эффект Карбонаро и нестандартная коробка
01:00
История одного вокалиста
Рет қаралды 10 МЛН