• 150 likes • 163 Views
This exam review covers programming problems, tracing algorithms, and short answer questions on topics such as stack ADT, recursion, sorting, and analysis of algorithms.
E N D
Exam 2 Review CS 3358 Data Structures
Exam Format • 90 Total Points • 50 Points Writing Programs • 25 Points Tracing Algorithms, determining results, and drawing pictures • 15 Points Short Answer • Similar to quizzes and programming assignments • Note: the point values are approximations
Example Programming Problem • Given the ADT for the Stack_3358 at the end of the exam, implement the push, pop, isEmpty and isFull functions.
Example Tracing Problem • Given the following array, what would be the contents after the 4th iteration of a insertion sort? 3 7 2 12 56 1 42 9
Example Short Answer • Why is the quick sort less efficient than the insertion sort for small lists (e.g. n < 20)?
Templates • 10 Points • Why? • Templated functions • Templated Classes • Understand the Stack Fun and Sort’em programs
Analysis of Algorithms (still important) • 8 points • Don’t memorize definition • Does the amount of work depend on the size of the input? • Should be able to rank as faster or slower • Be able to analyze algorithms and code and determine Big O time analysis • Especially most common. O(1), O(n), O(n2), O (log2n) • Look for loops • How fast does the problem shrink?
Stack ADT • 30 points • Understand basic functions • Push • Pop • IsEmpty • isFull • Should be able to implement array or linked list version of stack • Be able to use a stack to solve a problem • How does a stack relate to recursion? • Understand Stack Fun assignment
Queue ADT • 0 Points • Know the basic functions • Enqueue • Dequeue • isFull • isEmpty • Be able to implement circular array-based queue • Be able to implement a linked list version of a queue
Recursion • 25 Points • Understand • Base case • Smaller caller • General case • Will have to write a recursive function • Be able to do time analysis of a recursive function • Understand math stuff and recursive flood fill
Sorting • 35 Points • Algorithms • Will not have to code the sorts • Know the algorithms REALLY WELL! • Will likely have to draw, trace, or produce psuedo-code • Time and space considerations • O(n2) sorts • Selection sort, Insertion sort • O(nlog2n) sorts • Mergesort, Quicksort
Not on this exam • Hashing • Code from book • Only concepts covered in class or on assignments
How to Study • Review the programs. • Rewrite them if you have time (especially the parts you had trouble with) • Look at sorts in a lot of detail. • Look at other recursive functions (linked lists, etc.) • Use the exam for clues on the other problems and for help with syntax. • Don’t stay up late!! Get some sleep and eat a good breakfast.
What to bring • Pencils and erasers • We will provide scratch paper • No calculators