CISC 621 Agorithm Design and Analysis -- midterm review sheet

  • Oct 30: midterm Topics: sample questions:

    Questions are likely to be "affinity" questions or "compare and contrast" questions.

    1. What do these three items all have in common. What aspects do two of them share but the third not?

      mergesort, heapsort, and quicksort

    2. of an algorithm, it's

      worst case time, average case time, expected time

    3. randomized-select, randomized-quicksort, introspective-sort

    sample answers:
    1. All three are O(n*lg(n)) sorting algorithms (if you take average case time for quicksort).

      Merge and heap share O(n*lg(n)) worst case time.

      heap and quick share being in place, i.e. O(1) extra memory.

      merge and quick share being divide and conquer algorithms.

      ...

    2. All three concern considering all inputs of a given size n. and estimating something about the times used by algorithm on all those inputs of size n.

      expected and worst case share being applicable randomized algorithms

      average and worst case share being applicable to normal deterministic algorithms.

      expected and average share being averages of a set of many times, whereas worst case is about an extreme in the set of times. This is since expected time is average over not only the inputs of size n, but also over the set of all possible random sequences of bits used by the algorithm.

    3. all three use randomized-partition.

      rqsort and introsort share being sorting algorithms and having the same expected run time, which is O(n*lg(n)),

      rsel and rqsort share having worst case run time of O(n2).

      rsel and intro share nothing I can think of that rqsort doesn't also share. I suppose both can be considered to be variations stemming from rqsort. rsel is almost identical to rqsort except that you recursively process only one half of the partition instead of both. introsort is almost identical to rqsort except that you turn to insertion sort if the size gets low (around 16) and you turn to heapsort if the recursion depth gets too deep. It is this latter property that gives introsort O(n*lg(n)) worst case time.

    Answers are penalized if (1) they contain plain wrong assertions, or (2) they contain insufficiently much correct information, or (3) they are expressed to incoherently to understand.

    Generally we are very forgiving of awkward modes of expression as referred to in (3). However there is a close correlation between clear thinking and clear expression and I urge you to put effort into ways of expressing points clearly and precisely.