Selection sort algorithm

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

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

  • @mycodeschool
    @mycodeschool  11 лет назад +242

    This is almost like online tuition. You can ask questions and even request videos. We can try to get them. :)

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

      My god . How could you know that ? Even I thought why this guy is not uploading videos.

    • @nithingunamgari871
      @nithingunamgari871 5 лет назад +16

      @@bubaighosh8500 Nope, the person teaching is pretty much alive and is working at Google. (Animesh Nayan). However, another co-founder kinda guy (Harsha aka Humblefool) died in an accident. Those circumstances led to the closure of the channel.

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

      @@oreoshake6287 no

    • @shubhamsulakhe3382
      @shubhamsulakhe3382 2 года назад

      @@shamanthakrishnakg1978 uff

    • @shankar7435
      @shankar7435 6 месяцев назад

      ❤❤❤

  • @mycodeschool
    @mycodeschool  11 лет назад +91

    Did you see our merge sort video? Its quite simplified. You may start loving recursion once it settles well in your head.

  • @bob_factory
    @bob_factory 5 лет назад +30

    I saw a lot of comments below asking for new videos from this guy, This is 2020 and it has been 7 years since this video was posted and the content is top-notch. However the author is no more and suffered a loss of life by a speeding car while crossing a road. May he rest in peace.

  • @mycodeschool
    @mycodeschool  11 лет назад +35

    We are always comparing with A[iMin] i.e the current minimum,, so, its against 7, then against 4 and then against 2. Its not always against 7 because iMin is getting updated.

  • @swetamahajan6416
    @swetamahajan6416 7 лет назад +19

    These videos are really awesome.Please post more videos on C programming and if possible on java,python,c++ or any other language you want or on data structures and algorithms because you are doing a great job. Your videos helped me a lot.You make things simple and concise.

  • @CSSoda
    @CSSoda 4 года назад +30

    Rest in Peace Harsha. You will be remembered through your amazing work.

  • @jayjw1
    @jayjw1 17 дней назад

    Rest in peace Harsha. I feel honored to be learning from you even after you're gone from this earth.

  • @MelDen-h9z
    @MelDen-h9z Год назад +2

    One of the greatest lecture of all time on algorithm!

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

    Great lesson, I think the final code can be optimized...
    void selectionSort(int* A, int n){
    int temp; // temporary variable
    for (int i=0; i < n-1; i++){ // n-2 passes (last element comparisons are not necessary)
    for (int j=i+1; j < n; j++){
    if (A[j] < A[i]){ // there's a smaller value ahead
    temp = A[i]; // interchange positions
    A[i] = A[j];
    A[j] = temp;
    }
    }
    }

    • @saajankumarjha244
      @saajankumarjha244 2 года назад

      how's this optimized ? what you've done is nothing but bubble sort with swapping of min elements. Time complexity for both is O(n^2)

    • @davidgmos
      @davidgmos 2 года назад +1

      @@saajankumarjha244 yes that's optimization swapping elements only when needed, that implies fewer instructions per pass and less execution time even with the same time complexity

    • @saajankumarjha244
      @saajankumarjha244 2 года назад

      @@davidgmos here's a scenario for you consider an array {5,4,3,2,1}, let me know which one is optimized in terms of swapping.

    • @davidgmos
      @davidgmos 2 года назад +1

      @@saajankumarjha244 mine because in the worst case scenario (like the one you propose) swapping occurs through all the array and time execution is almost the same, but when it's not the case (like the vast majority of cases) the lines that swap positions in my code execute only when is necessary because they are inside the "if" condition.

  • @ryujiyamasaki355
    @ryujiyamasaki355 2 года назад +1

    Thank you so much, will probably binge watch your videos for my upcoming DSA exam

  • @tanmaysrivatsa8550
    @tanmaysrivatsa8550 5 лет назад +4

    It was difficult for me to understand but you made me understand in 10 minutes.
    Thanks

  • @dileepbc5901
    @dileepbc5901 5 лет назад +19

    dear sir, we are following ur entire content please update this course with more algorithms , please bros who like this series give thumbs .
    (from india)

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

      brother, this guy is no more

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

      @@sarfaraz6582 what happened to him

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

      @@shubhampanwar6879 passed away years ago by car accident

    • @AbhishekSingh-hy4dm
      @AbhishekSingh-hy4dm 4 года назад +3

      @@sarfaraz6582 bro its not this guy its the other cofounder of the channel his friend who died..the guy who speaks in the video works for google now

  • @anton.encours
    @anton.encours 8 лет назад +56

    it probably would make sense to add another "if" statement, to check if the min is different from i (then swap is needed). Right now, we are swapping every time, even when it is not needed

    • @RajeevKumar-ch4kg
      @RajeevKumar-ch4kg 5 лет назад

      Hi Anton,
      We are building a huge video tutorial of solutions which are asked in the interview. and we need your feedback on our video content. We believe that we can achieve that if you are around with us. So please come to our RUclips channel. The playlist link is as given below.
      ruclips.net/p/PLqqPVCi6glKYJ3RK_LrlljjnAk5QdcroX
      Please subscribe the channel for any upload notification.

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

      Actually,I also think about “if”,if it is added,the program is more efficient .

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

      @@chouliwen4173 no.

  • @hirakmondal6174
    @hirakmondal6174 7 лет назад +217

    *_This guy sounds the same as the one on neso academy_*

    • @shubhampatel5576
      @shubhampatel5576 6 лет назад +2

      yes , noticed

    • @anshul6516
      @anshul6516 6 лет назад +5

      he also owns neso academy.

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

      HIRAK MONDAL your comment is in bold. How you do that...

    • @RajKumar-qv7ci
      @RajKumar-qv7ci 6 лет назад +7

      @@usama57926 *use "*" at start and end of comment*

    • @usama57926
      @usama57926 6 лет назад +3

      @@RajKumar-qv7ci thank u very much

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

    Selection sort. In computer science, selection sort is a sorting algorithm, specifically an in-place comparison sort. It has O(n2) time complexity, making it inefficient on large lists, and generally performs worse than the similar insertion sort.

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

      His definition of in-place for this algorithm that you showed makes sense but from other examples i see swaps and not copying values to a new array. In place means there is NOT a use of extra data structures that will be created then deleted. Selection sort is said to be an in place but you are saying it is not? is this explanation wrong or am I confused?

    • @youarethecssformyhtml
      @youarethecssformyhtml Год назад

      @@blake1835 well it can be both in-place and not-in-place. Generally, not-in-place are used to make explanation easier. But in-place is much better.

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

    some of the best material online period

  • @BNFY1
    @BNFY1 Год назад

    Such a masterpiece! It is still no.1 in 2023

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

    I really appreciate your work...one of the best channel for DS & Algo...Please make more videos

  • @ayushcode5804
    @ayushcode5804 4 года назад +9

    Love his voice

  • @rupaliroychoudhury2300
    @rupaliroychoudhury2300 9 лет назад +2

    I think for selection sort, time complexity for best case should be O(n) because if one traverses through the already sorted list, then one can always come out of it after finding that it is already sorted instead of traversing again. Here is my code :
    int temp, min = 0, index = 0;
    bool swap = true;
    for(int i = 0; i < num && swap; i++)
    {
    min = arr[i];
    swap = false;
    for(int j = i; j < num - 1; j++)
    {
    if(min > arr[j+1])
    {
    min = arr[j+1];
    index = j+1;
    swap = true;
    }
    }
    if(swap == true)
    {
    temp = arr[i];
    arr[i] = min;
    min = temp;
    arr[index] = min;
    }
    }

    • @tej4o3
      @tej4o3 Год назад

      It's O(n^2) because of the nested for loop I think

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

    amazing explanation, hats off to you sir, keep it up 👍👍

  • @silentcod3r
    @silentcod3r 11 лет назад

    You mentioned that this algorithm is slow, but technically, it is not if n (size of the array) is small. As n gets bigger, it can begin to get slower yes.

  • @ranjeethashastri9086
    @ranjeethashastri9086 7 месяцев назад

    at 7:45, shouldnt j be from i+1 to n? otherwise we keep missing the last element of the array and dont compare it to anything

  • @ventin75
    @ventin75 9 лет назад +1

    The way you explain your selection sort and how you code your selection sort function is actually different in my opinion.

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

      I also agree with this

  • @annmaryjose7880
    @annmaryjose7880 7 лет назад +8

    U saved my life

  • @LUX1111111111111
    @LUX1111111111111 11 лет назад +11

    I just love you. You teach the way I learn !

  • @Juznik1389
    @Juznik1389 9 лет назад +9

    I LOVE YOU! Thanks for these clips!

  • @jayshrinikam19
    @jayshrinikam19 8 лет назад +10

    I found it complicated than other explanations..Why can t you have variable to hold the index of minimum value from each pass. Then swap the first element and the minimum element. So in next pass start from 2nd element to find second element and so on...

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

    It's too good👍👍 i understood very easily bro
    Your language accent is so good and sweet

  • @amritanair6640
    @amritanair6640 8 лет назад +2

    There is a mistake at 2:37, it is supposed to be the second smallest element and not second-largest.
    Thank you for the videos, they are absolutely amazing :)

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

      he probably meant to say 2nd largest within the sorted portion of the array.

  • @juhabach6371
    @juhabach6371 3 года назад +1

    Dude, please keep making videos...we need you, even in 2021...please

  • @sudhanshusingh208
    @sudhanshusingh208 3 года назад +4

    Hi, I recently found out about your channel and why did you stop making videos you are so good at it. Its a request if you could upload more videos about cs if possible. Love your work

    • @swastiksharma6926
      @swastiksharma6926 2 года назад +1

      he died

    • @womanwhocode3032
      @womanwhocode3032 2 года назад

      @@swastiksharma6926 no Animesh nayan is alive

    • @VivanRangra
      @VivanRangra Год назад

      @@womanwhocode3032 the brain behind the channel that is Harish died and as a result Animesh is depressed and can not make more videos

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

    Sir hats off to you the best lectures on sorts i have ever heard thankyou so much

  • @energizedphy6bybhathiyawij9
    @energizedphy6bybhathiyawij9 9 лет назад +1

    This helps me a lot in my exam..thnkzzzzzz a lot

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

    very gratuful for you man , this really gave an overview of sorting algorithms

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

    teacher: lets talk about simple sorting scenerio. teacher: *takes out adult uno cards*

  • @ahinsa__parmo__dharam
    @ahinsa__parmo__dharam 3 года назад +1

    Best explanation I ever found for sorting.
    Thanks alot sir for the easiest approaches you shared with us .😊😊

  • @beardlessspirit4946
    @beardlessspirit4946 9 лет назад +1

    please do the lecture for file pointers i.e, lecture on streams.....
    we are having a lot of trouble in learning that.......
    thank you for all the lectures till now.....

  • @paramjeetchauhan
    @paramjeetchauhan 8 лет назад +1

    thanks bro. your teaching way is impressive.....

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

    nth term in arithmetic series is calculated by a (sub n) = n ( (a1 + a (sub n) )/ 2 ) , if last term is 1, and first is (n-1), how do you get n(n-1) / 2

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

    this vid also taught me time complexity calculation wow! hats off....

  • @LalitPoddar
    @LalitPoddar 10 лет назад +1

    7:46 acc to j loop for an array 472135, the element replaced with 4 will be 2, not 1, which is contrary to the fact that the lowest element is compared with the element at index 0. So what exactly it is?

    • @nilashishchakraborty3983
      @nilashishchakraborty3983 10 лет назад

      This is my question too :/
      For e.g., 4,2,1,8
      It would give back 2,1,4,8 :/

    • @Horhew
      @Horhew 10 лет назад

      Nilashish Chakraborty
      That's because you forgot (like me, at first) that the "j" loop loops all the way to the end of the array on each "i" iteration. 2,1,4,8 is the result you would get if the "j" loop would run only over one element (j=i+1).

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

      it's a faulty algorithm man he should have stored the position of min not the value to swap at the end

  • @SaratKumar-qk7lu
    @SaratKumar-qk7lu 6 лет назад +4

    Hello,
    Thanks! for the Explanation. It's good to start for learning. I have a small doubt. At present we have shortcuts are available like Arrays.sort(), Arrays.parallelSort(); Comparable and Comparator etc., We need to learn this sorting Algorithm._ (I don't know that's the reason I am asking.) _.*It anyone knows please provide the answer. * Please provide any links. I need to learn more about this.
    Thanks and Regards,
    Sarat.

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

      There are predefined sorting methods . These sorting algorithms are just choices in case we need to implement algorithms based on input size.

  • @beauty876
    @beauty876 Год назад

    You are good at teaching and creating panel
    Thank you

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

    Why i

  • @nilashishchakraborty3983
    @nilashishchakraborty3983 10 лет назад

    There is an issue with this algorithm. If u take inputs as 4,2,1,8 it gives back 2,1,4,8 as output. And it is not an issue of the code because the sorting algorithm itself specifies this sort of output it. Please check it :)
    P.S: I might be wrong ;)

    • @jef4300
      @jef4300 10 лет назад

      it gives 1248 for me

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

    8:03 Shouldn't the outermost loop be running n-1 times? The logic is correct but the comment is not correct

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

      You're correct, just a small mistake there

  • @amanchauhan-jl9ls
    @amanchauhan-jl9ls 11 лет назад +1

    Nice explanation..
    but can you please upload video for Heap Sort and Radix sort?

  • @thedotz10
    @thedotz10 11 лет назад +2

    Hello Sir. Here I have a doubt. When you are in element 7 and then we check for each element which is lesser than 7 from 2 to 5 indices. In each index suppose index 2 (4 lesser 7) => True so imin is 2. Again it goes to index 3 (2 lesser 7) True = > imin is 3 then index 4(5 lesser 7)= > imin is 4 and last index 5(3 lesser 7) = > imin is 5. So at the end imin is 5. Now A[5] and A[1] will be swapped right that is 7 AND 3 ?

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

      I too have this same doubt.. can anyone clarify ?

  • @sayyedaaman5719
    @sayyedaaman5719 2 года назад

    Thank you sir for that video it's very helpful for me

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

    Why use iMin at all?
    Why not simply use i instead of iMin?
    We can do the comparison A[j] < A[i] and it will give the same result.
    void SelectionSort(int A[], int n)
    {
    for (int i=0; i

    • @anmol9886
      @anmol9886 2 года назад

      Just for sake of better understanding

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

    all da videos r just mind blowing

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

    Your videos are the best of data structures and algorithms and more!
    Do have a question about this video here. @7:56, the comment says "we need to do n-2 passes", but even though we do not have to do the last loop, that should still mean n-1? From the loop condition, it was n-1 passes, and also in practice, it's n-1 passes as well.
    Does anyone also have this concern? Thanks

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

    Totally worth that horrendous zomato ad

  • @TheMcallist1
    @TheMcallist1 6 лет назад +2

    Amazing vids. Thanks for making them.

  • @youarethecssformyhtml
    @youarethecssformyhtml Год назад +1

    There's an error in the pseudocode. It's:
    for i

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

    *nicely explained..loved it*

  • @bhaskerthapa6534
    @bhaskerthapa6534 9 лет назад +3

    thank u soo much for these good tutorials.

  • @abhinashmahor6227
    @abhinashmahor6227 9 лет назад +1

    please upload a lecture on linkedlist

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

    Normally I am not into correcting grammar mistakes but since you say it in every video: first not 1th
    great videos btw!!

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

      First number will actually be the zeroth index . So 1th is said to avoid confusion .

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

    instead of n could replace by array.length or return new arr[] will be more efficient

  • @RahulKumar-cg9sf
    @RahulKumar-cg9sf 6 лет назад +1

    great work..it really very helpful

  • @venkatasubbareddy.g2283
    @venkatasubbareddy.g2283 5 лет назад +2

    Could you make the data structures and algorithms videos using java

    • @RajeevKumar-ch4kg
      @RajeevKumar-ch4kg 5 лет назад

      Hi Venkata,
      We are building a huge video tutorial of solutions which are asked in the interview. and we need your feedback on our video content. We believe that we can achieve that if you are around with us. So please come to our RUclips channel. The playlist link is as given below.
      ruclips.net/p/PLqqPVCi6glKYJ3RK_LrlljjnAk5QdcroX
      Please subscribe the channel for any upload notification.

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

    You help me so much
    Thanks for your brilliant tutorial!!!

  • @HWHWID
    @HWHWID 2 года назад

    how to stop looping by using selectionsort if array is already sorted?

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

    Please provide videos on heap sort also

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

    *best lecture*

  • @sidneyeubanks8224
    @sidneyeubanks8224 7 лет назад +2

    Great tutorials! Keep it up i appreciate it!

  • @jarjarbinks9937
    @jarjarbinks9937 2 года назад

    can we just not perform a simple swap in selection sort for every length of array

  • @narsireddynallamilli3755
    @narsireddynallamilli3755 11 лет назад +3

    Can we improve algo by running c3 only if iMin is changed in c2?

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

    please update your content if possible!

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

    in 2021 also best series to learn Ds

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

    excellent explanation

  • @tanm7610
    @tanm7610 10 лет назад +1

    loving your videos!!

  • @MMa-eo1yw
    @MMa-eo1yw 10 лет назад

    when entering the inner for loop and checking the if (condition) which if true updates the value of iMin to j, does the result of iMin changing its value to j correspond to entering the inner for loop again?

    • @MMa-eo1yw
      @MMa-eo1yw 10 лет назад

      I found the answer to my question...after reading the code a few times I was able to see what the inner for loop was doing with each j index....Your videos are great!

    • @mycodeschool
      @mycodeschool  10 лет назад +1

      M. Ma awesome :)

  • @Burak-pl1jl
    @Burak-pl1jl 6 лет назад

    Wouldn't the part with the cost "c1" be executed "n - 2" times? Since you are starting with the index 0 till n-2
    which makes
    (n - 2) - 0 + 1 = n - 1
    for the loop header of the outer loop. Then n - 2 for the statements inside the loop.

  • @ibrahimgadli2583
    @ibrahimgadli2583 2 года назад

    How did you get n(n-1)2 pls explain

  • @rolandoaguilera3114
    @rolandoaguilera3114 8 лет назад

    what about an array like this {3,2,1} will it still work?

  • @mcwho3
    @mcwho3 9 лет назад

    Great video! This was a much clearer explanation than when i took this class in college. Quick question, why would you want/need to pass in the length of the array. Are you assuming that this is being implemented in languages without built in arrays with a find/return length function? It seems like it would be unnecessary for a user to input the length.

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

    Just a suggestion!!!!!!!!!!!!!!!!!!!!WE dont need to swap even if the chosen i element is already minimum in global array

  • @silverzero9524
    @silverzero9524 7 лет назад +107

    Array bhai bhai bhai bhai

    • @aryamaangoswamy179
      @aryamaangoswamy179 5 лет назад +10

      List behen behen behen behen

    • @RajeevKumar-ch4kg
      @RajeevKumar-ch4kg 5 лет назад +2

      Hi Miscritz,
      We are building a huge video tutorial of solutions which are asked in the interview. and we need your feedback on our video content. We believe that we can achieve that if you are around with us. So please come to our RUclips channel. The playlist link is as given below.
      ruclips.net/p/PLqqPVCi6glKYJ3RK_LrlljjnAk5QdcroX
      Please subscribe the channel for any upload notification.

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

      @@aryamaangoswamy179 😂

    • @spaceandtechnology5214
      @spaceandtechnology5214 2 года назад

      😂😂😂😂😂😂

    • @iam_tanishmall
      @iam_tanishmall 2 года назад

      Bro😂😂

  • @pritamsarkar8830
    @pritamsarkar8830 8 лет назад +1

    please give me the time complexity analysis link

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

    Time complexity explanation was pretty vague. I felt the second expression should be (n-2)(n-2)C2/2

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

    Great Explanation !!!
    Btw which software do u use for writing things like this?

  • @sanjanaattanayake4231
    @sanjanaattanayake4231 Год назад

    Thank you!!!
    Awesome teaching...

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

    Good work👍🏻👍🏻👍🏻

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

    You're so good!!!! Indian tutorials forever!

  • @FlyingHulk
    @FlyingHulk 7 лет назад +9

    2:37 When you are good at coding but you say 1th instead of 1st xD

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

      dude, we are discussing the index so, the first index of array is not so cool as a programmer as the 1th , huhh!

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

    Explanation is very congested and hastened. Go over the points a bit more patiently

  • @cesarjom
    @cesarjom 9 лет назад

    this has probably been asked already, but why pass function argument "int n", when you can simply assign this variable inside function definition like so: int n = A.Length;

    • @kilianciuffolo
      @kilianciuffolo 8 лет назад +1

      +Cesar Omiste because in some low level languages like C an array is not an object but just a chunk of memory and it's up to you to save the length or if you want to be fancy measure a the memory size and divide by the size of the type :)

    • @cesarjom
      @cesarjom 8 лет назад

      Kilian Ciuffolo Thanks. Too long working in C# :)

  • @puneetja
    @puneetja 10 лет назад

    In Selection sort algorithm, why you are iterating the i loop till n-2 and j loop till n-1, should not they be n-1 and n, respectively. In program they are correct.

    • @mycodeschool
      @mycodeschool  10 лет назад

      punit jain It's because in the program, I am running the loop for less than n-1. In Pseudo code, I am saying till n-2. They mean the same.

    • @puneetja
      @puneetja 10 лет назад +2

      mycodeschool hmm, just confused how they both are same. as per the pseudo code if last last value in the array is the smallest value, pseudo code won't work?

    • @viva180
      @viva180 10 лет назад +2

      mycodeschool Yes, the punit jain is right. In pseudo code last array element won't be checked in any iteration. If you will have array 5, 3, 2, 1, 0 after sorting it will look like 1, 2, 3, 5, 0.
      P.S Please make some annotation on video to prevent confusions to another watchers. Thank you

    • @LarryAszune
      @LarryAszune 8 лет назад +1

      Answering to a really old comment here, but to clear up confusion: the difference is the pseudo code is "

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

      @@LarryAszune thanks

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

    Excellent explanation...we should make videos... excellent...

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

    Great explanation

  • @harmandua7489
    @harmandua7489 10 лет назад

    can u plz upload video Radix sort... I am not getting it through other videos available till now..

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

    is it safe to say that any algorithm with a nested loop would have a time complexity of at least (n^2)?

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

    what if we have duplicate number in the list like two same numbers. How that one number will be arranged?

  • @abhishekgopal9514
    @abhishekgopal9514 8 лет назад

    how will we find the minimum no. in an array? like what will be the code?

    • @yashkaushik6116
      @yashkaushik6116 8 лет назад

      +Spark Shift We actually assume that the first element is the minimum , and then we check it with with all the upcoming elements in the array here:-
      iMin

  • @deepanshubansal4454
    @deepanshubansal4454 9 лет назад +3

    mycodeschool You guys do an awesome job.Thanks!
    I have a query.The two loops are nested.So,to calculate the time complexity,shouldn't their individual complexities be multiplied?Why are they being added?

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

      Multiplication is nothing but repeated addition. He did the same

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

    Can anyone explain to me why did we use the iMin variable instead i variable in the if statement?

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

      because we are trying to find the index of minimum value so that we can swap it with the i'th value. If we use i instead we will mess up the first loop which uses i'th index to iterate

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

      ​@@spacesuitred3839Ohh thanks for the explanation!

  • @sagardolui2998
    @sagardolui2998 8 лет назад

    amazing video, you make it so simple..