Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Class 26: Complexity and Subclassing

Class 26: Complexity and Subclassing

cs1120: Introduction to Computing
Explorations in Language, Logic, and Machine
University of Virginia, Spring 2016

http://xplorecs.org/class26

Class 26:
Problems and Complexity
Sorting
Multiplying
Go
Subclassing

David Evans

April 01, 2016
Tweet

More Decks by David Evans

Other Decks in Programming

Transcript

  1. Class 26: Complexity and Subclassing Introduction to Computing: Explorations in

    Language, Logic, and Machines cs1120 Spring 2016 David Evans University of Virginia
  2. Complexity of Sorting Facts Known: 1. There exists a sorting

    algorithm, best-first-sort, that has worst-case asymptotic running time in (N2) where N is the number of elements in the input list.
  3. Complexity of Sorting Facts Known: 1. There exists a sorting

    algorithm, best-first-sort, that has worst-case asymptotic running time in (N2) where N is the number of elements in the input list. 2. It is not possible to sort a list of elements, without at least looking at each element once.
  4. Complexity of Sorting Facts Known: 1. There exists a sorting

    algorithm, best-first-sort, that has worst-case asymptotic running time in (N2) where N is the number of elements in the input list. 2. It is not possible to sort a list of elements, without at least looking at each element once. How can we make progress to a tight () bound for the problem complexity?
  5. Chapter 5 – Sorting • 5.1. Combinatorial Properties of Permutations

    • 5.1.1. Inversions • 5.1.2. Permutations of a Multiset • 5.1.3. Runs • 5.1.4. Tableux and Involutions • 5.2. Internal sorting • 5.2.1. Sorting by Insertion • 5.2.2. Sorting by Exchanging • 5.2.3. Sorting by Selection • 5.2.4. Sorting by Merging • 5.2.5. Sorting by Distribution • 5.3. Optimum Sorting • 5.3.1. Minimum-Comparison Sorting • 5.3.2. Minimum-Comparison Merging • 5.3.3. Minimum-Comparison Selection • 5.3.4. Networks for Sorting • 5.4. External Sorting • 5.4.1. Multiway Merging and Replacement Selection • 5.4.2. The Polyphase Merge • 5.4.3. The Cascade Merge • 5.4.4. Reading Tape Backwards • 5.4.5. The Oscillating Sort • 5.4.6. Practical Considerations for Tape Merging • 5.4.7. External Radix Sorting • 5.4.8. Two-Tape Sorting • 5.4.9. Disks and Drums • 5.5. Summary, History, and Bibliography
  6. Complexity of Multiplying Facts Known: 1. There exists a multiplication

    algorithm, ft-multiply, that has worst-case asymptotic running time in (N2) where N is the size (number of digits) in the input.
  7. Complexity of Multiplying Facts Known: 1. There exists a multiplication

    algorithm, ft-multiply, that has worst-case asymptotic running time in (N2) where N is the size (number of digits) in the input 2. It is not possible (in the worst case) to multiply two numbers, without at least looking at each digit.
  8. Complexity of Multiplying Facts Known: 1. There exists a multiplication

    algorithm, ft-multiply, that has worst-case asymptotic running time in (N2) where N is the size (number of digits) in the input 2. It is not possible (in the worst case) to multiply two numbers, without at least looking at each digit.
  9. Complexity of Multiplying Facts Known: 1. There exists a multiplication

    algorithm, furer-multiply, that has worst-case asymptotic running time in (N log N 2O(log* N)) where N is the size (number of digits) in the input 2. It is not possible (in the worst case) to multiply two numbers with less than (N log N) operations (“under certain restrictive conditions”).
  10. Inheritance is using the definition of one class to implement

    another class. SquareBoard inherits from Board. SquareBoard is a derived class of Board. SquareBoard is a subclass of Board. The base class of SquareBoard is Board. The superclass of SquareBoard is Board. Board SquareBoard These all mean the same thing. GameState
  11. The base class of TicTacBoard is SquareBoard. TicTacToeBoard is a

    subclass of GameState, Board, SquareBoard Board SquareBoard GameState TicTacToeBoard
  12. Charge • Updates to provided code (sync your forked repository

    to get them – will provide more detailed directions in Notes) • Project 5 – break the problem down into small steps that you can test as you develop