Insertion Sort - CS50 Shorts

  Рет қаралды 59,894

CS50

CS50

5 жыл бұрын

Пікірлер: 31
@aaronmaxcarver
@aaronmaxcarver 4 жыл бұрын
Hopefully Izod will sign Doug to a golf shirt sponsorship deal soon. Fresh shirts in every video.
@mahaagro7783
@mahaagro7783 5 жыл бұрын
Doug saving programmers' lives since 2017 :)
@Maen963
@Maen963 4 жыл бұрын
Yup 😂❤
@user-st4qv2vw7q
@user-st4qv2vw7q 3 жыл бұрын
Thanks Doug, this is by far the best explanation on insertion sort!
@this_rishi
@this_rishi 4 жыл бұрын
wasn't this guy in 21 Jump Street?
@pramitgautam5221
@pramitgautam5221 4 жыл бұрын
This feels like bubble sort with extra steps
@thomasbeckley9187
@thomasbeckley9187 Жыл бұрын
i love you thank you helped me in my computing lesson
@ashkiin8493
@ashkiin8493 Жыл бұрын
Ended up here after seeing "insertion sort" mentioned in the average temperatures practice exercise's instructions. Wondering why this video is not included in the courses' page as the merge, selection and bubble sort are? Just seeing this video (haven't tried figuring out how to code this yet) it seems the least intuitive of all 4, and as bad as selection sort. Is that why it got removed from the course?
@khaled-dev
@khaled-dev 3 жыл бұрын
i wish he shows the code as well
@GOODBOY-vt1cf
@GOODBOY-vt1cf 4 жыл бұрын
thank you man !
@mattkan3275
@mattkan3275 3 жыл бұрын
You are very professional in teaching
@tiakimx
@tiakimx 4 жыл бұрын
Could someone explain more about how he got O(n^2)?
@boneserickson
@boneserickson 4 жыл бұрын
yeah he said worst case scenario, you have to shift each of n characters, n times. so n x n = n^2
@sabrinal.5775
@sabrinal.5775 3 жыл бұрын
O looks at the worst case scenario: ie, all characters not sorted - we'll have to shift every character with every movement of the line (or the character we're looking at). If we looked at 1 character before, 1 shift (the character we just looked at) needs to be made for the 2nd character to be sorted. If there are 3 characters that are all unsorted, we will need to shift each character once in order to sort to the 3rd character. The math ends up being n^2 3 2 1 --> 1st sort ('3' is sorted) (1 * 1) 2 3 1 --> 2nd (2 and 3 shift to allow 2 and 3 to be sorted, 1 is not sorted yet) (2 chars /movements of the line * 2 shifts) 1 2 3 --> 3rd sort (1, 2, and 3 are shifted to allow all 3 characters to be shifted) (3 chars * 3 shifts)
@IMADETHISACCFORRAY
@IMADETHISACCFORRAY 4 жыл бұрын
Why don't you include pseudocode? Great visualisation apart from that.
@exnihilonihilfit6316
@exnihilonihilfit6316 3 жыл бұрын
I guess they simply don't deal with implementation in these videos.
@TypicallyThomas
@TypicallyThomas 2 жыл бұрын
What week does this belong to? I can't find it on the CS50 website
@davidjmalan
@davidjmalan 2 жыл бұрын
Week 3, but not discussed in recent years!
@TypicallyThomas
@TypicallyThomas 2 жыл бұрын
@@davidjmalan Any particular reason for that?
@XXXDooMXXXDoesMC
@XXXDooMXXXDoesMC 4 жыл бұрын
lol
@Jake-oz3fy
@Jake-oz3fy 5 жыл бұрын
Hey :))))))))))))))))DDD?
@splodys
@splodys 3 жыл бұрын
Wouldn't it be quicker to create a new empty array and start building it up with the elements, instead of continuously shifting elements in the original array? My only guess as to why this would be worst, is that it might make the program heavier in memory.
@jason1596tmgmail
@jason1596tmgmail 3 жыл бұрын
So, how do you decide where to put the element at the new array? You still have to shift the existing elements inside the "new" array in order to add an element to it, which is basically the same if you only have one array.
@ValentinSharonov
@ValentinSharonov 3 жыл бұрын
Had to double check my monitor because of the artifacts on his neck.
@bivshiyzek
@bivshiyzek 3 жыл бұрын
Inmate shirt? Broadcasting from the prison?
@arcadeeeee26
@arcadeeeee26 3 жыл бұрын
When I try to sort an array of numbers, the way I calculate it, it every element only gets shifted (n - 1) times. For example for list of 4, 3, 2, 1: Wouldn't each element only shift 3 positions? So 4 elements * 3 shifts each = total of 12 shifts? so n * (n - 1) shifts? But Doug says each of the n elements gets shifted n times. I don't understand how each element could shift n times? for example if 4 shifted 4 times wouldn't it go over the available number of indexes in the array?
@Walruz1000
@Walruz1000 3 жыл бұрын
I am confused as to why the selection sort is still n squared because for each iteration of the outer loop you will be reducing the size of the inner loop by one, and on top of this you still need to swap 2 items around on each iteration. For the insertion sort there is only one loop but its the swapping that seems to end up increasing the complexity, I wonder why this is not taken into consideration for some algorithms where they loop multiple times but also need to swap each time?
@kochikamevideos2502
@kochikamevideos2502 3 жыл бұрын
i didnot understand
@Enskkc
@Enskkc 4 жыл бұрын
What is the name of the CS50 course explaining all the sort algorithms?
@johneng6534
@johneng6534 3 жыл бұрын
@@davidjmalan MVP
Quicksort: Partitioning an array
4:48
KC Ang
Рет қаралды 578 М.
Nutella bro sis family Challenge 😋
00:31
Mr. Clabik
Рет қаралды 13 МЛН
LOVE LETTER - POPPY PLAYTIME CHAPTER 3 | GH'S ANIMATION
00:15
Visualization of Quick sort (HD)
3:12
udiprod
Рет қаралды 849 М.
CS50 Shorts - Merge Sort
7:42
Apps Developer
Рет қаралды 33 М.
Sorting Algorithms in JS : Insertion Sort
7:44
getMaxed
Рет қаралды 5 М.
Insertion Sort | C++ Example
11:40
Portfolio Courses
Рет қаралды 25 М.
3 Levels of Sorting Algorithms - FASTEST Comparison Sort!
10:38
Bubble Sort
3:32
KC Ang
Рет қаралды 84 М.
Diffie-Hellman Key Exchange: How to Share a Secret
9:09
Spanning Tree
Рет қаралды 134 М.
Shell sort vs Insertion sort
6:23
udiprod
Рет қаралды 138 М.
Generative AI in a Nutshell - how to survive and thrive in the age of AI
17:57