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. Also look at old midterm and final exams on blackboard, under the 'Course Library' tab. Fill out the table of time complexities.
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
, 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
- Implement function objects and use them in STL algorithms, such as
sort
.
- Implement iterators
- Solve problems using recursive functions
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
- You may need to use the formula for the sum of a geometric series
- Remember that
alogan = n
- Given an expression, give its asymptoticcc time complexity in terms of Big-O
- 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 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
- Analyze the time compelxity of recursive functions
Stacks and queues
- Implement a circular array and give the time complexity for operations on it
- 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
Binary trees
- Derive the minimum possible height of binary trees and also trees where any node can have a maximum of
k
children, for some value of k
- Given a sequence of operations, show the state of a Binary Search Tree
- Implement common operations a binary search tree
- Derive the time complexity for common operations on a Binary Search Tree
- Give the order in which nodes of a binary tree are visited by each of the following traversals: (i) inorder, (i) preorder, (iii) postorder, and (iv) level order
Applications
- Given an application, give the time complexities of relevant operations using different containers, and suggest a suitable one
Last modified: 6 Oct 2011