Lec 10 | MIT 6.00 Introduction to Computer Science and Programming, Fall 2008



Lecture 10: Divide and conquer methods, merge sort, exceptions

Instructors: Prof. Eric Grimson, Prof. John Guttag

View the complete course at: http://ocw.mit.edu/6-00F08

License: Creative Commons BY-NC-SA
More information at http://ocw.mit.edu/terms
More courses at http://ocw.mit.edu

source

32 thoughts on “Lec 10 | MIT 6.00 Introduction to Computer Science and Programming, Fall 2008

  • January 15, 2022 at 4:07 am
    Permalink

    I have a question. Professor Grimson said, that the exception raised inside the 'getGrades' function wasn't an IOError, but in fact it was an IOError, wasn't it? Because otherwise It wouldn't t raise the error tot the 'try' call. Furthermore, the " 'Could not open', fname " message would only be printed if it got inside of the except clause, which would only happen if the error was specifically an IOError, right? I got a bit confused at this part. Tks

    Reply
  • January 15, 2022 at 4:07 am
    Permalink

    17:09 to elaborate on the complexity of each level, the bottom level merging the singleton lists has N/2 steps, it keeps getting larger until the final level with N-1 steps merging the final 2 sorted lists.

    Reply
  • January 15, 2022 at 4:07 am
    Permalink

    Is there anyone who solve the psets in this course???
    Having listening to this courses, I'm trying to solve psets uploaded on mit's page.
    but I cannot find any answers to this problems.
    How you solve them?? Since there is no answer or explanation, I cannot check my solutions to problems. ㅜ.ㅜ
    If you know the way to know the solution, please let me know!!

    Reply
  • January 15, 2022 at 4:07 am
    Permalink

    Great intro into some basic algorithms in CS. My first course in programming sucked in comparison; we didn't learn anything beyond bubble sort and not even binary search.

    Reply
  • January 15, 2022 at 4:07 am
    Permalink

    I could not get this to work. I get the following error.
    >>> 
    [1, 4, 3, 6, 5, 2, 8, 7]
    [1, 4, 3, 6]
    [1, 4]
    [1]
    [4]
    merged [1]
    [3, 6]
    [3]
    [6]
    merged [3]
    merged [1]
    [5, 2, 8, 7]
    [5, 2]
    [5]
    [2]

    Traceback (most recent call last):
      File "C:Python27mergesort.py", line 36, in <module>
        mergesort(test)
      File "C:Python27mergesort.py", line 30, in mergesort
        right = mergesort(L[middle:])
      File "C:Python27mergesort.py", line 29, in mergesort
        left = mergesort(L[:middle])
      File "C:Python27mergesort.py", line 31, in mergesort
        together = merge(left,right)
      File "C:Python27mergesort.py", line 12, in merge
        result.append(right[j])
    MemoryError

    Can  anybody help?

    Reply
  • January 15, 2022 at 4:07 am
    Permalink

    Is there anybody who could help me. I have written all the codes i.e def merge() and def mergesort(). But when i run it with test the output gets stuck with merge. I mean it divides but in merge it gives me error says typeerror 'none type'. Cd you please tell me what is the code for list test and def mergesort(test).
                                   thank you all    

    Reply
  • January 15, 2022 at 4:07 am
    Permalink

    it is interesting how the number of view per video on comp. prog. decrease as the lessons progress, It sucks how many people really loose interest so quickly, damn. Great videos. Thanks MIT.

    Reply
  • January 15, 2022 at 4:07 am
    Permalink

    1) because of the speed… When I do a simple copy paste in linux I have 31Mb/s… When I do it in windows only 8-9Mb/s… Which one is better? 🙂
    2) you don't have to pay for it, and everything works without drivers (you need to install video drivers for 3D aplications – it does that for you with a click)
    3) no viruses
    4) you want to play, pay for software use windows / you want speed and not pay every year for antivirus and software use linux 🙂

    Reply
  • January 15, 2022 at 4:07 am
    Permalink

    YouTube's interactive transcript seems to miss on context a little easier than you'd think. for instance, at 30:01 the transcript says "root force…" and the professor had actually said "root force". It also seems to have trouble with one my favorite YouTuber's voice. LOTS of syntax errors in THAT transcript.

    Reply
  • January 15, 2022 at 4:07 am
    Permalink

    Macs – coz people have the cash. Linux – cause it's highly-legally-customizable. You can (and are allowed to) practically change each and every damn thing about it (if you want to). Oh and no viruses (in both).

    Reply
  • January 15, 2022 at 4:07 am
    Permalink

    Just watching the whole series from Australia – great lectures. However my classic problem with university was typified at 02:50 – me concentrating hard, hot girl walks by in hot pants, my eyes turn to spirals and I lose concentration for 5 mins. Education should always be on you tube with camera focussed hard in on the lecturer. Its the only way it can be done, certainly for me anyway. Does this constitute a recognised attention deficit disorder I wonder? Sounds flippant but its a real problem

    Reply
  • January 15, 2022 at 4:07 am
    Permalink

    windows rocks. macs and linux are very good for programmers because of the interface

    Reply
  • January 15, 2022 at 4:07 am
    Permalink

    great if u dont have much money to study in mit but u can attend classes for free

    Reply
  • January 15, 2022 at 4:07 am
    Permalink

    When I try to do the insert function after I do the create function I get a type error: TypeError: object doesn't support item assignment
    Can someone please explain what is going wrong?

    Reply
  • January 15, 2022 at 4:07 am
    Permalink

    @kopilatis10 try checking the OCW website – you might get lucky by findng the prinout there.

    Reply
  • January 15, 2022 at 4:07 am
    Permalink

    @jerricogomez its not a space error..its the indentation of subsequent blocks of code that python forces u to use…to get used to it use good text editors as VIM etc..and google around about vim's python feature…

    Reply
  • January 15, 2022 at 4:07 am
    Permalink

    These videos make programming far more interesting and easy to understand than anything else I've tried to learn from. Thank you, MIT.

    Reply

Leave a Reply

Your email address will not be published.