CS340 Final Exam Review
Chapter 1
Principles of object oriented programming o Classes, Types, Objects o Inheritance o Overloading o Overriding o Polymorphism
You will be required to write simple code or pseudo code on a piece of paper. Most important things: o Algorithm: your algorithm has to be clear o Your algorithm has to include every step that the computer needs to follow to execute the program o You do NOT have to:
Present syntactically perfect code
Know all the libraries in the java API
Example: o Write a method that will reverse an integer array. You need to write this method in Java or pseudo code. You have to explicitly write all the steps that need to be executed to reverse the array. Write a main method to call this method. o Write a method that will flatten a binary search tree to an array. You need to write this function in Java or pseudo code. You have to explicitly write all the steps that need to be executed to flatten the tree.
Chapter 2
Lists o Array o Linked o Double Linked o Basic Methods: add, remove, get, set o Complexity? (Big-Oh)
Why do we prefer one list implementation over another one?
o Memory o Speed: we measure speed with worst case complexity, i.e., Big-Oh
Big-Oh complexity of your code: what is the bottleneck in a particular piece of code?
Memory hogs: which implementations, calls, parts of code take more memory? How can we make them more efficient?
Performance questions: o Why use linked list instead of:
Array
Tree
Stack
Queue
Chapter 3
Stack: o How can you implement a stack? o Which methods are implemented in the stack interface? o What is the complexity of these methods? (Big-Oh)
Performance questions: o Why use stack instead of:
Array
Tree
Queue
Chapter 4
Queue: o How can you implement a queue? o Which methods are implemented in the queue interface? o What is the complexity of these methods? (Big-Oh)
Queue applications
Performance questions: o Where would you prefer to use a queue and why?
Chapter 5
Recursion: o Write an algorithm using recursion. o What is the complexity of a specific recursive version of an algorithm? (Big-Oh) o What is the drawback of recursion?
o What are the major applications of recursion in data structures?
Binary Search Tree
Graph depth first search
Other?
Chapter 6
Binary Search Trees: o How can we implement a BST? o Why are BSTs useful? o What are the pros and cons of using a BST in a specific implementation? o What is the Big-Oh of BST basic methods such as:
Pre-order traversal?
In-order traversal?
Post order traversal
Get
Insert (put)
Remove
Heaps and Priority queues? o How can you implement a heap, priority queue? o How is the heap organized? How do we restore the heap property? o Algorithm to insert to a heap, remove from a heap. o MinHeaps, MaxHeaps and how to construct these. o Why is a heap, priority queue useful? o What are the properties of a heap? o Performance questions: when would you prefer a heap instead of…
Chapter 7
Sets o Why are sets useful? o How can you implement a set? o Can you have duplicate elements in a set? o What are the basic characteristics of a set?
Maps o What is a map? o Where do we use maps? o Map application: based on what criteria would you select a key for the following application. Which field would you use as a key:
Textbook title, book, author, ISBN, year, publisher
Player’s name, uniform number, team, position
Computer manufacturer, model number, processor, memory, disk size
Department, course title, course id, section number, days, time, room
Hash Tables o Hash Table methods: get, put, remove, rehash o Hash Table implementations o What are the pros and cons of each implementation o What is the complexity of each hash table method o Why use hash tables? Why not use hash tables?
Chapter 8
Sorting Algorithms: Selection, Bubble, Insertion, Quick, Merge o Performance: big-Oh complexity o Why use one algorithm over another one? o Which algorithm is best for:
Random data
Reversed data
Almost ordered data
Strings, ints, other objects
Sample Questions:
1.
When would you use a binary tree vs. a hash map (hash table)?
2.
Design an algorithm to retrieve median a linked list.
3.
Write a function which will flatten a binary tree into an array.
4.
Reverse a singly linked list.
5.
Verify correct order of parentheses in a given expression.
Websites to look for interview questions: http://commoninterview.com
http://www.glassdoor.com/ http://www.careercup.com/