Default Style CS577 Style CSL Style

Lecture Questions

Euclid's Algorithm

  • Q: How do we know Euclid's Algorithm gives the correct answer?
  • Q: For Euclid's game, if you begin with m > n, do you generate all positive integers greater than m?
  • Q: In Euclid's game, should you be player 1 or player 2?
    Claim: # number of possible values = (larger value/ gcd). Why is this claim correct?

Old World/New World Problems

  • Q: For the old world problem, what are the safe combinations we can get from the initial state?
  • Q: How many valid configurations are there for the old world problem?
  • Q: In the new world problem, one thought is we can have the fastest person always running back and forth between sides. However, there is a faster method for crossing. How can we get them across faster?
  • Q: Why isn't the "fastest person" method the best strategy?
  • Q: How could we write an algorithm for the new world problem?

Insertion Sort Analysis

  • Q: In the case of Insertion Sort, how many comparisons are needed in each of these situations?
    • location i
    • location i-1
    • location i-2
    • location 2
    • location 1

Recurrance Relations

  • Q: In pancake flipping, how many flips are there in the worst case? What is the worst case scenario for 4 pancakes?

Pancake Flipping

  • Q: How many flips are there in the worst case for 3 pancakes?
  • Q: What is the worst case scenario for 4 pancakes?
  • Q: How many distinct, worst-case inputs are there for n?

Closest Pair Problem

  • Consider a brute force approach to solving this problem.
    Q: Can we do better?

Quick Sort and Merge Sort

  • In looking at an example of a 6 element array in reverse sorted order, we determined it to be a worst case scenario for Quick Sort.
    Q: Is reverse sorted order always a worst case?

Topological Sorting

  • Q: Given a directed, acyclic graph (DAG) can we find a linear ordering that respects the graph ordering?

Binary Mask and Gray Codes

  • Q: How would you prove that using squashed order to generate all subsets works?
  • Q: Given n, is there always an n-bit Gray Code? How would you prove it?

Convex Hull Problem

  • Q: How do we turn a point set into a polygon?
    Claim: A point set can be turned into the vertex set of a polygon (simple polygon).
  • Q: How do we turn a collection of points into a simple polygon?
  • Q: In a Graham Scan, what condition causes us to push/pop from the stack?

Line Segment Intersection

  • Q: If the number of intersections is small [O(n) or O(nlogn)] is there always an algorithm that is better than brute force?

Linear Selection Algorithms

  • Q: For the problem of finding the k smallest element of n orderable keys, can we get a linear algorithm?

Heap properties

  • Q: Where is the minimum value in a minheap?
  • Q: Where is the 2nd smallest value in a minheap? 3rd?
  • Q: Where is the kth smallest value in a minheap?
  • Q: Given n elements, how do we build a heap?

Analysis for Linear Selection Algorithm

  • In the inductive (strong) proof of the induction hypothesis to show that M(n) <= c2n, we derived that M(n) <= c2 * 9n/10 + 6c2 + an <= c2.
    Q: Can we choose c2 so that this is true?

Decision Trees

  • Q: How tall could a decision tree with n! leaves be?
  • Q: How big is log2(n!)?
  • Q: How do we use a decision tree model to prove a lower bound on the average path length?

String Matching

  • We discussed 4 steps to a string matching problem in class.
    Q: How do we efficiently preprocess the given pattern so that steps 1-4 are easy?
  • Q: How do we efficiently preprocess the given pattern to build a table for the alphabet to be used in the problem.

Back to CS577 Home