Lecture 14
Midterm review
Notes:
This materials is just meant to give you an idea of important topics. You are still responsible for learning from the following materials:
- Class notes
- Reading assignments
- Review questions
- Material covered in recitation
- Assignments and our assignment solutions
In order to prepare for the midterm, I suggest that after learning the material, you try answering the review questions and homework/recitation assignments.
Important topics
C++
- Use guards in header files
- Implement, use, and compile template functions and classes
- Remember that templates go in header files, and don't compile these files
- Deep copy in classes with dynamically allocated data -- copy constructor, assignment (avoid self copy), destructor
- Using
using namespace std;
- Use common STL containers (
list, vector, deque, stack, and queue, apart from string) and operations, such as: push_front, push_back, pop_front, pop_back, front, back, empty, size, begin, and end.
- Declare and use STL iterators, increment (++) them, and compare with
end()
- IO: File IO, output to stdout, and read from stdin
- Command line arguments
Vectors
- Implement simple vector features:
push_back, pop_back, operator[], (push_front, and pop_front)
- Use simple STL
vector features
- Remember to expand the vector when necessary
- Time complexity of common vector operations
- Implement algorithms to perform binary search and insertion into a sorted vector.
Linked lists
- Implement simple features of singly and doubly linked lists:
push_front, push_back, pop_front, and pop_back
- Implement simple features of self-organizing lists, in particular, a
search method that also performs a self-organization (the self organization scheme may be different from those discussed in class)
- Given a sequence of operations, draw the state of the final doubly linked list, singly linked list, or self-organizing linked list
- Time complexity of common singly and doubly linked list operations
- Use simple STL
list features
Complexity analysis
- You may need to use the formula for the sum of the first
n positive integers, and approximations to the sum of their powers too
- You may need to use the formula for the sum of a geometric series
- Remember that
alogan = n
- Prove big-O properties, such as
O(f1 + f2) = O(max{f1, f2})
- Show that
f(n) = O(g(n)) using the definition (that is, finding c and N), or using properties
- Perform average case analysis, given a probability distribution for the input
- Perform amortized analysis
- Explain how amortized analysis is different from average case analysis
- Derive tight bounds for sums using integration (I will probably not ask a question on this in the midterm; however you should know a good approximation to
Sumni=1 ik for a constant k)
- Derive time complexity for algorithms or nested loops
- Given the time taken by an algorithm on a small input size, and its time complexity, determine the time taken by that algorithm on a larger input size
- Give the time complexities of common set operations, when using doubly or singly linked lists, vectors, or sorted vectors, to represent sets
Deque
- Given a sequence of operations, show the state of the deque, remembering to expand when necessary
- Implement common operations on a deque, such as:
push_front, push_back, pop_front, pop_back, size, empty, and operator[]
- Use simple STL
deque features
- Time complexity of common operations on a deque
Stacks and queues
- Given a sequence of operations, show the state of a stack or a queue, and that of its underlying implementation
- Implement common operations on stacks and queues, using some other suitable container:
push, pop, front, top, size, and empty
- Use simple STL
stack and queue features
- Time complexity of common operations on stacks and queues
- Given a problem, write pseudo-code that uses stacks or queues to solve it
Applications
- Given an application, give the time complexities of relevant operations using different containers, and suggest a suitable one
Last modified: 17 Feb 2009