Topics: Object Oriented Programming: dunder methods, examples We start with a review of classes and methods from last lecture. Class vs. instance of a class. All review for me, of course, but I like to observe how they teach it. Dunder methods review. Why OOP and bundling the data in …
Topics: Object Oriented Programming: data abstraction, class def, class instances, methods More review for me. I don’t mind reviewing though. We start by defining an object, along with examples. Advantages of OOP Bundle data into packages together with procedures that work on them through well-defined interfaces Divide and conquer …
Topics: Recursion: Fibonacci, Fibonacci with a dict, recursion on non-numerics, recursion on lists, Towers of Hanoi (extra) We start by reviewing fibonacci and tracing through the function call graph. Recursion in general is review for me, I still think this lecture is good for me to digest. After doing another …
Search Module In this module, we will expand on generative recursion and work on search problems, which are a category of problem solving that can be solved by generating the space of all possible paths from a given state and traversing that space until a solution is found. We will …
This chapter is about infinite sets and some challenges in proving things about them. There has been a truly astonishing outcome of studying infinite sets. Their study led to the discovery of fundamental, logical limits on what computers can possibly do. For example, in a later section, they use reasoning …
Topics: Recursion: iteration vs. recursion, inductive reasoning Recursion is review for me. I like the example she gave with the student asking professor, TA, and LA to regrade. Big idea: “Earlier” function calls are waiting on results before completing. Went over some more examples of recursion. When to use recursion …
Recursive data - define something in terms of simpler version of the same thing. Recursive data types play a central role in programming, and induction is really all about them. Recursive data types are specified by recursive definitions, which say how to construct new data elements from previous ones. Along with …
Finished the problem set in about an hour. It was a good exercise. Here is my solution along with test case results: My solution: # Purpose: Check for similarity between two texts by comparing different kinds of word statistics. import string import math ### DO NOT MODIFY THIS FUNCTION def load_file(filename …
Generative Recursion Module Generative recursion is in many ways similar to structural recursion: a function calls itself recursively (or several functions call themselves in mutual recursion). For the recursion to terminate, each recursive call must receive an argument that is in some way "closer to the base case". That is …
Topics: Dictionaries: keys, values, mutability, iteration over a dict, examples This is review for me, I am familiar with dictionaries. I guess one new thing I learned is that dictionary keys must be immutable or technically hash-able objects. Although in practice this is obvious.