Skip to content

Week 8 Notes

  • Lab 07: Object-Oriented Programming, Linked Lists, and Trees (27/07/22)
  • Discussion 07: Object-Oriented Programming, Linked Lists (27/07/22)
  • Reading Ch. 2.9: Recursive Objects (31/07/22)
    • Recursive object: an object of some class has an attribute value of that same class
    • Sets: (aside from list, tuple, and dictionary) a built-in container type. Duplicate elements are removed upon construction. Unordered, mutable collections
      • Set comprehension: {3, 2, 1, 4, 4} → {1, 2, 3, 4}
      • Membership (in operator), length computation (len()). union (union()), intersection (intersection())
        • <set1>.intersection(<set2>)
      • Set comparison: isdisjoint(), issubset(), and issuperset()
      • add(), remove(), discard(), pop(), clear(), update(),…
      • Cannot contain mutable data types
  • Lecture 20: Composition (31/07/22)
    • A @<attribute>.settor decorator on a method designates that it will be called whenever that attribute is assigned. <attribute> must be an existing property method (decorated with @property decorator)
  • Reading Ch. 2.8: Efficiency (31/07/22)
    • Efficiency: computational resources used by a representation or process (time and memory)
      • Can be measured with how many times some event occurs, e.g: a function call
      • Space requirements of a function: An environment is active if it provides the evaluation context for some expression being evaluated. An environment becomes inactive whenever the function call for which its first frame was created finally returns
    • Memoization: A memoized function will store the return value for any arguments it has previously received
    • Order of growth: expresses how the resources of a process grow as a function of the input
      • Constants do not affect the order of growth:
      • The base of a logarithm does not affect the OOG: ,
      • The OOG of an entire nested process is a product of the number of steps in the outer and inner processes
      • Lower-order terms are always ommited from OOG, since the highest-order term will eventually dominate the total
      • Common categories: constant, logarithmic, linear, quadratic, exponential
  • Lecture 21: Efficiency (31/07/22)
  • Supplemental Discussion 08: Efficiency (31/07/22)
  • Lecture 22: Decomposition (31/07/22)
    • Modular design of large programs → separation of concerns
    • sorted(iterable, /, *, key=None, reverse=False)
      • Return a new list containing all items from the iterable in ascedding order
      • A custom key function can be suppled to customize the sort order, and reverse reverses
  • Guerrilla 03: Linked Lists, Object-Oriented Programming (31/07/22)