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

Поделиться
HTML-код
  • Опубликовано: 8 ноя 2024

Комментарии • 62

  • @riteshparkhi8582
    @riteshparkhi8582 4 года назад +5

    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 года назад +1

    Thank you ... you are doing great job for us...smoothly explained even all the smallest term to heighest term...

  • @MargulanTukhfatov
    @MargulanTukhfatov 4 года назад +1

    Please continue posting videos, very good explanation

  • @fathimasyed4232
    @fathimasyed4232 4 года назад +1

    Thank you so much .. Really helpful .. Slow and steady, so it is understandable even for beginners..Thanks a lot.

  • @swastikkanjilal2829
    @swastikkanjilal2829 4 года назад +2

    Sir you are great in explaining these concepts!

  • @ManishaKumari-yv3nf
    @ManishaKumari-yv3nf 4 года назад +1

    Thanks😊 for the effort ur putting in. They're very helpful

  • @praveenchouhan6388
    @praveenchouhan6388 4 года назад +1

    awesome explaination!!!!!!!!!!!!!!

  • @munishkumararora6429
    @munishkumararora6429 5 лет назад +1

    Great explanation for pivot element. Thanks

  • @karthikk1172
    @karthikk1172 5 лет назад +1

    Great Explanation. Never stop making videos.

  • @payalsagar1808
    @payalsagar1808 4 года назад +1

    Thankyou Vivek !
    great 👌got it

  • @duredurrani
    @duredurrani 4 года назад

    Nice explanation

  • @akyt7595
    @akyt7595 5 лет назад +2

    Great explanation sir. Thank you!

  • @gayatrijoshi5951
    @gayatrijoshi5951 4 года назад

    You are amazing man🙌🙌👏👏

  • @priyaranjanPanda93
    @priyaranjanPanda93 5 лет назад +2

    Do mention also , how to go about duplicate elements in the array. Nice explanation anyways !!

  • @SunilKumar-cu8wm
    @SunilKumar-cu8wm 5 лет назад +1

    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

  • @RahulKumar-qu1if
    @RahulKumar-qu1if 4 года назад +1

    Thank you sir!

  • @mikelee5691
    @mikelee5691 7 лет назад +3

    thanks. can you please do serialising/deserialising a string to a binary tree?

  • @maheswarreddyu
    @maheswarreddyu 6 лет назад +1

    will this algorithm work when the array has either 1 or 2 elements?

  • @lokeshsistu9996
    @lokeshsistu9996 3 года назад

    Sir please make videos on timecomplexity

  • @helloyou4233
    @helloyou4233 6 лет назад

    i like your videeeos sir... plz keep making videos

  • @FactifyFables1234
    @FactifyFables1234 4 года назад +1

    try to give clear description sir

  • @amandeepchilani3999
    @amandeepchilani3999 5 лет назад

    Great Job Vivek..

  • @nidhisingh25_
    @nidhisingh25_ 4 года назад

    thank you

  • @Dragondavid
    @Dragondavid 6 лет назад

    You are the best

  • @yuanhe9890
    @yuanhe9890 6 лет назад

    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

  • @sammanluitel3018
    @sammanluitel3018 7 лет назад

    . 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

  • @LakshyaK_SE_
    @LakshyaK_SE_ 3 года назад

    is this code correct when we have duplicate elements in a array?

  • @Saurabhnaik
    @Saurabhnaik 7 лет назад

    Thanks a lot for great explanation.
    Please make a video on removing duplicate elements from Array
    Thanks in advance...

  • @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 7 лет назад +1

    implementation of heap

  • @rahulkhandelwal46578
    @rahulkhandelwal46578 6 лет назад

    Thanks

  • @knightganesh
    @knightganesh 7 лет назад +1

    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.

  • @Shini1984
    @Shini1984 4 года назад

    What if arrays contains duplicates?

  • @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 ??

  • @isonal2099
    @isonal2099 7 лет назад +1

    Vivekanand ji. There is no link in description bar of this video.

  • @FactifyFables1234
    @FactifyFables1234 4 года назад

    sir please include in python language please sir

  • @rrsonia10
    @rrsonia10 5 лет назад

    whats space complexity?

  • @bhavyanayyer3391
    @bhavyanayyer3391 4 года назад

    sir can u pls provide with a code it will be very grateful

  • @vikrantkumarsmvdu
    @vikrantkumarsmvdu 6 лет назад

    Hi Vivekanand,
    Please upload videos on different sorting algorithms.

  • @pankajverma892
    @pankajverma892 4 года назад

    Let us assume that m came 8 than algo will not work bro....

  • @bhavyanayyer3391
    @bhavyanayyer3391 4 года назад

    #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

  • @dhruvajuloori4361
    @dhruvajuloori4361 6 лет назад

    Finding an element is nothing but finding a minimum element in the array

  • @tyler_ua6593
    @tyler_ua6593 6 лет назад

    And space complexity is O(n) -> for recursive call stack.

  • @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 лет назад +1

    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 лет назад +2

      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