4 years later and you are literally saving my life Such a gift for teaching Thank you
@lovesignal Жыл бұрын
Yeah, you're really talented at teaching. Believe me when I say you've got a real gift. And thank you for sharing it because you don't know how daunting this concept was to me when hearing it from other instructors.
@janmuhammad73764 жыл бұрын
I wish I have teachers like him at my college
@navodyaliyanage4733 жыл бұрын
this is absolutely the best series on algorithms, I struggled a lot watching other videos, but this is really amazing, clear and short.
@utkarshmalik44714 жыл бұрын
Hey Derrick this is the best Algorithm Playlist I ever came across So please it's a humble request to make more videos on Algorithm
@thatcherkane49553 жыл бұрын
Sorry to be off topic but does anybody know a way to log back into an Instagram account?? I was stupid forgot the password. I love any assistance you can give me
@kasontrevor9663 жыл бұрын
@Thatcher Kane instablaster =)
@thatcherkane49553 жыл бұрын
@Kason Trevor thanks so much for your reply. I found the site through google and Im waiting for the hacking stuff now. Looks like it's gonna take quite some time so I will reply here later when my account password hopefully is recovered.
@thatcherkane49553 жыл бұрын
@Kason Trevor it did the trick and I now got access to my account again. I'm so happy! Thank you so much you saved my account !
@kasontrevor9663 жыл бұрын
@Thatcher Kane Glad I could help :)
@RadioKilledMusic4 жыл бұрын
def selection_sort(list_a): indexing_length=range(len(list_a)-1) for i in indexing_length: min_value=i for j in range(i+1,len(list_a)): if list_a[j]
@AlfredDHull3 жыл бұрын
Still loving this video two years later Derrick!
@andrewbrower41584 жыл бұрын
This tutorial is incredible. Thank you for teaching it so effectively
@johnhillescobar5 жыл бұрын
This is a great, amazing and super instructional video. My code for this algorithm is by far more complex. Love the code you created.
@aqualung14663 жыл бұрын
@Maryam Ashraf Below is what I did to test - setup params for "my_range" and "num_elements", or do like I did and make these arguments to your script with sys.argv. import sys import time import random my_range = int(sys.argv[1]) num_elements = int(sys.argv[2]) my_array = [random.randint(1, my_range) for i in range(0, num_elements)] start_time = time.time() bubble_sorted_array = list(bubble_sort(my_array)) bubble_sort_run_time = time.time() - start_time start_time = time.time() selection_sorted_array = list(selection_sort(my_array)) selection_sort_run_time = time.time() - start_time selection_sort_efficiency = bubble_sort_run_time / selection_sort_run_time print("bubble sort took {:.2f} seconds to run".format(bubble_sort_run_time)) print("selection sort took {:.2f} seconds to run".format(selection_sort_run_time)) print("selection sort was {:.2f} times more efficient than bubble sort".format(selection_sort_efficiency)) HTH
@AlternateMelatonin Жыл бұрын
I always wonder, why my professor spends 50 mins lecture just to teach what you show in 5 mins. Thank you always.
@coolios6854 жыл бұрын
Dude!!! Derrick this is so awesome. you make these concepts so easy to learn. Keep it up!!!
@timohelasvuo96505 жыл бұрын
Here again for another alogorithm treat! Thanks buddy for yet again great video. Looking forward to look into the code on my comp later today
@easynow65992 жыл бұрын
i have to admit.. I love your short but badass bass music at the intro..
@shrutikanikhar79874 жыл бұрын
You're an amazing teacher.......your videos are very helpful.... Thanks
@abletmuhtar89795 жыл бұрын
Pls teach all of those fundamental algorithms. Thanks
@rushas5 жыл бұрын
I like the new intro and the outro! Content is also great!
@tuborao4 жыл бұрын
Hi Derrick, first of all I would like to thank you for your videos. They are helping me a lot! I think I found an indentation error inside your script in your githup area. The "if min_value !=1" is not indented with the "for j", and this can cause some sort errors if the first element of the list is equal to the last element. thanks! for j in range(i+1, len(list_a)): if list_a[j] < list_a[min_value]: min_value = j if min_value != i: list_a[min_value], list_a[i] = list_a[i], list_a[min_value] return list_a print(selection_sort([6,7,8,7,6,5,4,5,6,7,6,7,8,9,7,9,0]))
@cassidybrookland21742 жыл бұрын
this fixed my error!
@lone.wo1f4 жыл бұрын
Great tutorial! Easy to grasp the concepts.. Subbed!
@aqualung14663 жыл бұрын
Your videos as terrific, thank you. Below is what I came up with - it is almost twice as fast as your code. Why is that?? def selection_sort(unsorted_list): sorted_list = [] while len(unsorted_list) > 0: min_index, min = 0, unsorted_list[0] for i in range(0, (len(unsorted_list) - 1)): if unsorted_list[i] < min: min_index, min = i, unsorted_list[i] sorted_list.append(unsorted_list.pop(min_index)) return sorted_list
@nowyouknow22495 жыл бұрын
Nice video like it's really cool. Fire on bruv!
@mahadkhurram29503 жыл бұрын
Thanks bro, I have an exam tomorrow. And this is really gonna help.
@DeepakSah3.07 ай бұрын
Love from India - Thanks
@anirbanc882 жыл бұрын
you are the coolest guy ever man, thanks so much
@SEE.ME.N0.M0RE3 жыл бұрын
Thank you so much!
@jiahuizhu39114 жыл бұрын
A basic question. How come the 'changing position' could work? such as list[j], list[i] = list[i], list[j]. The first assignment should change list[j], the the second assignment will come back to i, isn't it? Has python put some secrete third item to keep the value temporarily? I am a learner on Python:) Thank you very much in advance
@rahulnegi4563 жыл бұрын
its swapping the expression: “ a, b = b, a”, first right gets assigned to first left and second right get assigned to second left at the same time therefore swap values of a and b Search for one liner swapping in python you will get it!
@carloschaccon84655 жыл бұрын
Awesome Derrick, Have you considered a video for Regular Expressions to find data over large files, It is just an idea, thanks again, and keep sharing your knowledge .
@sebastianlupa73553 жыл бұрын
I think calling min_value index_of_min_value could make it clearer, took me a while to figure it out :-)
@aqualung14663 жыл бұрын
Agreed.
@rayanrahmoune10644 жыл бұрын
I did it another way i don't know if it's selection sort def selectionsort(mylist): indexing_length = len(mylist) sorted = [] if indexing_length mylist[value]: min = mylist[value] mylist[0], mylist[value] = mylist[value] , mylist[0] mylist.pop(0) notsorted = mylist sorted.append(min) return sorted + selectionsort(notsorted)
@alexeyigonen31704 жыл бұрын
Thanks for your videos. Will this code be shorter? (prints really help to see the work of the two cycles) for k in range(0,n-1): print('for cycle, k: ', k) for x in range(1, n): print("for cycle, x:",x,a) if a[k] > a[x] and x > k: a[k], a[x] = a[x], a[k]
@xynerd2 жыл бұрын
awesome explanation!
@navodyaliyanage4733 жыл бұрын
please make more videos on python..on what's after algorithms
@mehmetozel90013 жыл бұрын
Really really easy explained I love u
@lyricsdelivered2 жыл бұрын
How do you calculate time complexity
@erikcarcelen16634 жыл бұрын
Hey, amazing video and so beautiful explanation, but I have a question hehe How do you do your animations?
@Futball8603 жыл бұрын
Would the result be different if we used indexing_length = range(0, len(list_a))?
@breakoutgaffe40272 жыл бұрын
great explanation
@jaket7502 жыл бұрын
thanks man you saved me
@DispelTV3 жыл бұрын
When I measure the time it takes to sort with bubble vs selection, selection always takes longer to execute. How is selection better than bubble if bubble takes less time and there's 2 for loops in selection sort which leads to higher complexity O(n^2)? Otherwise, fantastic and simple videos to learn from.
@krissh65634 жыл бұрын
Which software you are using for this video editing
@abdullahshahid62163 жыл бұрын
Line 7: Should the min_value be equal to list_a[ i ]??? Please answer
@dewman74774 жыл бұрын
I don’t get why indexing length only goes to second last item in unsourced list. What if the item in the unworried list is smaller than the previous minimum value?
@ahmedghanem31264 жыл бұрын
Hey Bro You have wrong code if you put [ '1', '4', '19'] output will be [ '1', '19' , '4']
@gaganjeetsingh6734 жыл бұрын
No. The code is absolutely fine. You must've implemented it wrong.
@SReaperz4 жыл бұрын
his code is the problem to fix it just add if min_value != i: list_a[min_value], list_a[i] = list_a[i], list_a[min_value] min_value = i
@somyamaniktala10904 жыл бұрын
best explanation..
@sergdonskikh21404 жыл бұрын
Hi! Good lessons!
@hardiktmustudent58514 жыл бұрын
hey can you plz tell me a program for to rotate a matrix 90 degree anti-clockwise
@aminetlemcani6934 жыл бұрын
Thanks for the video
@alighaith97175 жыл бұрын
thank you for effort Derrick , can you help me with this issue (I have a file of 1000 images and i want to classify it at specific folders i already created for example : from pic 1 to 10 move to folder number 1 and from 12 to 15 to folder number 2 etc ....)I'm biggner on python if you help me I really appreciated it .
@codex83324 жыл бұрын
Please I don't understand the logic behind.the last part. If the min_value != i . Please I need an explanation
@KeepCoding69 Жыл бұрын
It's not required actually u can just simply write the switch statement and it would still work.
@lukasreissig45003 жыл бұрын
I am a beginner with Python, which programming evironment is that?
@shanmuga-raj3 жыл бұрын
bro can you do more videos like this...
@betobernal4864 жыл бұрын
Hi Derrick thanks for your videos. I solved in a recursive way, take a look! def selection_sort(lista,sortedd): if len(lista) !=0: mini=lista[0] for i in lista[1:]: mini=min(mini,i) sortedd.append(mini) lista.remove(mini) selection_sort(lista,sortedd) return sortedd def sorting(lista): return selection_sort(lista,[]) a=[3,3,54,2345,542,456,0,3,4,4,3,6] sorting(a) The problem is that my function requires 2 args, thats why I had to implement the second function. Is there a way to do it this way with only one function? Thanks!
@johndunn62535 жыл бұрын
Good stuff. Thanks
@luffyhat38523 жыл бұрын
your code isnt working for [3,1,2,5,4] this input . it shows the output as [2,1,3,4,5]
@KeepCoding69 Жыл бұрын
You need to write the switch statement outside the 2nd for loop. I know it's late but I hope you will find it useful.
@samuelchen86354 жыл бұрын
thank you for making this :0
@mhd4034 жыл бұрын
when we changed iMin = j does that change the iMin value or the value stored at list[iMin]?
@16aasthadoshi954 жыл бұрын
imin value whereas list[imin]=j changes value in the list to value of j
@handle-23 жыл бұрын
can someone explain what this line does? its line 14 in his code list_a[min_value],list_a[i]=list_a[i],list_a[min_value]
@rahulnegi4563 жыл бұрын
its swapping the expression: “ a, b = b, a”, first right gets assigned to first left and second right get assigned to second left at the same time therefore swap values of a and b Search for one liner swapping in python you will get it!
@expat20104 жыл бұрын
Cool!
@prasikrar39273 жыл бұрын
thanks sir iam from wkwkw island
@leas98544 жыл бұрын
What do i and j stand for?
@KeepCoding69 Жыл бұрын
Those are the counter variables
@MadhushreeSinha4 жыл бұрын
Isn't the min_val != i : is redundant?
@rahulnegi4563 жыл бұрын
yes its not necessary
@masoud48432 жыл бұрын
❤👌
@darthbolloful4 жыл бұрын
Derrick stop it you're scaring me
@rishabhawasthi81922 жыл бұрын
David Bowie teaching CS
@yunkel5 жыл бұрын
👍
@AbdullahKhan-dl9lm3 жыл бұрын
ahhh....The algorithm doesn't work.
@hamdamjonganijonov88254 жыл бұрын
lmao, why is his code sooo easy to understand!
@rw48773 жыл бұрын
You have beautiful eyes man
@qasimarshad266229 күн бұрын
I have to say you explain well but not for a beginner, I already knew all these concepts and needed a recap and tbh i found your teaching a bit too quick, you need to explain slowly and in more detail