12. Searching and Sorting

2024 ж. 22 Мам.
173 184 Рет қаралды

MIT 6.0001 Introduction to Computer Science and Programming in Python, Fall 2016
View the complete course: ocw.mit.edu/6-0001F16
Instructor: Prof. Eric Grimson
In this lecture, Prof. Grimson explains basic search and sort algorithms, including linear search, bisection search, bubble sort, selection sort, and merge sort.
License: Creative Commons BY-NC-SA
More information at ocw.mit.edu/terms
More courses at ocw.mit.edu

Пікірлер
  • This guy was the chancellor at MIT and yet teaches such basic concepts with sincerity and humility. Meanwhile most professors just brush over these topics assuming the students can learn it on their own. Massive respect !

    @abhishekhawaldar569@abhishekhawaldar5693 жыл бұрын
    • Exactly! The less knowledgeable the more arrogant

      @JH-ux1re@JH-ux1re2 жыл бұрын
    • 42:12 merge isn’t logn iterations its at least n iterations and at most 2n iterations. You can see at 39:49 that number of prints(iterations) isn’t logn. 37:32 we aren’t cutting down the problem in half, it’s a tree 40:33. It’s logn levels of iterations(not iterations themselves) where iterations at each level together have O(n) complexity(cost of each step(iteration) is O(n) but turns out that cost of steps at same level of a tree is also O(n) 41:24. He just mixes levels with steps 42:04 Normally what we do is we multiply number of steps(O(n->2n)) to their complexity(O(n)) but in this case we use the fact that at each LEVEL of a tree sum of conplexity of steps is O(n). So number of LEVELS in a tree (O(logn)) multipled with each level’s complexity(O(n)) = O(nlogn)

      @programmer1010@programmer1010 Жыл бұрын
    • @@JH-ux1re Perfectly explains his sentiments around the political divide.

      @McAwesomeReaper@McAwesomeReaper8 ай бұрын
    • ​@@JH-ux1re😢😊😊

      @ildoguilhermeschneider4296@ildoguilhermeschneider42966 ай бұрын
  • I've watched all the 12 lectures during corona time, I think professor Eric deserved a better audience, his jokes are really good and keep your attention through the course. Thanks MIT !!

    @VixyMan96@VixyMan964 жыл бұрын
    • same here

      @saurabhmiyani9014@saurabhmiyani90144 жыл бұрын
    • same game (c) Prof. Grimson

      @shamrockspb@shamrockspb4 жыл бұрын
    • Can u share the playlist link

      @kannammapoona8064@kannammapoona80644 жыл бұрын
    • @@kannammapoona8064 I'm late but it's /playlist?list=PLUl4u3cNGP63WbdFxL8giv4yhgdMGaZNA

      @bee_irl@bee_irl3 жыл бұрын
    • I do agree

      @utkarshaganla5724@utkarshaganla57243 жыл бұрын
  • *My takeaways:* 1. Search algorithm 2:49 2. Sorting a list is also linear complexity 8:09, but when we search for something, we often search many times, therefore the cost of sorting could be balanced 9:37 3. Bogo sort (unbounded complexity) 11:00 4. Bubble sort (quadratic complexity) 12:48 5. Selection sort (quadratic complexity) 18:20 6. Merge sort (log-linear complexity) 26:20, and why it is efficient 32:55, it is the best we can have (considering worst cases not average cases)

    @leixun@leixun4 жыл бұрын
    • Lei Xun thanks

      @Amy_Yu2023@Amy_Yu20233 жыл бұрын
    • Thanks for the handy time stamps.

      @fc.soccercard@fc.soccercard3 жыл бұрын
  • For someone watching this. Make sure you do the problem sets. These classes mean nothing without them. It has been a great experience watching all the videos

    @CamiloDS@CamiloDS4 жыл бұрын
  • It has been an amazing learning experience to watch those 12 MIT lectures, I am really thankful to the institution for making all this avaiable to everyone, It's been really helpful. Incredible teachers and great lectures, already looking forward for the next course I will certainly "attend" hehe cheers from a brazillian comp science undergrad

    @marco.nascimento@marco.nascimento5 жыл бұрын
  • Thank you MIT, I really enjoyed this class.

    @TheDinosaurHead@TheDinosaurHead7 жыл бұрын
  • I'm so grateful for MIT and everyone who helps support OCW. This course was an incredible experience and i can't believe I just did it from Argentina, during an economic crisis. Thank you!!!

    @tomifg@tomifg3 жыл бұрын
  • One of my biggest dream was studying at MIT, I was pretty optimistic about that till I was like 16yo when I realise it is impossible, bcs I live in central Europe and I also needed to pass some difficult times so I didn't tryhard learning as much as I wanted to. These courses are making my dream partly realised. I'm so grateful for that, thank you

    @dominikklon1985@dominikklon19854 жыл бұрын
    • garbge

      @hoangnamdn682@hoangnamdn6822 жыл бұрын
  • I’m in awe such incredible lectures are available free of charge on the internet. This far exceeded the quality of any CS course I’ve taken to date.

    @RussTeeTrombone@RussTeeTrombone5 жыл бұрын
  • You did in one lecture, what my shitty lecturer tried to do in a week. Very good, simple and accurate.

    @dayzed_gecko@dayzed_gecko6 жыл бұрын
  • by far the most amazing course I've taken, really thankful to you guys for taking the time and providing this

    @tuanh9661@tuanh966110 ай бұрын
  • Thank you very much for this free resource. I've memorized all the algorithms presented after running into what I would consider a severe mental block in trying to conceptualize them in my mind before memorizing them. I only share in case anyone else is struggling with trying to deeply understand the content, my suggestion is to first memorize the algorithms, type them out a few hundred times, line by line, through memory, then the concepts will solidify in your mind and you can start to adapt them to other facets of programming. I think we'd all like to pretend we're super-genius's that "get it" on the first go-round, but, at least in my case, it just doesn't work that way.

    @zigginzag584@zigginzag5843 жыл бұрын
  • Thank You MIT-OCW from bottom of my heart.... Thank You for your honest service. I really enjoyed this journey with both professors. THANK YOU :)

    @atyantsony2013@atyantsony20133 жыл бұрын
  • Thanks MIT for producing such great content and making it freely available. This is the third MIT course that I have finished.

    @robpatty1811@robpatty18112 жыл бұрын
  • THANKS MIT, ALL THE PROFESSORS AND MIT OCW TEAM FOR SHARING SUCH AMAZING KNOWLEDGE

    @shittyworld@shittyworld3 жыл бұрын
  • This was amazing. Thank you professor for making me understand these concepts so easily. I’ve been trying to understand these concepts for so many years and now I feel like I truly get it. A gifted teacher and thanks MIT for providing this!

    @hermionegrful@hermionegrful3 жыл бұрын
  • Those lectures are a a great chunk of knowledge I needed. I really liked the way everything is explaned. Thanks MIT

    @titanfrost8445@titanfrost84454 жыл бұрын
  • These guys are great!! I'm now accepting donations to buy Ana and Prof. Grimson a second pair of clothes.

    @micahd7255@micahd72556 жыл бұрын
    • They didn't record these in 1 day?

      @laksitowp@laksitowp3 жыл бұрын
    • It looks like they recorded these videos in one day.

      @mvisperas@mvisperas3 жыл бұрын
    • @@mvisperas so the students are actors?

      @kneerelief577@kneerelief5773 жыл бұрын
    • @@kneerelief577 It means all the videos were shot in one day. Thus, their clothes appear to be the same. In game shows like Jeopardy, the host and the contestants bring different clothes so it appears the next show is actually the next day. The MIT videos are aimed at teaching, not vanity.

      @mvisperas@mvisperas3 жыл бұрын
  • In the merge() function (35:14), if you change the first line of the for while loop to "if left[i]

    @rdwells@rdwells6 ай бұрын
  • Thank you Dr. Ana Bell and Prof. Grimson for the amazing lectures and all involved with OpenCourseWare for this course!

    @RyanScarbrough@RyanScarbrough Жыл бұрын
  • It has been great to follow these lectures. Thanks MIT and ocw

    @nicolasortiz2638@nicolasortiz26386 жыл бұрын
  • Thank you Prof Eric and MIT team for these wonderful lectures !

    @imagenitin@imagenitin3 жыл бұрын
  • Thank you MIT, even though I'm not attending your institute and not paying you any fees, I'm still able to learn from (atleast the so called/ supposedly) the best profs! ❤✌🇮🇳🇮🇳🇮🇳

    @ashu7pathak@ashu7pathak4 жыл бұрын
  • This the best ever cs course I have ever seen on youtube Thank you so much MIT you helped a lot

    @jfbjavaforbeginners4176@jfbjavaforbeginners41763 жыл бұрын
  • Thank you! hopefully the education in Brazil will get better because of your wonderful free courses. God Bless the whole world and you all.

    @ricj9594@ricj95943 жыл бұрын
  • That joke at the end was gold lmao, Prof. Grimson has a wonderful sense of humor

    @dezkightz@dezkightz Жыл бұрын
  • For folks struggling with how recursion code runs, the animation at 40:05 shows step by step what happens for the recursive merge sort code. Study it together with the code, and hope you get a clearer picture of recursion.

    @scorpio19771111@scorpio197711112 жыл бұрын
  • Thanks for your efforts that made such gems available

    @ductive@ductive7 ай бұрын
  • I am addicted to Dr. Grimson’s lectures

    @user-su8rr3cr7k@user-su8rr3cr7k2 жыл бұрын
  • professor Eric has been writing recursive solutions the whole course, so this time I spent 3 hours writing a recursive merge sort to find out it wasn't necessary to do it recursively,

    @ali51717@ali517175 жыл бұрын
  • Thank you for these lectures! Very helpful for a highschool student interested in computer science.

    @amishakandi8450@amishakandi84503 жыл бұрын
  • amazing lecture! I am so thankful this is available to us!

    @OliviaLearns@OliviaLearns2 жыл бұрын
  • Thank you MIT u guys are doing a great job ... This video made my learning easy in lockdown 🙏🙏

    @kirangajjala7148@kirangajjala71484 жыл бұрын
  • what an absolutely fantastic lecturer

    @theguildofsilence@theguildofsilence2 жыл бұрын
  • Selection sort is like the opposite of bubble. In bubble after every loop we find the maximum one and put it at the end, in selection sort we just find minimum after each loop. If it was c++ we could’ve written len(L)-j for range of j in 15:07

    @programmer1010@programmer1010 Жыл бұрын
  • The proffessor's presentation is poetry 😎

    @danielkinyanjui5296@danielkinyanjui52963 жыл бұрын
  • Amazing lectures! Thanks OCW. Also, what should be the next course that I should take after this? (considering I want to get good at the use of data structures and algorithms)

    @devesh3648@devesh36484 жыл бұрын
  • Thank you MIT and thank you Prof. Grimson!

    @rossgaller3662@rossgaller36624 жыл бұрын
    • more like geller

      @shittyworld@shittyworld3 жыл бұрын
  • love this lecture, very interesting!! thank you so much for the videos, now... to give all of this some good use =P

    @darianharrison4836@darianharrison48366 жыл бұрын
  • great explanations!

    @tycho103@tycho1035 жыл бұрын
  • a very impressive lesson.

    @bingchengduan7361@bingchengduan73615 жыл бұрын
  • How is this only 125k views and a guy talking about pokemon cards has over 3 million views? Can't really comprehend how this amazing lecture is posted for free on youtube and ppl are not watching it (or at least as much as it should be watched )

    @danciulescurazvan1047@danciulescurazvan10472 жыл бұрын
  • Thank you MIT!

    @kooser6@kooser64 жыл бұрын
  • thanks a lot.Very interesting and livefull lections for self education

    @OmigosTV@OmigosTV3 жыл бұрын
  • Thank you MIT

    @fernandomachado7795@fernandomachado77953 жыл бұрын
  • thank you ,mit

    @akbarrauf2741@akbarrauf27417 жыл бұрын
  • I really liked your sense of humor

    @YoungLink51423@YoungLink514232 жыл бұрын
  • Thank you professor for teachings

    @PankajKumar-ji1ig@PankajKumar-ji1ig2 жыл бұрын
  • Much thanks to OCW

    @ibradalmar3764@ibradalmar37643 жыл бұрын
  • Thank you MIT.

    @arjunsagar130@arjunsagar1304 жыл бұрын
  • Thank you so much sir and ma'am!!

    @njexictfan@njexictfan Жыл бұрын
  • Best professor ever!!!

    @annebortoli@annebortoli2 жыл бұрын
  • Very informative, thank you.

    @jadenmax679@jadenmax6794 жыл бұрын
  • Made My Life! Thanks Sensei!

    @codesha@codesha3 жыл бұрын
  • love this dude

    @wewantjeremy@wewantjeremy11 ай бұрын
  • "And we deliberately admit students of different heights so John can do this demo" lol, love these lectures!

    @inflem9860@inflem98602 жыл бұрын
  • A BIG THANKS TO MIT.

    @chands.3207@chands.32073 жыл бұрын
  • i love this dude man

    @tarekghosn3648@tarekghosn36482 жыл бұрын
  • thanks mit!!!

    @MrSrijanb@MrSrijanb6 жыл бұрын
  • Great lectures and great lecturers. And I liked the jokes :) Thank you.

    @HoudekM@HoudekM5 жыл бұрын
  • 2:53 linear search (mentioned) is not the same as sequential search (what is meant here)

    @dve845@dve8454 жыл бұрын
  • selection sort around 18:00

    @amywang8407@amywang84075 жыл бұрын
  • I wish I was in this lecture as bubble sort has been given a bad wrap, where: "for j in range(1, len(L)):" should be "for j in range(1, unsort_len(L)):" This would be a simple extension to the use of "swap" as "new_len". This saving was even observed in the lecture. Also, it would have made a very informative demonstration of quick_sort out on the steps on such a nice day. Merge sort also requires many storage allocations, which can be expensive and is another cost to consider with "compares", "swaps" and "allocates". Those steps would have been a great location for any divide and conquer sort, eg shell, merge or quick, and especially to demonstrate their difference.

    @johncampbell7868@johncampbell78683 жыл бұрын
  • Thank you very much. From Vietnam ^^

    @hhg1560@hhg1560 Жыл бұрын
  • I think bubble sort print statement should be right after the if statement

    @user-kc1hq9rk1t@user-kc1hq9rk1t5 жыл бұрын
  • what a closure!

    @user-kv8oh8lx7y@user-kv8oh8lx7y2 жыл бұрын
  • Thank you so much.

    @abigiyatadesse2672@abigiyatadesse2672 Жыл бұрын
  • wooow so fantastic!!!

    @jemsmilner4416@jemsmilner44165 жыл бұрын
  • Thank you !!! it's great

    @user-tn1yb1ne4e@user-tn1yb1ne4e4 жыл бұрын
  • This is awesome

    @cnasir3475@cnasir34754 жыл бұрын
  • Thank you

    @jiayuyan4296@jiayuyan42962 жыл бұрын
  • Thank you very much! 💖🙂

    @xer_t3661@xer_t36612 жыл бұрын
  • The classes are very good. I wish there were more classes to explain the algorithms in detail

    @yamalokesh2657@yamalokesh26573 жыл бұрын
    • there is one more MIT OCW course called introduction to algorithms

      @MrTc1004@MrTc10043 жыл бұрын
    • See ocw.mit.edu/courses/find-by-topic/#cat=engineering&subcat=computerscience&spec=algorithmsanddatastructures to see what we have for algorithms. Best wishes on your studies!

      @mitocw@mitocw3 жыл бұрын
  • Thank you MIT wonderful lectures. @ Eric awful jocks ;)

    @Damoon2543@Damoon25435 жыл бұрын
  • day during quarantine .sounds good

    @adiflorense1477@adiflorense14773 жыл бұрын
  • that was fantastic :)!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

    @sagartomar4210@sagartomar42105 жыл бұрын
  • He's actually quite funny

    @sciencethings5731@sciencethings57314 жыл бұрын
  • I feel like Prof. Grimson's true calling was to be a comedian. The dude is really funny!

    @nicholasestrella339@nicholasestrella3392 жыл бұрын
  • 34:42

    @subhasaha8988@subhasaha89886 жыл бұрын
  • 42:12 merge isn’t logn iterations its at least n iterations and at most 2n iterations. You can see at 39:49 that number of prints(iterations) isn’t logn. 37:32 we aren’t cutting down the problem in half, it’s a tree 40:33. It’s logn levels of iterations(not iterations themselves) where iterations at each level together have O(n) complexity(cost of each step(iteration) is O(n) but turns out that cost of steps at same level of a tree is also O(n) 41:24. He just mixes levels with steps 42:04 Normally what we do is we multiply number of steps(O(n->2n)) to their complexity(O(n)) but in this case we use the fact that at each LEVEL of a tree sum of conplexity of steps is O(n). So number of LEVELS in a tree (O(logn)) multipled with each level’s complexity(O(n)) = O(nlogn)

    @programmer1010@programmer1010 Жыл бұрын
  • This is amassing lecture . Please can you say where the first 11 lectures .

    @balanceyourmind5674@balanceyourmind56743 жыл бұрын
    • Here's the playlist for the series: kzhead.info/channel/PLUl4u3cNGP63WbdFxL8giv4yhgdMGaZNA.html. For more info, see the course on MIT OpenCourseWare at: ocw.mit.edu/6-0001F16. Best wishes on your studies!

      @mitocw@mitocw3 жыл бұрын
  • 15:25 better turn the meaning of the swap flag upside down ... if you swap things set swap to True

    @dve845@dve8454 жыл бұрын
  • For anyone watching this as a beginner and want to learn more computer science courses, here is the list of free courses through which you can learn sequentially - github.com/ossu/computer-science

    @ankurg132@ankurg1323 жыл бұрын
    • Very useful. Thanks!

      @hicham5770@hicham57703 жыл бұрын
  • “And we deliberately admit students of different height so we can do this demo”Hilarious 😂. I really appreciate your jokes, Professor !

    @anonymous.youtuber@anonymous.youtuber2 жыл бұрын
  • are there lectures after this.?

    @kiit-etc-etc-qi4mc@kiit-etc-etc-qi4mc6 жыл бұрын
    • No more lectures after this one. See the course on MIT OpenCourseWare for more details at ocw.mit.edu/6-0001F16.

      @mitocw@mitocw6 жыл бұрын
    • there is a follow up course which is 6.0002

      @konet1440@konet14406 жыл бұрын
  • why was my college not showing this kind of example

    @samuelmurmu3163@samuelmurmu31633 жыл бұрын
  • the playlist link please !!!!

    @labrecheabdelatif7188@labrecheabdelatif71885 жыл бұрын
    • kzhead.info/channel/PLUl4u3cNGP63WbdFxL8giv4yhgdMGaZNA.html

      @mitocw@mitocw5 жыл бұрын
  • ​​0:00:00 Review 0:02:54 0:04:00 0:06:10 0:08:26 Sorting will do you good 0:12:32 ​BOGO sort 0:13:58​ Bubble sort 0:15:58 0:18:25 selection sort 0:20:00 0:22:02 0:23:50 ​0:26:00 0:27:38​ Merge sort 0:30:00 0:32:26 0:34:28 ​0:36:26 ​0:38:12​ 0:40:02 0:42:00 ​0:44:00 ​ 0:46:10 ​What do computer scientist do 0:47:06

    @user-fl7vs4ed6l@user-fl7vs4ed6l3 жыл бұрын
  • Is it required at MIT that profs wear the same outfit for every lecture, or is that just a consequence of filming for the video series?

    @McAwesomeReaper@McAwesomeReaper8 ай бұрын
  • Please provide algorithms course for c++

    @gauravshukla5203@gauravshukla52034 жыл бұрын
    • go to website

      @mohamedrafat3466@mohamedrafat34664 жыл бұрын
  • i gave applause without him telling

    @tombrady7390@tombrady73903 жыл бұрын
  • is there any final exam for this course (6.001) ?

    @shittyworld@shittyworld3 жыл бұрын
    • Looking at course on MIT OpenCourseWare ( ocw.mit.edu/6-0001F16 ), it doesn't look like it. We do know that the equivalent of 6.001 will be starting on EdX in late August (26th). It will have a final exam (which can even be graded if you sign up for a certificate): www.edx.org/course/introduction-to-computer-science-and-programming-7. There is an older version that has an exam (with solution) but it is based on an earlier version of Python and might not be as helpful: ocw.mit.edu/courses/electrical-engineering-and-computer-science/6-00sc-introduction-to-computer-science-and-programming-spring-2011/unit-3/final-exam/

      @mitocw@mitocw3 жыл бұрын
  • Raymond Hettinger would have a bird if he saw the abomination at 3:58

    @maninarush2112@maninarush21125 жыл бұрын
  • All classes included?

    @raihantanvir8880@raihantanvir8880 Жыл бұрын
    • Yes. For more info and materials, see the course on MIT OpenCourseWare at: ocw.mit.edu/6-0001F16. Best wishes on your studies!

      @mitocw@mitocw Жыл бұрын
  • Great though difficult ~~

    @dongguodan2128@dongguodan21285 жыл бұрын
  • For explanation + implementation + Key points List and short notes on all sorting algorithms with doubt support : kzhead.info/sun/mNmFXaijaYKGmq8/bejne.html All English Videos have been uploaded by 25th June 2020 and from now hindi series will start.

    @yourtechbuddy101@yourtechbuddy1013 жыл бұрын
  • 34:30 what programming language is this ??

    @061_arsh@061_arsh2 жыл бұрын
    • Python (v3.5). For more information and materials, see the course on MIT OpenCourseWare at: ocw.mit.edu/6-0001F16. Best wishes on your studies!

      @mitocw@mitocw2 жыл бұрын
  • 👏👏👏👏

    @BenyNotNice@BenyNotNice3 жыл бұрын
  • I really hope he is my cs professor, such an adorable person

    @seanliu3549@seanliu35494 жыл бұрын
  • 20:00

    @mathabahassan3471@mathabahassan34712 жыл бұрын
KZhead