Sort an Array in WAVE form

Поділитися
Вставка
  • Опубліковано 8 січ 2025

КОМЕНТАРІ • 25

  • @priyanshu.tiwari
    @priyanshu.tiwari 4 роки тому +4

    Code fails at
    [1,2,2,1,2,1,1,1,1,2,2,2]

  • @techepathy
    @techepathy 2 роки тому

    Explaining beautifully!

  • @rvsagarch
    @rvsagarch 3 роки тому

    This algorithm doesn't work for [5,3,12,7,6,10,2,9,8]. It results [3,5,7,12,6,10,2,9,8] which is not a wave (first 4 are increasing only).

  • @arpitamishra6259
    @arpitamishra6259 6 років тому +1

    nice explanation sir
    could you pls upload upload a video explaining diff between ZigZag array and wave array by giving an example

  • @dipanjanbera5493
    @dipanjanbera5493 3 роки тому

    easiest way explained.....nice

  • @jaikrishnan4249
    @jaikrishnan4249 7 років тому

    Whats the difference between zig zag array and sort in wave form.. I thought array elements at last will be in sorted form..

    • @vivekanandkhyade
      @vivekanandkhyade  7 років тому +3

      For zig zag , a[i-1] < a[i] > a[i+1]
      For wave , a[i-1] = a[i+1]
      Hi Thanks for the feedback , i will edit the video and mention the difference..

    • @Whaleshamu
      @Whaleshamu 6 років тому

      it is not working for following input - [1,2,2,1,2,1,1,1,1,2,2,2]. Expected output - [1,2,1,2,1,2,1,2,1,2,1,2]

    • @priyanshu.tiwari
      @priyanshu.tiwari 4 роки тому

      @@Whaleshamu Leetcode example

  • @anmoljain5910
    @anmoljain5910 4 роки тому +1

    Wrong algorithm. Fails for duplicate elements in the array.

    • @Crazy-is3yx
      @Crazy-is3yx 3 роки тому

      It is correct but only for distinct integer

  • @NS-ef5yu
    @NS-ef5yu 7 років тому

    Could you please upload a video on how to find the maximum sum path of a binary tree?
    Here is the full question:
    Given a binary tree consisting of nodes with positive integer values, write a method that returns the maximum sum of data values obtained by traversing nodes along a path between any 2 nodes of the tree. The path must originate and terminate at 2 different nodes of the tree, and the maximum sum is obtained by summing all the data values of the nodes traversed along this path.

    • @vivekanandkhyade
      @vivekanandkhyade  7 років тому

      sure I will upload the video on this question...

  • @mohnishsatidasani7552
    @mohnishsatidasani7552 4 роки тому

    This is for unequal elements onyl

  • @pujachakraborty8625
    @pujachakraborty8625 7 років тому +1

    suppose there are 3 or more identical elements in the array subsequently, then how the array can be converted into wave form? I think this algorithm will not work out in that situation.
    Suppose the array is
    2 5 5 5 6 1 3
    can this be converted into wave form using this algorithm?

    • @vivekanandkhyade
      @vivekanandkhyade  7 років тому +5

      If you find the identical elements , then do nothing and go to next iteration........
      And actually if you consider the wave condition , the identical elements make the wave longer....like one long wave in ocean .........and again the waves get back to normal as lesser and greater...

    • @pujachakraborty8625
      @pujachakraborty8625 7 років тому

      thank you for the clarification

  • @anuragrai7142
    @anuragrai7142 6 років тому

    nice sir amazing video

  • @learnwithmanu5655
    @learnwithmanu5655 7 років тому

    sir please bfs and dfs ki implementation ki video dal dijiye sir .and n queen ki implementation bhi sir .execellent way of explaning in simple manner.

  • @zeeshantanveer979
    @zeeshantanveer979 2 роки тому

    Sir wave sort is awiggle sort

  • @yatheeshareddy3661
    @yatheeshareddy3661 6 років тому

    .

  • @AliRaza-vb7vv
    @AliRaza-vb7vv 5 років тому +1

    yrr kya buckchodi hai ...kash urdu ya hind m hota :'(