Talk:PyClass

From Noisebridge
Revision as of 21:27, 8 January 2018 by (talk | contribs) (Nick's Python Lesson)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search

Notes on Nick's talk on graphs

  • Introduction to memo'izing with Fibonacci Numbers
  • Counting steps problem, with either 1, 2, or 3 steps at a time on n steps staircase
  • Binary search trees
  • Canonical Dynamic Programming Problems
    • Shortest Path
    • Parenthization
    • Knapsack
    • Towers of Hanoi
    • Edit Distance
    • Eith Queens


fibonacci w/memo'ization

...it's a thing https://www.python-course.eu/python3_memoization.php

class Fibber:
    def __init__(self):
        self.memo = {}

    def fib(self, n):
        if n < 0:
            raise Exception("Oh Snap!")
        elif n < 2:
            return 2
        if n in self.memo:
            return self.memo[n]
        result = self.fib(n-1) + self.fib(n-2)
        self.memo[n] = result

        return result

f = Fibber()
f.fib(10)


how many steps

nick goes up n stairs, he goes up the stairs one, two or three steps at a time, how many steps do they take.

#tripples
class triple_steps():
  def __init__(self):
    self.memo = {}
  def triple_step(self, step):
  if step < 0:
  return 0
...


napsack

Given a set of tuples that represent the weight and value of different goods, cakes in our examples, find the maximum value we can get given a knapsack with a certain weight restriction. Find the point where the value is maximum and the sum of their weight is equal to the total weight allowed by the knapsack. 0/1 means you can not split an item.

#napsack problem


binary trees

https://en.wikipedia.org/wiki/Binary_tree

discussion about nodes, branching structure with a root/parent node, with two children. Traversal orders, in order, pre order, and post order. In order traversal is sorted array.

(talk) 04:27, 9 January 2018 (UTC)