Chapter 10 Search Structures

Size: px
Start display at page:

Download "Chapter 10 Search Structures"

Transcription

1 Chapter 1 Search Structures 1

2 1.2 AVL Trees : 동기 Objective : maintain binary search tree structure for O(log n) access time with dynamic changes of identifiers (i.e., elements) in the tree. JULY APR AUG FEB MAY DEC FEB AUG JAN MAR OCT JAN JULY NOV DEC JUNE NOV SEPT JUNE MAR 최상의 dynamic insertions MAY 최악의 dynamic insertions NOV OCT SEPT 2

3 1.2 AVL Trees : 정의 Height-balanced: An empty tree is height-balanced. If T is a non-empty binary tree with T L and T R as its left and right subtrees, respectively, then T is height-balanced iff (1) T L and T R are heightbalanced and (2) h L -h R < 2 where h L and h R are the heights of T L and T R, respectively. Balance factor: The balance factor, BF(k), of a node k in a binary tree : h L h R. AVL is a binary search tree, satisfying for any node k in the tree, BF(k) = -1,, or 1. 3

4 1.2 AVL Trees : Insertion MAR MAR MAY + 1 (a) Insert MARCH (b) Insert MAY MAY MAR NOV - 2 AUG (d) Insert AUGUST MAR - 1 MAY RR MAY MAR NOV NOV (c) Insert NOV 4

5 1.2 AVL Trees : Insertion (2) +2 MAY MAY +1 AUG MAR NOV LL (e) Insert APRIL MAR AUG APR NOV APR +2 MAY - 1 MAR - 1 AUG + 1 NOV LR AUG MAY APR MAR (f) Insert JANUARY APR JAN NOV JAN 5

6 1.2 AVL Trees : Insertion (3) APR AUG +1 MAR JAN MAY NOV LR APR +1 MAR AUG JAN MAY NOV DEC DEC JULY (g) Insert DECEMBER (h) Insert JULY APR +2 MAR DEC MAY +1-1 JAN NOV RL +1 MAR -1 DEC MAY + AUG 1 JAN NOV DEC JULY APR FEB JULY FEB (i) Insert FEBRUARY 6

7 1.2 AVL Trees : Insertion (4) APR +1 AUG +2 MAR -1-1 DEC MAY FEB -1 JAN -1 JULY NOV JUNE LR APR +1 AUG (j) Insert JUNE +1 DEC FEB JAN +1 AUG JULY MAR NOV JULY +1 AUG APR JAN +1-1 DEC FEB -1-1 JULY JUNE MAR -2 MAY -1 NOV OCT RR +1 AUG APR (k) Insert OCTOBER JAN +1 DEC FEB -1 JULY JUNE MAR MAY NOV 7 OCT

8 1.2 AVL Trees : Insertion (4) APR +1 AUG +2 MAR -1-1 DEC MAY FEB -1 JAN -1 JULY NOV JUNE LR APR +1 AUG (j) Insert JUNE +1 DEC FEB JAN +1 AUG JULY MAR NOV JULY +1 AUG APR JAN +1-1 DEC FEB -1-1 JULY JUNE MAR -2 MAY -1 NOV OCT RR +1 AUG APR (k) Insert OCTOBER JAN +1 DEC FEB -1 JULY JUNE MAR MAY NOV 8 OCT

9 1.2 AVL Trees : Rebalancing rotations BL B Balanced subtree BR +1 A AR h h+2 Unbalanced following insertion BL +1 B BR +2 A AR rotation type LL h+2 Rebalanced subtree BL B BR A AR Rebalanced subtree -1 A AL B height+2 Height of BL increases to h+1-2 A AL -1 B Height of BR increases to h+1 RR Height of subtrees of B remain h+1 A B BR BL BR BL BR height+2 AL BL

10 1.2 AVL Trees : Rebalancing rotations(2) Balanced subtree B +1 A Unbalanced following insertion -1 B +2 A rotation type LR(a) Rebalanced subtree B C A C BL B C +1 A AR h+2 h BL -1 B +1 C +2 A AR LR(b) B C -1 A h+2 h CL CR h-1 CL CR h BL CL CR BR

11 1.2 AVL Trees : Rebalancing rotations(3) -1 B +2 A AR LR(c) +1 B C A h+2 BL -1 C CL CR BL CL CR BR h 11

12 1.2 AVL Trees : Performance comparisons Operation Sequential list Linked List AVL tree Search for x O(log n) O(log n) O(log n) Search for k-th item O(1) O(k) O(log n) Delete x O(n) O(1) 1 O(log n) Delete k-th item O(n-k) O(k) O(log n) Insert x O(n) O(1) 2 O(log n) Output in order O(n) O(n) O(n) 1. Doubly linked list and position of x known 2. Position for insertion known 12

13 Trees - node degree is more than 2 - a special case of B-trees Definition (2-3 tree) : (1) Each internal node is a 2-node or a 3-node. (2) if e is a 2-node, key of every element in LeftChild(node e) < key of e key of every element in MiddleChild(node e) > key of e (3) if e is a 3-node, key of every element in LeftChild(node e) < keyl of e KeyL of e < key of every element in MiddleChild(node e) > keyr of e key of every element in RightChild(node e) > keyr of e (4) All external nodes are at the same level. A 4 B C

14 1.3.3 Inserting into a 2-3 Tree Searching : O(log n) Inserting : O(log n) A 4 (b) 6 inserted G 4 A 2 F 7 B C B 1 3 D C 6 8 E A 4 A 2 4 B C B 1 3 D 7 8 C (a) 7 inserted (b) 3 inserted 14

15 1.3.4 Deletion from a 2-3 Tree Deleting : O(log n) A 5 8 B 1 2 C 6 D 9 95 A 5 8 B 1 2 C 6 7 D deleted A 5 8 B 1 2 C 6 D 95 9 deleted 15

16 1.3.4 Deletion from a 2-3 Tree (2) A 5 8 B deleted B 1 2 C 6 D 95 A 2 B 1 C 8 A deleted B 1 C 5 D 95 A 2 6 deleted B 1 C deleted 16

17 1.3.4 Deletion from a 2-3 Tree : Rotations (a) p is the left child r r x? r y? p q y z p x q z a b c d a b c d (b) p is the middle child r r z? r y? q x y p q x p z a b c d a b c d (c) p is the right child r r x z r w y a q y z p a q x z p b c d e b c d e 17

18 1.3.4 Deletion from a 2-3 Tree : Procedure Step 1: Modify node p as necessary to reflect its status after the desired element has been deleted. Step 2: for (; p has zero elements && p!=root; p = r) { let r be the parent of p, and let q be the left or right sibling of p (as appropriate); if(q is a 3-node) perform a rotation else perform a combine; } Step 3: If p has zero elements, then p must be the root. The left child of p becomes the new root, and node p is deleted. 18

19 1.6 B-Trees Definition: An m-way search tree satisfies (1) The root has at most m subtrees n, A, (K 1, A 1 ), (K 2, A 2 ),, (K n, A n ). (2) K i < K i+1, i = 1,, n. (3) K i < All key values in subtree A i < K i+1, i = 1,, n. (4) K n < All key values in subtree A n, All key values in subtree A < K 1. (5) The subtrees A i, i = 1,, n, are also m-way search tree. T 2, 4 a node schematic format a 2, b, (2, c), (4, d) b 1, 15 c 25, 3 d 45, 5 b 2,, (1, ), (15, ) c 2,, (25, e), (3, ) d 2,, (45, ), (5, ) e e 1,, (28, ) 28 Figure 1.35: Example of a 3-way search tree that is not a 2-3 tree Definition: A B-tree of order m is an m-way search tree, satisfying (1) The root node has at least two children. (2) All nodes other than root and failure nodes have at least m/2 children. (3) All failure nodes are at the same level. 19

20 1.6.3 B-Trees: Properties N: minimum number of keys in a B-tree N+1 = the number of failure nodes = the number of nodes at level l+1 > 2(m/2) l-1 If there are N key values, the level of B-tree l is l < log m/2 {N+1)/2} +1 Choice of m - depending on access time : time for reading nodes from disk + time to search the nodes for x Total maximum search time m 2

21 1.9 Tries blank a b c g o t w blank l u a h o u oriole h wren r b bluebird bunting cardinal chickadee d s gull a u godwit goshawk thrasher thrush 21

22 1.9 Tries : Searching and Sampling Strategies 1. Searching : O(l) where l is the number of level 2. How to reduce l sampling strategy at the i-th level for key value x Example: Sample(x, i) = x r(x,i) for r(x,i) a randomization function blank a b c d e f g h i j k l m n o p q r s t u v w x y z b bunting goshawk wren godwit bluebird thrush thrasher e l a h A tri : sampling one character at a time, from right to left chickadee oriole cardinal gull blank a b c d e f g h i j k l m n o p q r s t u v w x y z b thrasher cardinal goshawk wren chickadee bluebird gull oriole bunting thrush godwit An optimal tri : sampling on the first level done by using the fourth character

23 1.9 Tries : Insertion and Deletion Shrink when deleting b l o u σ Need a count data member in each branch node δ 1 δ 2 e u bobwhite bunting b j δ 3 Section of tri showing changes resulting from inserting bobwhile and bluejay Grow when inserting ρ bluebird bluejay

24 Outline 1. Introduction 2. Finding max. and min. 3. Finding the 2th largest key 4. The Selection Problem 5. A lower bound for finding the median 24

25 1. Introduction SP : (Selection Problem) Given a set of n real numbers, find the k th smallest one, 1 k n. How can you solve it? well, (1) Sort the numbers. (2) Pick the k th smallest one. O(nlogn) Any better way? 25

26 What is a trivial lower bound in time complexity for solving SP? T L (n) = Ω(n) Why? What if only considering comparisons? well,... 26

27 P : Given a set S of n real numbers, find the largest one. W c L W c = {(?,?, x 1 ), (?,?, x 2 ),, (?,?, x n )} W c = n T L (n) = log 2 W c = log 2 n However, this is not tight!!! Why? n = 3 S = {x 1, x 2, x 3 } L = {1 1, 1 2, 1 3, 1 4 } W c = {(?,?, x 1 ), (?,?, x 2 ), (?,?, x 3 )} 1 : 2 < > 2 : 3 1 : 3 < > < > x 3 x 2 x 3 x L >> W 1 c = n as n!!! (x 1, x 2, x 3 ) (?,?, x 2 ) (x 2, x 1, x 3 ) (?,?, x 1 ) 27

28 Adversary Arguments Z 1 = {, 1,, 999} Guess the number in Z 1 that I have in mind? A Guessing Game!!! I can change my mind as long as my answers(responses) are consistent!!! Maximize the number of leaves in a decision tree. 28

29 2. Finding Max. and Min. MM : Given a set of n real numbers, find max and min. max = the largest number min = the smallest number How can you solve MM? x 1 x 2 x 3 x 4 x 2n-1 x 2m n = 2m W {x 11, x 21, x 31,, x m1 } max L {x 12, x 22, x 32,, x m2 } min How many comparisons? m dividing m-1 finding max m-1 3 3m 2 = n 2finding min 2 Any better way? 29

30 What information is needed for finding max and min? Finding max : All numbers except max itself must lose at least once in some comparisons. (n-1 losses) Finding min : All numbers except min itself must win at least once in some comparisons. (n-1 wins) 1 unit of information (1 win) or (1 loss) (2n - 2) units of information are needed!!! max min x 1 x 2 x 3 x 4 x 5 x 6 L L L L L W W W W W 3

31 Status of a number (x i, s i ) : Status W at least one win, no loss L at least one loss, no win WL wins and losses N no comparisons (x, y) Status of keys x and y new compared by an algorithm Adversary response information New Status Units of (N,N) x>y (W,L) 2 (W,N) or (WL,N) * x>y (W,L) or (WL,L) 1 (L,N) ** x<y (L,W) 1 (W,W) x>y (W,WL) 1 (L,L) x>y (WL,L) 1 (W,L), (WL,L) or (W,WL) *** x>y No change (WL,WL) Consistent with No change * (N, W) or (N, WL) can be treated assigned symmetrically values ** (N, L) can be treated symmetrically. *** (L, W), (L, WL) or (WL, W) can be treated symmetrically 31

32 Example Comparison x 1, x 2 x 1, x 5 x 3, x 4 x 3, x 6 x 3, x 1 x 2, x 4 x 5, x 6 x 6, x 4 x 1 Status Value x 2 Status Value x 3 Status Value x 4 Status Value x 5 Status Value x 6 Status Value N * N * N * N * N * N * W 2 W 2 WL 2 L 1 W 15 W 15 W 25 L 8 WL 1 L 6 L 2 L 5 L 12 LW 5 L 3 LW 3 32

33 Theorem : Any algorithm to find max and min of n numbers must do at least 3n/2-2 comparisons in the worst case [proof] n 2m (for nsimplicity) 2 (N, N) 2m information needed n 2?? 2m-2, since 2n-2(4m-2) + (2m 2) = n 3n + ( n 2) = What if n = 2m + 1? Exercise. 33

34 3. Finding the 2 nd largest key 2L : Given a set of n real numbers find the largest two numbers (max and max2). max max2 max2 the 2nd largest one x1 x2 x3 x n W L L L W L L 2n - 3 comparisons!!! Do we need all those L? Any better algorithm? max. max --- n - 1 comparisons max 2 ---? How many numbers were compared directly with 34

35 * 1 * * (n-1) + ( log 2 n - 1) = n + log 2 n - 2 comparisons 35

36 Initially, w(x i ) = 1, i = 1, 2,, n (x i, x j ) Upon each comparison of x i and x j, their values are manipulated depending on the weights, w(x i ) and w(x j ) : w(x i ) > w(x j ) x i > x j w(x i ) := w(x i ) + w(x j ); w(x j ) := w(x i ) = w(x j ) > same same w(x i ) < w(x j ) x i < x j w(x j ) := w(x j ) + w(x i ); w(x i ) := w(x i ) = w(x j ) = consistent no change w(x 1 ) w(x 2 ) w(x 3 ) w(x 4 ) w(x 5 ) (x 1,x 2 ) x 1 > x 2 2 (x 3,x 4 ) x 3 > x 4 2 * (x 3,x 5 ) x 3 > x 5 3 * 36

37 Lemma : # of direct losers to max = log 2 n [Proof] max x i for some i w(x i ) = n w k (x i ) w(x i ) after the k th win against a previously undefeated key w k (x i ) 2 w k-1 (x i ) Why? w (x i ) = 1 w k (x i ) = w k-1 (x i )+w(x j ) 2w k-1 (x i ) since w(x j ) w k-1 (x i ) for (x i,x j ) Suppose that x i wins against t previously undefeated keys eventually. Then, n = w t (x i ) n 2 t Why? w t (x i ) 2 t w (x i ) w t (x i ) 2 t log 2 n t Theorem : Any algorithm to find the 2 nd largest number in a set of n real numbers must do at least n + log 2 n - 2 comparisons. 37

38 Lecture Schedule November 18 (Friday) 1: ~ 11: class A 14: ~ 15: class B Room #4443 (Oh Sang-su lecture room) 38

39 4. Selection Problem SP : Given a set S of n real numbers, find the k th smallest one. a n - k numbers > N k N k k - 1 numbers < N k b is less than a (b < a) b In order to fix the k th smallest number N k, the relation of N k to each number in S must be established!!! Why? 39

40 y N k x y x An adversary could change the value of y which is not related to N k!!! n - 1 crucial comparisons!!! Why? Theorem : Finding the k th smallest element in S requires at least S - 1 comparisons. 4

41 How to find the k th smallest one A straightforward approach (1) Sort S (2) Pick the k th smallest one O(nlogn) Far from optimality!!! Any better idea? well,. Try Divide and Conquer!!! 41

42 S = { 21, 15, 13, 8, 7, 29, 22, 2, 5, 1, 3, 26, 4, 19, 12, 2, 18, 24, 16, 23, 11, 1, 25, 14, 27, 6, 17, 9, 28 } Divide S into S /5 sequences of 5 elements each with up to 4 leftover elements Sort each 5-element sequence

43 A B M = m = the median of M S 1 = {s s < m and s S} S 2 = {s s = m and s S} S 3 = {s s > m and s S} C D S 1 3 S 4 Why? 3 S 3 S 4 43

44 A B m m C D S 1 = {s s < m and s S} S 2 = {s s = m and s S} S 3 = {s s > m and s S} 3 3 S 1 S and S 3 S

45 if S 1 k then select (S 1, k) else if S 1 + S 2 k then m is the k th smallest one else select (S 3, k - S 1 - S 2 ) end 3n T ( n) = T ( ) + c n + T ( n / 5) 4 Why? 45

46 Algorithm ( finding the k th smallest element in S ) procedure SELECT(k,S) begin end if S < 5 then Sort S; SELECT := the k th smallest one end {if} else end Divide S into S /5 sequences of 5 elements each with up to 4 leftover elements; Sort each 5-element sequence; Let M be the set of medians of 5-elements sets (sequences); m := SELECT( ); S 1 = {s s < m and s S}; S 2 = {s s = m and s S}; S 3 = {s s > m and s S}; if S 1 k then SELECT ( k, S 1 ) else if S 1 + S 2 k then else end M, M 2 SELECT ( k - S 1 - S 2, S 3 ) SELECT := m c1 n Why? c2 n n T 5 c n 3 3n T 4 46

47 c n if T ( n) T ( n / 5) + T (3n / 4) + c n if Show that T(n) 2cn. How? By induction!!! 15 n = 5 T (5) T (1) + T ( ) + c 5 4 T (1) + T (38) + c 5 c 1 + c 38 + c 5 c 98 2 c 5 n < 5 n 5 5 < n k T(n) 2cn n = k+1 T(k+1) T((k+1) / 5) + T(3(k+1) / 4) + c (k+1) 2 c (k+1) / c 3(k+1) / 4 + c(k+1) 2 c (k+1) 4c(k+1) + 15 c (k+1) + c(k+1) 47

48 Finding the Median # of comparisons 16n Blum [1973] 5.4n Hyafile [1976] Schonhage, Paterson, and Pippenger [1976] The 3n + o(n) best known little o algorithm 48

49 5. A Lower Bound for Finding the Median k = (n+1) / 2 n-1 (crucial) comparisons Can you find any tighter lower bound? Well, Why not using an adversary argument? 49

50 Observation x y median x y crucial comparisons non-crucial comparisons Def n : A comparison involving an element x is said to be a crucial comparison for x if it is the first comparison with y satisfying one of the following conditions : (1) x > y for some y median. (2) x < y for some y median. Note : (i) A crucial comparison for x establishes the relation of x to the median. (ii) The relation of y to the median is not necessarily known at the time the crucial comparison for x is done. 5

51 Adversary Strategy Force an algorithm to perform as many non-crucial comparisons as possible. How? Assigning values to variables. (x i, s i ) Status L: assigned a value larger than the median S: assigned a value smaller than the median N: not yet in comparison (L, S) (x i, x j ) : Comparing x i and x j, i j (N, N) -- x i > median > x j ; (L, S) (L, N) -- make the unassigned one smaller than the median ; (S, N) -- reverse the above ; (S, L) (L, S) L) consistent with previous responses (S, L) S) 51

52 n + 2 n elements 1 n + 1 th 2 element n n 1 2 n + 1 < median median < elements media n Unless there are already (n - 1) / 2 elements with status S (or L), keep the strategy previously stated!!! 2 Otherwise, make the balance between the numbers for L and S. (n - 1) / 2 non-crucial comparisons possible!!! Why? 3 ( n 1) / 2 + ( n 1) = ( n 1) 2 crucial non-crucial Comparisons 52

53 Theorem : Any algorithm to find the median of n numbers must do 3 ( n 1) at least 2 comparisons. 3 ( n 1) n log n 1.8n 2n Best lower bound currently known!!! (n - 1) comparisons are tight lower bound only for k = 1 and n!!! 53

54 Project 2 Graph-related algorithms Both directed and undirected graphs Menu-driven 1) Initialize Graphs 2) Min-Cost spanning tree 3) Dijkstra s shortest path 4) Depth-first Search 5) Breadth-first Search 6) Biconnected components 7) Strongly connected components 54

Data Structures and Algorithms

Data Structures and Algorithms Data Structures and Algorithms Spring 2017-2018 Outline 1 Sorting Algorithms (contd.) Outline Sorting Algorithms (contd.) 1 Sorting Algorithms (contd.) Analysis of Quicksort Time to sort array of length

More information

Data Structures and Algorithms " Search Trees!!

Data Structures and Algorithms  Search Trees!! Data Structures and Algorithms " Search Trees!! Outline" Binary Search Trees! AVL Trees! (2,4) Trees! 2 Binary Search Trees! "! < 6 2 > 1 4 = 8 9 Ordered Dictionaries" Keys are assumed to come from a total

More information

Selection and Adversary Arguments. COMP 215 Lecture 19

Selection and Adversary Arguments. COMP 215 Lecture 19 Selection and Adversary Arguments COMP 215 Lecture 19 Selection Problems We want to find the k'th largest entry in an unsorted array. Could be the largest, smallest, median, etc. Ideas for an n lg n algorithm?

More information

AVL Trees. Properties Insertion. October 17, 2017 Cinda Heeren / Geoffrey Tien 1

AVL Trees. Properties Insertion. October 17, 2017 Cinda Heeren / Geoffrey Tien 1 AVL Trees Properties Insertion October 17, 2017 Cinda Heeren / Geoffrey Tien 1 BST rotation g g e h b h b f i a e i a c c f d d Rotations preserve the in-order BST property, while altering the tree structure

More information

GAMINGRE 8/1/ of 7

GAMINGRE 8/1/ of 7 FYE 09/30/92 JULY 92 0.00 254,550.00 0.00 0 0 0 0 0 0 0 0 0 254,550.00 0.00 0.00 0.00 0.00 254,550.00 AUG 10,616,710.31 5,299.95 845,656.83 84,565.68 61,084.86 23,480.82 339,734.73 135,893.89 67,946.95

More information

Lecture 17: Trees and Merge Sort 10:00 AM, Oct 15, 2018

Lecture 17: Trees and Merge Sort 10:00 AM, Oct 15, 2018 CS17 Integrated Introduction to Computer Science Klein Contents Lecture 17: Trees and Merge Sort 10:00 AM, Oct 15, 2018 1 Tree definitions 1 2 Analysis of mergesort using a binary tree 1 3 Analysis of

More information

CSCE 750 Final Exam Answer Key Wednesday December 7, 2005

CSCE 750 Final Exam Answer Key Wednesday December 7, 2005 CSCE 750 Final Exam Answer Key Wednesday December 7, 2005 Do all problems. Put your answers on blank paper or in a test booklet. There are 00 points total in the exam. You have 80 minutes. Please note

More information

CS 350 Algorithms and Complexity

CS 350 Algorithms and Complexity 1 CS 350 Algorithms and Complexity Fall 2015 Lecture 15: Limitations of Algorithmic Power Introduction to complexity theory Andrew P. Black Department of Computer Science Portland State University Lower

More information

4.8 Huffman Codes. These lecture slides are supplied by Mathijs de Weerd

4.8 Huffman Codes. These lecture slides are supplied by Mathijs de Weerd 4.8 Huffman Codes These lecture slides are supplied by Mathijs de Weerd Data Compression Q. Given a text that uses 32 symbols (26 different letters, space, and some punctuation characters), how can we

More information

CS Data Structures and Algorithm Analysis

CS Data Structures and Algorithm Analysis CS 483 - Data Structures and Algorithm Analysis Lecture VII: Chapter 6, part 2 R. Paul Wiegand George Mason University, Department of Computer Science March 22, 2006 Outline 1 Balanced Trees 2 Heaps &

More information

CS 350 Algorithms and Complexity

CS 350 Algorithms and Complexity CS 350 Algorithms and Complexity Winter 2019 Lecture 15: Limitations of Algorithmic Power Introduction to complexity theory Andrew P. Black Department of Computer Science Portland State University Lower

More information

Algorithms and Data Structures 2016 Week 5 solutions (Tues 9th - Fri 12th February)

Algorithms and Data Structures 2016 Week 5 solutions (Tues 9th - Fri 12th February) Algorithms and Data Structures 016 Week 5 solutions (Tues 9th - Fri 1th February) 1. Draw the decision tree (under the assumption of all-distinct inputs) Quicksort for n = 3. answer: (of course you should

More information

DAILY QUESTIONS 28 TH JUNE 18 REASONING - CALENDAR

DAILY QUESTIONS 28 TH JUNE 18 REASONING - CALENDAR DAILY QUESTIONS 28 TH JUNE 18 REASONING - CALENDAR LEAP AND NON-LEAP YEAR *A non-leap year has 365 days whereas a leap year has 366 days. (as February has 29 days). *Every year which is divisible by 4

More information

WHEN IS IT EVER GOING TO RAIN? Table of Average Annual Rainfall and Rainfall For Selected Arizona Cities

WHEN IS IT EVER GOING TO RAIN? Table of Average Annual Rainfall and Rainfall For Selected Arizona Cities WHEN IS IT EVER GOING TO RAIN? Table of Average Annual Rainfall and 2001-2002 Rainfall For Selected Arizona Cities Phoenix Tucson Flagstaff Avg. 2001-2002 Avg. 2001-2002 Avg. 2001-2002 October 0.7 0.0

More information

Search Trees. Chapter 10. CSE 2011 Prof. J. Elder Last Updated: :52 AM

Search Trees. Chapter 10. CSE 2011 Prof. J. Elder Last Updated: :52 AM Search Trees Chapter 1 < 6 2 > 1 4 = 8 9-1 - Outline Ø Binary Search Trees Ø AVL Trees Ø Splay Trees - 2 - Outline Ø Binary Search Trees Ø AVL Trees Ø Splay Trees - 3 - Binary Search Trees Ø A binary search

More information

Search Trees. EECS 2011 Prof. J. Elder Last Updated: 24 March 2015

Search Trees. EECS 2011 Prof. J. Elder Last Updated: 24 March 2015 Search Trees < 6 2 > 1 4 = 8 9-1 - Outline Ø Binary Search Trees Ø AVL Trees Ø Splay Trees - 2 - Learning Outcomes Ø From this lecture, you should be able to: q Define the properties of a binary search

More information

Divide-and-Conquer Algorithms Part Two

Divide-and-Conquer Algorithms Part Two Divide-and-Conquer Algorithms Part Two Recap from Last Time Divide-and-Conquer Algorithms A divide-and-conquer algorithm is one that works as follows: (Divide) Split the input apart into multiple smaller

More information

Fundamental Algorithms

Fundamental Algorithms Fundamental Algorithms Chapter 5: Searching Michael Bader Winter 2014/15 Chapter 5: Searching, Winter 2014/15 1 Searching Definition (Search Problem) Input: a sequence or set A of n elements (objects)

More information

Review Of Topics. Review: Induction

Review Of Topics. Review: Induction Review Of Topics Asymptotic notation Solving recurrences Sorting algorithms Insertion sort Merge sort Heap sort Quick sort Counting sort Radix sort Medians/order statistics Randomized algorithm Worst-case

More information

CMPT 307 : Divide-and-Conqer (Study Guide) Should be read in conjunction with the text June 2, 2015

CMPT 307 : Divide-and-Conqer (Study Guide) Should be read in conjunction with the text June 2, 2015 CMPT 307 : Divide-and-Conqer (Study Guide) Should be read in conjunction with the text June 2, 2015 1 Introduction The divide-and-conquer strategy is a general paradigm for algorithm design. This strategy

More information

Dictionary: an abstract data type

Dictionary: an abstract data type 2-3 Trees 1 Dictionary: an abstract data type A container that maps keys to values Dictionary operations Insert Search Delete Several possible implementations Balanced search trees Hash tables 2 2-3 trees

More information

Search and Lookahead. Bernhard Nebel, Julien Hué, and Stefan Wölfl. June 4/6, 2012

Search and Lookahead. Bernhard Nebel, Julien Hué, and Stefan Wölfl. June 4/6, 2012 Search and Lookahead Bernhard Nebel, Julien Hué, and Stefan Wölfl Albert-Ludwigs-Universität Freiburg June 4/6, 2012 Search and Lookahead Enforcing consistency is one way of solving constraint networks:

More information

What we have learned What is algorithm Why study algorithm The time and space efficiency of algorithm The analysis framework of time efficiency Asympt

What we have learned What is algorithm Why study algorithm The time and space efficiency of algorithm The analysis framework of time efficiency Asympt Lecture 3 The Analysis of Recursive Algorithm Efficiency What we have learned What is algorithm Why study algorithm The time and space efficiency of algorithm The analysis framework of time efficiency

More information

IS 709/809: Computational Methods in IS Research Fall Exam Review

IS 709/809: Computational Methods in IS Research Fall Exam Review IS 709/809: Computational Methods in IS Research Fall 2017 Exam Review Nirmalya Roy Department of Information Systems University of Maryland Baltimore County www.umbc.edu Exam When: Tuesday (11/28) 7:10pm

More information

Computer Science 385 Analysis of Algorithms Siena College Spring Topic Notes: Limitations of Algorithms

Computer Science 385 Analysis of Algorithms Siena College Spring Topic Notes: Limitations of Algorithms Computer Science 385 Analysis of Algorithms Siena College Spring 2011 Topic Notes: Limitations of Algorithms We conclude with a discussion of the limitations of the power of algorithms. That is, what kinds

More information

Analysis of Algorithms. Outline 1 Introduction Basic Definitions Ordered Trees. Fibonacci Heaps. Andres Mendez-Vazquez. October 29, Notes.

Analysis of Algorithms. Outline 1 Introduction Basic Definitions Ordered Trees. Fibonacci Heaps. Andres Mendez-Vazquez. October 29, Notes. Analysis of Algorithms Fibonacci Heaps Andres Mendez-Vazquez October 29, 2015 1 / 119 Outline 1 Introduction Basic Definitions Ordered Trees 2 Binomial Trees Example 3 Fibonacci Heap Operations Fibonacci

More information

Greedy Algorithms. CSE 101: Design and Analysis of Algorithms Lecture 10

Greedy Algorithms. CSE 101: Design and Analysis of Algorithms Lecture 10 Greedy Algorithms CSE 101: Design and Analysis of Algorithms Lecture 10 CSE 101: Design and analysis of algorithms Greedy algorithms Reading: Kleinberg and Tardos, sections 4.1, 4.2, and 4.3 Homework 4

More information

UCSD CSE 21, Spring 2014 [Section B00] Mathematics for Algorithm and System Analysis

UCSD CSE 21, Spring 2014 [Section B00] Mathematics for Algorithm and System Analysis UCSD CSE 21, Spring 2014 [Section B00] Mathematics for Algorithm and System Analysis Lecture 14 Class URL: http://vlsicad.ucsd.edu/courses/cse21-s14/ Lecture 14 Notes Goals for this week Big-O complexity

More information

Chapter 5 Arrays and Strings 5.1 Arrays as abstract data types 5.2 Contiguous representations of arrays 5.3 Sparse arrays 5.4 Representations of

Chapter 5 Arrays and Strings 5.1 Arrays as abstract data types 5.2 Contiguous representations of arrays 5.3 Sparse arrays 5.4 Representations of Chapter 5 Arrays and Strings 5.1 Arrays as abstract data types 5.2 Contiguous representations of arrays 5.3 Sparse arrays 5.4 Representations of strings 5.5 String searching algorithms 0 5.1 Arrays as

More information

Assignment 5: Solutions

Assignment 5: Solutions Comp 21: Algorithms and Data Structures Assignment : Solutions 1. Heaps. (a) First we remove the minimum key 1 (which we know is located at the root of the heap). We then replace it by the key in the position

More information

NATIONAL UNIVERSITY OF SINGAPORE CS3230 DESIGN AND ANALYSIS OF ALGORITHMS SEMESTER II: Time Allowed 2 Hours

NATIONAL UNIVERSITY OF SINGAPORE CS3230 DESIGN AND ANALYSIS OF ALGORITHMS SEMESTER II: Time Allowed 2 Hours NATIONAL UNIVERSITY OF SINGAPORE CS3230 DESIGN AND ANALYSIS OF ALGORITHMS SEMESTER II: 2017 2018 Time Allowed 2 Hours INSTRUCTIONS TO STUDENTS 1. This assessment consists of Eight (8) questions and comprises

More information

Binary Search Trees. Lecture 29 Section Robb T. Koether. Hampden-Sydney College. Fri, Apr 8, 2016

Binary Search Trees. Lecture 29 Section Robb T. Koether. Hampden-Sydney College. Fri, Apr 8, 2016 Binary Search Trees Lecture 29 Section 19.2 Robb T. Koether Hampden-Sydney College Fri, Apr 8, 2016 Robb T. Koether (Hampden-Sydney College) Binary Search Trees Fri, Apr 8, 2016 1 / 40 1 Binary Search

More information

Chapter 5 Data Structures Algorithm Theory WS 2017/18 Fabian Kuhn

Chapter 5 Data Structures Algorithm Theory WS 2017/18 Fabian Kuhn Chapter 5 Data Structures Algorithm Theory WS 2017/18 Fabian Kuhn Priority Queue / Heap Stores (key,data) pairs (like dictionary) But, different set of operations: Initialize-Heap: creates new empty heap

More information

CSC 8301 Design & Analysis of Algorithms: Lower Bounds

CSC 8301 Design & Analysis of Algorithms: Lower Bounds CSC 8301 Design & Analysis of Algorithms: Lower Bounds Professor Henry Carter Fall 2016 Recap Iterative improvement algorithms take a feasible solution and iteratively improve it until optimized Simplex

More information

15.1 Introduction to Lower Bounds Proofs

15.1 Introduction to Lower Bounds Proofs 15 Lower Bounds How do I know if I have a good algorithm to solve a problem? If my algorithm runs in Θ(n log n) time, is that good? It would be if I were sorting the records stored in an array. But it

More information

Kartsuba s Algorithm and Linear Time Selection

Kartsuba s Algorithm and Linear Time Selection CS 374: Algorithms & Models of Computation, Fall 2015 Kartsuba s Algorithm and Linear Time Selection Lecture 09 September 22, 2015 Chandra & Manoj (UIUC) CS374 1 Fall 2015 1 / 32 Part I Fast Multiplication

More information

CSE 4502/5717: Big Data Analytics

CSE 4502/5717: Big Data Analytics CSE 4502/5717: Big Data Analytics otes by Anthony Hershberger Lecture 4 - January, 31st, 2018 1 Problem of Sorting A known lower bound for sorting is Ω is the input size; M is the core memory size; and

More information

Design and Analysis of Algorithms

Design and Analysis of Algorithms CSE 101, Winter 2018 Design and Analysis of Algorithms Lecture 5: Divide and Conquer (Part 2) Class URL: http://vlsicad.ucsd.edu/courses/cse101-w18/ A Lower Bound on Convex Hull Lecture 4 Task: sort the

More information

Fibonacci Heaps These lecture slides are adapted from CLRS, Chapter 20.

Fibonacci Heaps These lecture slides are adapted from CLRS, Chapter 20. Fibonacci Heaps These lecture slides are adapted from CLRS, Chapter 20. Princeton University COS 4 Theory of Algorithms Spring 2002 Kevin Wayne Priority Queues Operation mae-heap insert find- delete- union

More information

Optimal Tree-decomposition Balancing and Reachability on Low Treewidth Graphs

Optimal Tree-decomposition Balancing and Reachability on Low Treewidth Graphs Optimal Tree-decomposition Balancing and Reachability on Low Treewidth Graphs Krishnendu Chatterjee Rasmus Ibsen-Jensen Andreas Pavlogiannis IST Austria Abstract. We consider graphs with n nodes together

More information

Data selection. Lower complexity bound for sorting

Data selection. Lower complexity bound for sorting Data selection. Lower complexity bound for sorting Lecturer: Georgy Gimel farb COMPSCI 220 Algorithms and Data Structures 1 / 12 1 Data selection: Quickselect 2 Lower complexity bound for sorting 3 The

More information

Graphs and Trees Binary Search Trees AVL-Trees (a,b)-trees Splay-Trees. Search Trees. Tobias Lieber. April 14, 2008

Graphs and Trees Binary Search Trees AVL-Trees (a,b)-trees Splay-Trees. Search Trees. Tobias Lieber. April 14, 2008 Search Trees Tobias Lieber April 14, 2008 Tobias Lieber Search Trees April 14, 2008 1 / 57 Graphs and Trees Binary Search Trees AVL-Trees (a,b)-trees Splay-Trees Tobias Lieber Search Trees April 14, 2008

More information

Calculations Equation of Time. EQUATION OF TIME = apparent solar time - mean solar time

Calculations Equation of Time. EQUATION OF TIME = apparent solar time - mean solar time Calculations Equation of Time APPARENT SOLAR TIME is the time that is shown on sundials. A MEAN SOLAR DAY is a constant 24 hours every day of the year. Apparent solar days are measured from noon one day

More information

Design and Analysis of Algorithms

Design and Analysis of Algorithms CSE 101, Winter 2018 Design and Analysis of Algorithms Lecture 4: Divide and Conquer (I) Class URL: http://vlsicad.ucsd.edu/courses/cse101-w18/ Divide and Conquer ( DQ ) First paradigm or framework DQ(S)

More information

Preliminaries. Graphs. E : set of edges (arcs) (Undirected) Graph : (i, j) = (j, i) (edges) V = {1, 2, 3, 4, 5}, E = {(1, 3), (3, 2), (2, 4)}

Preliminaries. Graphs. E : set of edges (arcs) (Undirected) Graph : (i, j) = (j, i) (edges) V = {1, 2, 3, 4, 5}, E = {(1, 3), (3, 2), (2, 4)} Preliminaries Graphs G = (V, E), V : set of vertices E : set of edges (arcs) (Undirected) Graph : (i, j) = (j, i) (edges) 1 2 3 5 4 V = {1, 2, 3, 4, 5}, E = {(1, 3), (3, 2), (2, 4)} 1 Directed Graph (Digraph)

More information

Determine the trend for time series data

Determine the trend for time series data Extra Online Questions Determine the trend for time series data Covers AS 90641 (Statistics and Modelling 3.1) Scholarship Statistics and Modelling Chapter 1 Essent ial exam notes Time series 1. The value

More information

CS60007 Algorithm Design and Analysis 2018 Assignment 1

CS60007 Algorithm Design and Analysis 2018 Assignment 1 CS60007 Algorithm Design and Analysis 2018 Assignment 1 Palash Dey and Swagato Sanyal Indian Institute of Technology, Kharagpur Please submit the solutions of the problems 6, 11, 12 and 13 (written in

More information

CS 2110: INDUCTION DISCUSSION TOPICS

CS 2110: INDUCTION DISCUSSION TOPICS CS 110: INDUCTION DISCUSSION TOPICS The following ideas are suggestions for how to handle your discussion classes. You can do as much or as little of this as you want. You can either present at the board,

More information

Lecture 2 September 4, 2014

Lecture 2 September 4, 2014 CS 224: Advanced Algorithms Fall 2014 Prof. Jelani Nelson Lecture 2 September 4, 2014 Scribe: David Liu 1 Overview In the last lecture we introduced the word RAM model and covered veb trees to solve the

More information

Limitations of Algorithm Power

Limitations of Algorithm Power Limitations of Algorithm Power Objectives We now move into the third and final major theme for this course. 1. Tools for analyzing algorithms. 2. Design strategies for designing algorithms. 3. Identifying

More information

Data structures Exercise 1 solution. Question 1. Let s start by writing all the functions in big O notation:

Data structures Exercise 1 solution. Question 1. Let s start by writing all the functions in big O notation: Data structures Exercise 1 solution Question 1 Let s start by writing all the functions in big O notation: f 1 (n) = 2017 = O(1), f 2 (n) = 2 log 2 n = O(n 2 ), f 3 (n) = 2 n = O(2 n ), f 4 (n) = 1 = O

More information

Lecture 1: Asymptotics, Recurrences, Elementary Sorting

Lecture 1: Asymptotics, Recurrences, Elementary Sorting Lecture 1: Asymptotics, Recurrences, Elementary Sorting Instructor: Outline 1 Introduction to Asymptotic Analysis Rate of growth of functions Comparing and bounding functions: O, Θ, Ω Specifying running

More information

Discrete Optimization 2010 Lecture 2 Matroids & Shortest Paths

Discrete Optimization 2010 Lecture 2 Matroids & Shortest Paths Matroids Shortest Paths Discrete Optimization 2010 Lecture 2 Matroids & Shortest Paths Marc Uetz University of Twente m.uetz@utwente.nl Lecture 2: sheet 1 / 25 Marc Uetz Discrete Optimization Matroids

More information

An analogy from Calculus: limits

An analogy from Calculus: limits COMP 250 Fall 2018 35 - big O Nov. 30, 2018 We have seen several algorithms in the course, and we have loosely characterized their runtimes in terms of the size n of the input. We say that the algorithm

More information

CS 151. Red Black Trees & Structural Induction. Thursday, November 1, 12

CS 151. Red Black Trees & Structural Induction. Thursday, November 1, 12 CS 151 Red Black Trees & Structural Induction 1 Announcements Majors fair tonight 4:30-6:30pm in the Root Room in Carnegie. Come and find out about the CS major, or some other major. Winter Term in CS

More information

Chapter 11. Min Cut Min Cut Problem Definition Some Definitions. By Sariel Har-Peled, December 10, Version: 1.

Chapter 11. Min Cut Min Cut Problem Definition Some Definitions. By Sariel Har-Peled, December 10, Version: 1. Chapter 11 Min Cut By Sariel Har-Peled, December 10, 013 1 Version: 1.0 I built on the sand And it tumbled down, I built on a rock And it tumbled down. Now when I build, I shall begin With the smoke from

More information

Dictionary: an abstract data type

Dictionary: an abstract data type 2-3 Trees 1 Dictionary: an abstract data type A container that maps keys to values Dictionary operations Insert Search Delete Several possible implementations Balanced search trees Hash tables 2 2-3 trees

More information

JANUARY MONDAY TUESDAY WEDNESDAY THURSDAY FRIDAY SATURDAY SUNDAY

JANUARY MONDAY TUESDAY WEDNESDAY THURSDAY FRIDAY SATURDAY SUNDAY Vocabulary (01) The Calendar (012) In context: Look at the calendar. Then, answer the questions. JANUARY MONDAY TUESDAY WEDNESDAY THURSDAY FRIDAY SATURDAY SUNDAY 1 New 2 3 4 5 6 Year s Day 7 8 9 10 11

More information

16. Binary Search Trees. [Ottman/Widmayer, Kap. 5.1, Cormen et al, Kap ]

16. Binary Search Trees. [Ottman/Widmayer, Kap. 5.1, Cormen et al, Kap ] 418 16. Binary Search Trees [Ottman/Widmayer, Kap. 5.1, Cormen et al, Kap. 12.1-12.3] 419 Dictionary implementation Hashing: implementation of dictionaries with expected very fast access times. Disadvantages

More information

January 2009 Videmus Stellae

January 2009 Videmus Stellae January 2009 January Schedule of Events Sun Mon Tu e Wed Thu Fri Sat Jan 6th: ATM Sub at Paul Lind s Garage at 1900 Jan 9th: SAC General at Grand Canyon University at 1930 in room 105 of the Fleming Bldg.

More information

Asymptotic Analysis. Slides by Carl Kingsford. Jan. 27, AD Chapter 2

Asymptotic Analysis. Slides by Carl Kingsford. Jan. 27, AD Chapter 2 Asymptotic Analysis Slides by Carl Kingsford Jan. 27, 2014 AD Chapter 2 Independent Set Definition (Independent Set). Given a graph G = (V, E) an independent set is a set S V if no two nodes in S are joined

More information

Lecture 2 14 February, 2007

Lecture 2 14 February, 2007 6.851: Advanced Data Structures Spring 2007 Prof. Erik Demaine Lecture 2 14 February, 2007 Scribes: Christopher Moh, Aditya Rathnam 1 Overview In the last lecture we covered linked lists and some results

More information

CMPSCI611: The Matroid Theorem Lecture 5

CMPSCI611: The Matroid Theorem Lecture 5 CMPSCI611: The Matroid Theorem Lecture 5 We first review our definitions: A subset system is a set E together with a set of subsets of E, called I, such that I is closed under inclusion. This means that

More information

16. Binary Search Trees. [Ottman/Widmayer, Kap. 5.1, Cormen et al, Kap ]

16. Binary Search Trees. [Ottman/Widmayer, Kap. 5.1, Cormen et al, Kap ] 423 16. Binary Search Trees [Ottman/Widmayer, Kap. 5.1, Cormen et al, Kap. 12.1-12.3] Dictionary implementation 424 Hashing: implementation of dictionaries with expected very fast access times. Disadvantages

More information

2. ALGORITHM ANALYSIS

2. ALGORITHM ANALYSIS 2. ALGORITHM ANALYSIS computational tractability asymptotic order of growth survey of common running times Lecture slides by Kevin Wayne Copyright 2005 Pearson-Addison Wesley http://www.cs.princeton.edu/~wayne/kleinberg-tardos

More information

INF2220: algorithms and data structures Series 1

INF2220: algorithms and data structures Series 1 Universitetet i Oslo Institutt for Informatikk I. Yu, D. Karabeg INF2220: algorithms and data structures Series 1 Topic Function growth & estimation of running time, trees (Exercises with hints for solution)

More information

Lecture 4. Quicksort

Lecture 4. Quicksort Lecture 4. Quicksort T. H. Cormen, C. E. Leiserson and R. L. Rivest Introduction to Algorithms, 3rd Edition, MIT Press, 2009 Sungkyunkwan University Hyunseung Choo choo@skku.edu Copyright 2000-2018 Networking

More information

Ordered Dictionary & Binary Search Tree

Ordered Dictionary & Binary Search Tree Ordered Dictionary & Binary Search Tree Finite map from keys to values, assuming keys are comparable (). insert(k, v) lookup(k) aka find: the associated value if any delete(k) (Ordered set: No values;

More information

ENS Lyon Camp. Day 2. Basic group. Cartesian Tree. 26 October

ENS Lyon Camp. Day 2. Basic group. Cartesian Tree. 26 October ENS Lyon Camp. Day 2. Basic group. Cartesian Tree. 26 October Contents 1 Cartesian Tree. Definition. 1 2 Cartesian Tree. Construction 1 3 Cartesian Tree. Operations. 2 3.1 Split............................................

More information

1 Terminology and setup

1 Terminology and setup 15-451/651: Design & Analysis of Algorithms August 31, 2017 Lecture #2 last changed: August 29, 2017 In this lecture, we will examine some simple, concrete models of computation, each with a precise definition

More information

Advanced Implementations of Tables: Balanced Search Trees and Hashing

Advanced Implementations of Tables: Balanced Search Trees and Hashing Advanced Implementations of Tables: Balanced Search Trees and Hashing Balanced Search Trees Binary search tree operations such as insert, delete, retrieve, etc. depend on the length of the path to the

More information

AVL Trees. Manolis Koubarakis. Data Structures and Programming Techniques

AVL Trees. Manolis Koubarakis. Data Structures and Programming Techniques AVL Trees Manolis Koubarakis 1 AVL Trees We will now introduce AVL trees that have the property that they are kept almost balanced but not completely balanced. In this way we have O(log n) search time

More information

Week 5: Quicksort, Lower bound, Greedy

Week 5: Quicksort, Lower bound, Greedy Week 5: Quicksort, Lower bound, Greedy Agenda: Quicksort: Average case Lower bound for sorting Greedy method 1 Week 5: Quicksort Recall Quicksort: The ideas: Pick one key Compare to others: partition into

More information

CS361 Homework #3 Solutions

CS361 Homework #3 Solutions CS6 Homework # Solutions. Suppose I have a hash table with 5 locations. I would like to know how many items I can store in it before it becomes fairly likely that I have a collision, i.e., that two items

More information

Lecture 5: February 21, 2017

Lecture 5: February 21, 2017 COMS 6998: Advanced Complexity Spring 2017 Lecture 5: February 21, 2017 Lecturer: Rocco Servedio Scribe: Diana Yin 1 Introduction 1.1 Last Time 1. Established the exact correspondence between communication

More information

Divide and Conquer Algorithms. CSE 101: Design and Analysis of Algorithms Lecture 14

Divide and Conquer Algorithms. CSE 101: Design and Analysis of Algorithms Lecture 14 Divide and Conquer Algorithms CSE 101: Design and Analysis of Algorithms Lecture 14 CSE 101: Design and analysis of algorithms Divide and conquer algorithms Reading: Sections 2.3 and 2.4 Homework 6 will

More information

Quiz 1 Solutions. Problem 2. Asymptotics & Recurrences [20 points] (3 parts)

Quiz 1 Solutions. Problem 2. Asymptotics & Recurrences [20 points] (3 parts) Introduction to Algorithms October 13, 2010 Massachusetts Institute of Technology 6.006 Fall 2010 Professors Konstantinos Daskalakis and Patrick Jaillet Quiz 1 Solutions Quiz 1 Solutions Problem 1. We

More information

Lecture 5: Hashing. David Woodruff Carnegie Mellon University

Lecture 5: Hashing. David Woodruff Carnegie Mellon University Lecture 5: Hashing David Woodruff Carnegie Mellon University Hashing Universal hashing Perfect hashing Maintaining a Dictionary Let U be a universe of keys U could be all strings of ASCII characters of

More information

Georgia Tech High School Math Competition

Georgia Tech High School Math Competition Georgia Tech High School Math Competition Multiple Choice Test February 28, 2015 Each correct answer is worth one point; there is no deduction for incorrect answers. Make sure to enter your ID number on

More information

1 Approximate Quantiles and Summaries

1 Approximate Quantiles and Summaries CS 598CSC: Algorithms for Big Data Lecture date: Sept 25, 2014 Instructor: Chandra Chekuri Scribe: Chandra Chekuri Suppose we have a stream a 1, a 2,..., a n of objects from an ordered universe. For simplicity

More information

Problem. Problem Given a dictionary and a word. Which page (if any) contains the given word? 3 / 26

Problem. Problem Given a dictionary and a word. Which page (if any) contains the given word? 3 / 26 Binary Search Introduction Problem Problem Given a dictionary and a word. Which page (if any) contains the given word? 3 / 26 Strategy 1: Random Search Randomly select a page until the page containing

More information

Worst case analysis for a general class of on-line lot-sizing heuristics

Worst case analysis for a general class of on-line lot-sizing heuristics Worst case analysis for a general class of on-line lot-sizing heuristics Wilco van den Heuvel a, Albert P.M. Wagelmans a a Econometric Institute and Erasmus Research Institute of Management, Erasmus University

More information

data structures and algorithms lecture 2

data structures and algorithms lecture 2 data structures and algorithms 2018 09 06 lecture 2 recall: insertion sort Algorithm insertionsort(a, n): for j := 2 to n do key := A[j] i := j 1 while i 1 and A[i] > key do A[i + 1] := A[i] i := i 1 A[i

More information

CSC 421: Algorithm Design & Analysis. Spring 2015

CSC 421: Algorithm Design & Analysis. Spring 2015 CSC 421: Algorithm Design & Analysis Spring 2015 Complexity & lower bounds brute force decision trees adversary arguments problem reduction 1 Lower bounds on problems when studying a problem, may wish

More information

Fundamental Algorithms

Fundamental Algorithms Fundamental Algithms Chapter 4: AVL Trees Jan Křetínský Winter 2016/17 Chapter 4: AVL Trees, Winter 2016/17 1 Part I AVL Trees (Adelson-Velsky and Landis, 1962) Chapter 4: AVL Trees, Winter 2016/17 2 Binary

More information

On shredders and vertex connectivity augmentation

On shredders and vertex connectivity augmentation On shredders and vertex connectivity augmentation Gilad Liberman The Open University of Israel giladliberman@gmail.com Zeev Nutov The Open University of Israel nutov@openu.ac.il Abstract We consider the

More information

Data Structures in Java

Data Structures in Java Data Structures in Java Lecture 20: Algorithm Design Techniques 12/2/2015 Daniel Bauer 1 Algorithms and Problem Solving Purpose of algorithms: find solutions to problems. Data Structures provide ways of

More information

Midterm 1 for CS 170

Midterm 1 for CS 170 UC Berkeley CS 170 Midterm 1 Lecturer: Satish Rao October 2 Midterm 1 for CS 170 Print your name:, (last) (first) Sign your name: Write your section number (e.g., 101): Write your SID: One page of notes

More information

On improving matchings in trees, via bounded-length augmentations 1

On improving matchings in trees, via bounded-length augmentations 1 On improving matchings in trees, via bounded-length augmentations 1 Julien Bensmail a, Valentin Garnero a, Nicolas Nisse a a Université Côte d Azur, CNRS, Inria, I3S, France Abstract Due to a classical

More information

Algorithm for exact evaluation of bivariate two-sample Kolmogorov-Smirnov statistics in O(nlogn) time.

Algorithm for exact evaluation of bivariate two-sample Kolmogorov-Smirnov statistics in O(nlogn) time. Algorithm for exact evaluation of bivariate two-sample Kolmogorov-Smirnov statistics in O(nlogn) time. Krystian Zawistowski January 3, 2019 Abstract We propose an O(nlogn) algorithm for evaluation of bivariate

More information

b + O(n d ) where a 1, b > 1, then O(n d log n) if a = b d d ) if a < b d O(n log b a ) if a > b d

b + O(n d ) where a 1, b > 1, then O(n d log n) if a = b d d ) if a < b d O(n log b a ) if a > b d CS161, Lecture 4 Median, Selection, and the Substitution Method Scribe: Albert Chen and Juliana Cook (2015), Sam Kim (2016), Gregory Valiant (2017) Date: January 23, 2017 1 Introduction Last lecture, we

More information

ENGINE SERIAL NUMBERS

ENGINE SERIAL NUMBERS ENGINE SERIAL NUMBERS The engine number was also the serial number of the car. Engines were numbered when they were completed, and for the most part went into a chassis within a day or so. However, some

More information

5 + 9(10) + 3(100) + 0(1000) + 2(10000) =

5 + 9(10) + 3(100) + 0(1000) + 2(10000) = Chapter 5 Analyzing Algorithms So far we have been proving statements about databases, mathematics and arithmetic, or sequences of numbers. Though these types of statements are common in computer science,

More information

Solutions to the 74th William Lowell Putnam Mathematical Competition Saturday, December 7, 2013

Solutions to the 74th William Lowell Putnam Mathematical Competition Saturday, December 7, 2013 Solutions to the 74th William Lowell Putnam Mathematical Competition Saturday, December 7, 213 Kiran Kedlaya and Lenny Ng A1 Suppose otherwise. Then each vertex v is a vertex for five faces, all of which

More information

Activity Sheet Counting M&Ms

Activity Sheet Counting M&Ms Counting M&Ms Pour a half-pound bag of M&Ms onto a paper plate so that the candies are one layer thick. You will need to spread the M&Ms to the edges of the plate. Remove all the M&Ms that have the M showing

More information

Chapter 2. Recurrence Relations. Divide and Conquer. Divide and Conquer Strategy. Another Example: Merge Sort. Merge Sort Example. Merge Sort Example

Chapter 2. Recurrence Relations. Divide and Conquer. Divide and Conquer Strategy. Another Example: Merge Sort. Merge Sort Example. Merge Sort Example Recurrence Relations Chapter 2 Divide and Conquer Equation or an inequality that describes a function by its values on smaller inputs. Recurrence relations arise when we analyze the running time of iterative

More information

ISO Lead Auditor Lean Six Sigma PMP Business Process Improvement Enterprise Risk Management IT Sales Training

ISO Lead Auditor Lean Six Sigma PMP Business Process Improvement Enterprise Risk Management IT Sales Training Training Calendar 2014 Public s (ISO LSS PMP BPI ERM IT Sales Training) www.excelledia.com (ISO, LSS, PMP, BPI, ERM, IT, Sales Public s) 1 Schedule Registration JANUARY FEBRUARY 2 days 26 JAN 27 JAN 3

More information

Greedy. Outline CS141. Stefano Lonardi, UCR 1. Activity selection Fractional knapsack Huffman encoding Later:

Greedy. Outline CS141. Stefano Lonardi, UCR 1. Activity selection Fractional knapsack Huffman encoding Later: October 5, 017 Greedy Chapters 5 of Dasgupta et al. 1 Activity selection Fractional knapsack Huffman encoding Later: Outline Dijkstra (single source shortest path) Prim and Kruskal (minimum spanning tree)

More information

8 Priority Queues. 8 Priority Queues. Prim s Minimum Spanning Tree Algorithm. Dijkstra s Shortest Path Algorithm

8 Priority Queues. 8 Priority Queues. Prim s Minimum Spanning Tree Algorithm. Dijkstra s Shortest Path Algorithm 8 Priority Queues 8 Priority Queues A Priority Queue S is a dynamic set data structure that supports the following operations: S. build(x 1,..., x n ): Creates a data-structure that contains just the elements

More information

Allocation of multiple processors to lazy boolean function trees justification of the magic number 2/3

Allocation of multiple processors to lazy boolean function trees justification of the magic number 2/3 Allocation of multiple processors to lazy boolean function trees justification of the magic number 2/3 Alan Dix Computer Science Department University of York, York, YO1 5DD, U.K. alan@uk.ac.york.minster

More information