CS313E Midterm Study Guide:
Fall Semester, 2012
This looks like a lot of material, but if you've been in class, paying
attention and doing the assignments, you should be OK. You will not
be asked to reproduce the complicated algorithms and code examples we
showed in class. You will be asked to write simple Python definitions
and classes and to understand the concepts and constructs we've
discussed during the first half of the semester. It's a good idea to
read over the slides several times, paying particular attention to the
questions in purple on the slides. It's also a good idea to review the
quizzes.
----------------------------------------------------------------------
Slideset 1: Introduction
What are the basic components of a computer?
What is the fetch-execute cycle?
Why is binary used in computers instead of, say, decimal?
How are characters represented?
What sorts of things can be represented by bit strings?
----------------------------------------------------------------------
Slideset 2: Basic Python
What are some good features of the Python programming language?
Know how to run Python code interactively and from files.
Be able to use the basic constructs of Python including:
identifiers, variables, string type, int type, float type, bool type,
tuples, lists, dictionaries, arithmetic operators, boolean and
relational operators, assignments, conditionals, loops (for and
while), continue, break, pass, range, functions, import, print, and
input.
Understand what short-circuit evaluation is and what it's useful for.
Understand the difference between mutable and immutable types.
What is stored in Python variables?
----------------------------------------------------------------------
Slideset 3: Turtle Graphics
Understand the basic paradigm of object-oriented (OO) programming.
Be able to understand Python code implementing a class.
Review the CokeMachine and Calculator examples, but you won't be asked
to reproduce any of that code.
Understand the idea of Turtle as a predefined class available for use.
Understand the turtle state attributes and how the turtle is manipulated.
[You don't need to memorize the turtle commands.]
Understand the RGB system of color representation.
----------------------------------------------------------------------
Slideset 4: Classes
Understand the basic paradigm of object-oriented (OO) programming.
Be able to think of programming problems in an OO way.
Understand classes as containing data (attributes) and methods.
Understand the kinds of things class methods can do.
Understand the distinction between instance data/methods and class
data/methods.
Be able to construct simple classes in Python.
Understand what class accessors and mutators do.
Understand how to implement comparison operators (>, <, etc.) on
class instances.
Understand why we want to think of classes as abstract types.
Be able to explain the notion and value of hiding the implementation.
Understand the role of magic methods in Python.
----------------------------------------------------------------------
Slideset 5: Abstract Data Types and Stacks
What is an abstract data type (ADT)?
Why are they useful?
Understand the notion of the interface of an ADT and how it's a
"contract" between the implementor and the user.
Understand the Stack as a LIFO data structure.
What is the Stack interface?
Understand how you might implement a Stack and use it in programming.
In general, should the user care about the implementation?
Understand the three stack applications: bracket matching, postfix
evaluation, infix to postfix translation.
[You don't have to memorize the algorithms. You won't be asked to code
them on the test.]
Understand the three notations: infix, postfix, prefix.
What is the advantage of postfix over infix?
Understand the dictionary data type.
----------------------------------------------------------------------
Slideset 6: Another ADT: Queues
Understand the queue ADT functionality as a FIFO data structure.
Understand the Queue interface, implementation, and use in code.
Understand the usefulness of simulation.
[It would be a good idea to review the Market simulation, but you
don't need to memorize the algorithm; you won't be asked to
reproduce any part of it on the exam.]
Understand the use of randomness in a program and how to do that in Python.
What is event-based simulation?
Understand the idea and utility of inheritance.
How is inheritance implemented in Python?
Be able to implement a new class as a subclass of another.
[I'd suggest studying the Rectangle and Square classes as an example.]
Understand the kinds of methods of the subclass: new, inherited, overridden.
For a subclass, be able to state which methods are in each kind.
Understand the notion of a BoundedQueue and how it inherits from MyQueue.
Understand the notion of a PriorityQueue and how it inherits from MyQueue.
Understand multiple inheritance.
Understand the BoundedPriorityQueue and what it inherits from which
other classes.
----------------------------------------------------------------------
THIS IS WHERE THE SECOND HALF BEGINS
----------------------------------------------------------------------
Slideset 7: Lists
Be familiar with the Python list data type, including the common operations
on lists.
Understand the interface of lists as an abstract data type, including the
operations of: get, add, insert, remove, search, isEmpty, len.
Understand the distinction between a contiguous and a linked implemention
of lists.
Be able to state, for each implementation, whether a method likely has
complexity that is constant, linear, quadratic.
Understand the basic linked list functionalty.
[It is not required that you be able to program it from scratch.]
Understand the distinction between an orderedList and unorderedList, and what
this means for the implementations.
Understand the notion of an iterator and how you'd define an iterator over an
arbitrary class (such as a linkedList).
Why is an iterator sometimes more efficient than a list?
Answer: An iterator is really a generator (using a yield statement). It only
produces the items asked for. So if you only need the first k items of a
list, that's all that's ever produced.
Understand the magic method __getitem__ and what it's for.
Understand the basic concept and utility of doubly linked lists and circular
lists.
Understand the definitions of BucketSort and RadixSort, how they're used,
and the complexity.
----------------------------------------------------------------------
Slideset 8: Recursion
Understand the basic concept of recursion and how to write simple recursive
functions in Python.
What must be true of a recursive function?
What is the purpose of the base cases and recursive cases?
Understand how recursive functions can be very expensive (e.g., naive Fibonnaci).
Understand the relationship between function calls and the system run-time stack.
----------------------------------------------------------------------
Slideset 9: Efficiency
Understand the basic notion of the complexity of an algorithm.
Be able to explain worst case, best case, and average case complexity.
Understand why we typically consider worst case complexity.
[You don't need to know the formal definition of Big-O.]
Understand intuitively why complexity matters.
Understand the sorting problem as an example of complexity analysis.
Understand BubbleSort and InsertionSort.
Understand logarithmic complexity and when it might arise.
Be able to figure out the complexity of small code fragments with loops.
Understand binary search.
Be familiar with the complexity rules of thumb on the last slide.
----------------------------------------------------------------------
RECALL THAT WE DID SLIDESETS 11 AND 10 OUT OF ORDER.
Slideset 11: Hashing
Understand the notion of a direct address table and why it might be
impractical in many cases.
Understand the basic idea of hashing and why it is very efficient.
When is a hashing solution appropriate?
What is a hash function? What properties should it have?
What is the ADT interface for a hash table?
What is the complexity of the functions: find, insert, remove?
What is the complexity of building the hash table?
Understand the notion of a hash key.
What is a collision? Are collisions likely? Why?
Understand the two basic means of dealing with collisions in a hash
table: chaining and open addressing.
For what types of operations is a hash table most appropriate? For which
is it completely inappropriate?
How can you build a hash function for strings?
----------------------------------------------------------------------
Slideset 10: Trees
Understand the meanings of the following related to trees: root, node,
edge, acyclic, parent, children, sibling, ancestor, descendent, leaf,
internal node, subtree, degree, depth.
Understand the idea of an ordered tree versus an unordered tree.
Understand representing arithmetic expressions as expression trees.
Be able to explain the arity of a node in a tree.
Understand the BinaryTreeNode class and its interface.
Understand Binary Tree as a specialization of trees.
What is the interface of the BinaryTree ADT?
Understand the notion of BinaryTree as a "wrappen" on a collection of nodes.
Be able to write code using the BinaryTree and BinaryTreeNode classes.
Understand the algorithm to build a Binary expression tree from a postfix
expression.
Understand the four standard travarsals and their implementations.
Given a tree, be able to show the result of inorder, preorder, postorder,
and level-order traversals.
Understand why all traversals are of linear complexity.
Understand evaluating an expression tree.
Understand the BinarySearchTree (BST) as a specialization of a BinaryTree.
What is the main property of a BST?
Understand the interface of the BST ADT?
What is the average case complexity of search, insertion, remove in the case
of a balanced tree?
What is the worst case complexity and when does it arise?
Understand the implementation of search and insert.
Understand generally how remove from a BST works.
Understand the notion of balanced trees and the idea of re-balancing.
Understand TreeSort and why it has complexity O(n log n).
----------------------------------------------------------------------
Slideset 12: MergeSort and QuickSort
Understand the distinction between mutable and immutable classes and why
that is relevant to sorting "in place."
Understand MergeSort and why it has complexity O(n log n).
Explain why MergeSort is seldom used for "main memory sorts."
Understand the basic idea of QuickSort.
Understand the notion of picking a pivot and partitioning.
Why is the worst case complexity so much worse than average case?
What is the median-of-three stategy for and why does it work?
What is one pass of QuickSort guaranteed to accomplish?
Why might you not want to call QuickSort (or MergeSort) recursively on
very short lists?
----------------------------------------------------------------------