CS 314 Midterm Review

CS 314 Midterm Review - 16:16 CS314MidtermReview...

Info iconThis preview shows pages 1–6. Sign up to view the full content.

View Full Document Right Arrow Icon
16:16 CS 314 Midterm Review Read this comment Table of Contents ? Big O: Names of Big O classes Given a function for time vs. n, reduce it to Big O. Ranking of Big O: which is better Big O for common algorithms Estimate Big O for some given code log(n) grows slowly Estimate Big O from a log-log plot, from time ratios Linked List: Be able to give result of a call to these functions: Stacks: Using linked list, using array.
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Push, pop Queue: Using linked list, using array. Java Collections: LinkedList ArrayList Iteration over a Collection Trees: Binary tree First-child / next-sibling tree Linked list tree Implicit tree Binary tree search Binary search of array Depth-first search: Preorder, inorder, postorder Vocabulary ?
Background image of page 2
Material covered in class Big O: Meaning of Big O  Names of Big O classes  Given a function for time vs. n, reduce it to Big O. Ranking of Big O: which is better Best to worst: O(1), O(log(n)), O(nlog(n)), O(n), O(n^2), O(n^3), O(n^k), O(2^n) Big O for common algorithms binary search: O(n log(n))  max of array: O(n) quicksort: O(n log(n)) selection sort: O(n^2) Estimate Big O for some given code Elementary operations such as +, =, a[i] are  O(1) . The Big O for a sequence of statements is the  max  of the Big O of the statements. The Big O for an if statement is the  max  of the Big O of the test, then statement, and  else statement. The Big O for a loop is the loop count times the Big O of the contents.
Background image of page 3

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Big O for a recursive call that cuts the problem size in half is: discard one half:  log(n)  (binary search). process both halves:  n ∙ log(n)  (quicksort). log(n) grows slowly The function  log(n)  grows so slowly that it can almost be considered to be the same as  1. Estimate Big O from a log-log plot, from time ratios From log-log plot:  From time ratios: look at the  ratio  of times as the size of input is doubled. Ratios that are  approximately powers of 2 are easily recognized: 2   n, 2+   nlog(n), 4   n^2, 8  n^3 Linked List: Be able to give result of a call to these functions: cons, first, rest, setfirst, setrest cons - cons("a", list("b", "c"))   (a b c) first - first(list("a", "b", "c"))   a rest - rest(list("a", "b", "c"))   (b c) setfirst -  setrest -  length, reverse, append, nconc, nreverse, member, assoc length -  reverse -  append - 
Background image of page 4
nreverse -  member -  intersection, union, set-difference merge, sort mapcar some, every, subset Stacks:  Using linked list, using array.  Order in which items come out: LIFO.
Background image of page 5

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Image of page 6
This is the end of the preview. Sign up to access the rest of the document.

This note was uploaded on 03/06/2012 for the course CS 314 taught by Professor Novak during the Spring '12 term at University of Texas.

Page1 / 17

CS 314 Midterm Review - 16:16 CS314MidtermReview...

This preview shows document pages 1 - 6. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online