Download presentation
Presentation is loading. Please wait.
Published byBarbra Martha Wiggins Modified over 9 years ago
2
CSE 340: Review (at last!)
3
Measuring The Complexity Complexity is a function of the size of the input O() Ω() Θ() Complexity Analysis “same order” Order of growth: log 2 n, n, n log 2 n, n 2, n 3, 2 n, n!
4
Non Recursive vs Recursive Algorithms Non recursive algorithms: loops, (non recursive) function calls Recursive algorithms: 1.Identify the recursive relation, T(n), and the termination condition (typically T(1) or T(0)) 2.Solve the recursive relation (find a pattern, solve summations) Size of input
5
Algorithms Design Brute Force Greedy Algorithms Divide and Conquer Decrease and Conquer MST: Prim (contiguous edges) Kruskal (disjoint edges) Dijkstra’s shortest path Huffman encodings Bubble Sort (bubble largest element) Selection Sort (select smallest element) Closest pair, Convex-Hull Exhaustive search Merge sort (sort ½ arrays and merge) Quick sort (partition and reorder) Binary search, tree traversals Closest pair, Convex-Hull Insertion sort (incrementally sorted) Graph Search Topological sorting (DFS, source)
6
Some Data Structures Binary trees: Balanced, full, complete binary trees Heaps Graphs: Undirected, digraphs, DAG Representation: Adjacency lists Adjacency Matrices
7
P all the other sorts: Comparison of Problems / Solutions by Their Complexity Simple instruction O(1) Binary search O(log N) Sequential search, insertionsort (best) O(N ) O(N log N ) Mergesort Quicksort, insertionsort (average) Shortest pathMST O(N 2 ) Quicksort, insertionsort (worst), bubblesort
8
NP Prime Factorization Some Problems Seem Too Hard P TSP Vertex Cover SATCircuit-SAT NP-complete 1.If we can find one NP-complete problem that can be solved in polynomial time then P = NP 2.If we can show for one NP-complete problem that it cannot be solved in polynomial time then no other NP-complete problem can be solved in polynomial time (and P ≠NP) “my preciousss…”
9
Questions?
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.