Hash Table Analysis. e(k) = bp(k). kp(k) = n b.

Size: px
Start display at page:

Download "Hash Table Analysis. e(k) = bp(k). kp(k) = n b."

Transcription

1 Septemer 1, 2016 Hash Tale Analysis Assume that we have a hash tale structured as a vector of lists, resolving collisions y sequential search of uckets, as in the generic hash tale template HashTale<K,D,H> distriuted in the file hashtl.h. Let n denote the numer of items in the tale [tale size] and denote the numer of uckets (or slots) in the tale implementation. At this point we make no assumptions aout the hash function. Proposition 1. Denote y e(k) the expected numer of uckets of size k and y p(k) the proaility a given ucket has exactly k items. Then e(k) = p(k). Proof. e(k) = expected value = (frequency) (proaility) = p(k). Proposition 2. Let p(k) denote the proaility a given ucket has exactly k items. Then the expected ucket size is n kp(k) = n. k=0 Proof. The expected value of ucket size is the sum of (the expected value of size of uckets of size k) (proaility a ucket has size k), where expected value of size of uckets of size k = k proaility a ucket has size k = p(k) duh definition of p(k) Sustituting, we get the formula on the left for expected value of ucket size. On the other hand, there are n items in uckets, so the average ucket size is n/, the formula on the right. Proposition 3. Let a[k] denote the actual numer of uckets of size k. Then the size of the tale is n = k 0 ka[k]. Proof. The numer of items in uckets of size k is k a[k]. Since each item is in at most one ucket, the sum on the right does not overcount the numer of items. Since each item is in at least one ucket, the sum on the right does not undercount either. So the sum must e the numer n of items. 1

2 Remark. The smallest safe upper index for the sum in the formula aove is the maximum ucket size, ecause there are no items in uckets with size greater than the maximum. We could also say that n is the smallest safe upper index for the sum, if we want a data independent answer. n is attained in the most dismal case where all items end up in the same ucket, which would make a[i] = 0 for i < n and a[n] = 1, reducing the sum to n = n a[n]. Assume now that we have assigned keys to uckets randomly, so that each key has a uniformly likely proaility of eing assigned to a ucket. (This is called simple uniform hashing in the textook - see page 259.) Proposition 4. The proaility that a given ucket is empty is ( ) n 1 p(0) =. Proof. The proaility that one particular item is not in a given ucket is the proaility it is in some other ucket. There are uckets in total, so there are 1 other uckets. Thus the proaility that one particular item is not in a given ucket is q = ( 1)/. The proaility that two particular items are oth not in that ucket is the product q q = q 2. Reasoning y induction, it follows that the proaility that k particular items are not in a given ucket is q k 1 q = q k. Finally, then, the proaility that none of the n items is in the given ucket is q n. Proposition 5. Assume simple uniform hashing and 0 k n. The proaility that a given ucket has size k is ( )( ) k ( ) n k n 1 1 p(k) =. k Proof. This is a refinement of the argument aove. Note that the proaility that an item is in a given ucket is p = 1/ and the proaility it is not in that ucket is q = 1 p = ( 1)/. If we have a particular choice of k items, the proaility that exactly these items are in a given ucket is p k q n k, ecause those k items are each in the ucket, accounting for the p k factor, and the remaining n k items are not in the ucket, accounting for the q n k factor. There are ( n k) independent choices of exactly k items to put in the ucket, so the proaility that the given ucket has size k is the sum of p k q n k over all these independent ways of selecting k items: ( n k) p k q n k = i=1 ( ) n p k q n k k 2

3 Proposition 6. Assume simple uniform hashing. The ucket size distriution e(k) satisfies the iterative calculation (recurrence): ( ) n 1 e(0) = initial condition ( ) ( ) n k e(k) = e(k 1) for k = 1... n. k 1 e(k) = 0 for k > n. 3 Proof. We use the notation estalished aove: p = 1/, q = ( 1)/. Note that p + q = 1 and p/q = 1/( 1). First the initializer: e(0) = p(0) Proposition 2 ( ) n 1 = Proposition 4 Then the recurrence: e(k) e(k 1) = p(k) p(k 1) Proposition 2 = p(k) cancel p(k 1) ( n ) k p k q n k = ( n ) Proposition 5 k 1 p k 1 q n k+1 (n k + 1)p = applying definitions and simplifying kq ( ) ( ) n k = sustituting p/q = 1/( 1) k 1 Multiplying y e(k 1) completes the proof for the iterative formula. Finally, note that no ucket can have more than n items, so e(k) = 0 when k > n.

4 Hash Tale Analysis Algorithms. Assumptions: n = tale size, = numer of uckets Analysis of a specific hash tale, with a specified hash function, numer of uckets, and loaded data set, can e an important feature of hash tale implementations, simply due to the variaility of performance of hashing, particularly on non-random data where a ias in the hashing specified may exist. The results aove provide ackground needed to devise algorithms required for such an analysis. Algorithm 1: Maximum Bucket Size Runtime : Θ() + cost of calls to size = Θ( + n) typical unsigned long MaxBucketSize () unsigned long max = 0 for ( size_t i = 0; i < ; ++ i) s = size of ucket i if ( max < s) max = s return max ; Algorithm 2: Actual Bucket Size Distriution Runtime : Θ( + n) void ActualBucketSizeDistriution ( Vector < unsigned long >& sizecount ) // calculate and set size of distriution m = MaxBucketSize (); sizecount. SetSize (1+m,0); 4 // calculate distriution for ( size_t i = 0; i < ; ++ i) ++ sizecount [ size of ucket i]; Algorithm 3: Numer of Non - Empty Buckets Runtime : 1 + cost of uck size distriution = Θ( + n) typical Numer of non - empty uckets = - sizecount [0];

5 Algorithm 4: Simple Uniform Hashing Bucket Size Distriution Runtime : Θ(n) void ExpectedBucketSizeDistriution ( Vector < float >& expdcount ) expdcount. SetSize (1+ n,0.0); // set size of distriution expdcount [0] = ( -1)/ ; expdcount [0] = pow ( expdcount [0],n -1); expdcount [0] *= ( -1); for ( size_t k = 1; k < 1+n; ++k) expdcount [k] = ((n-k +1)/(( -1)* k)) * expdcount [k -1]; 5 Remark. The distriution calculated in Algorithm 4 is a inomial distriution, so named ecause of the relationship with inomial choice and the expansion of the inomial (A + B) n [with A = and B = ( 1)/)]: (A + B) n = A n + na n 1 B ( n k ) A k B n k B n In this context, ecause the 1 1 factors are much smaller than the factors, it is very closely approximated y the Poisson distriution. 1 Algorithm 4 calculates many more terms than would normally e useful in practice - most of them are so small they equate to zero in float representation. It is therefore usually a waste of space and time to allocate the entire vector of size 1 + n and calculate all of its elements. In the case here, it is more prudent to allocate space of size 1 + m and, if a few more values are needed, calculate them on the fly (continuing the same iterative process, starting at the (1 + m)th value expdcount[m]) without storing them. 1 See entries in Wikipedia and NIST Handook.

Data Structures and Algorithm. Xiaoqing Zheng

Data Structures and Algorithm. Xiaoqing Zheng Data Structures and Algorithm Xiaoqing Zheng zhengxq@fudan.edu.cn MULTIPOP top[s] = 6 top[s] = 2 3 2 8 5 6 5 S MULTIPOP(S, x). while not STACK-EMPTY(S) and k 0 2. do POP(S) 3. k k MULTIPOP(S, 4) Analysis

More information

Searching. Constant time access. Hash function. Use an array? Better hash function? Hash function 4/18/2013. Chapter 9

Searching. Constant time access. Hash function. Use an array? Better hash function? Hash function 4/18/2013. Chapter 9 Constant time access Searching Chapter 9 Linear search Θ(n) OK Binary search Θ(log n) Better Can we achieve Θ(1) search time? CPTR 318 1 2 Use an array? Use random access on a key such as a string? Hash

More information

Solutions. Problem 1: Suppose a polynomial in n of degree d has the form

Solutions. Problem 1: Suppose a polynomial in n of degree d has the form Assignment 1 1. Problem 3-1 on p. 57 2. Problem 3-2 on p. 58 3. Problem 4-5 on p. 86 4. Problem 6-1 on p. 142 5. Problem 7-4 on p. 162 6. Prove correctness (including halting) of SelectionSort (use loop

More information

Hash Tables. Given a set of possible keys U, such that U = u and a table of m entries, a Hash function h is a

Hash Tables. Given a set of possible keys U, such that U = u and a table of m entries, a Hash function h is a Hash Tables Given a set of possible keys U, such that U = u and a table of m entries, a Hash function h is a mapping from U to M = {1,..., m}. A collision occurs when two hashed elements have h(x) =h(y).

More information

1Number ONLINE PAGE PROOFS. systems: real and complex. 1.1 Kick off with CAS

1Number ONLINE PAGE PROOFS. systems: real and complex. 1.1 Kick off with CAS 1Numer systems: real and complex 1.1 Kick off with CAS 1. Review of set notation 1.3 Properties of surds 1. The set of complex numers 1.5 Multiplication and division of complex numers 1.6 Representing

More information

The variance for partial match retrievals in k-dimensional bucket digital trees

The variance for partial match retrievals in k-dimensional bucket digital trees The variance for partial match retrievals in k-dimensional ucket digital trees Michael FUCHS Department of Applied Mathematics National Chiao Tung University January 12, 21 Astract The variance of partial

More information

Fundamental Algorithms

Fundamental Algorithms Chapter 5: Hash Tables, Winter 2018/19 1 Fundamental Algorithms Chapter 5: Hash Tables Jan Křetínský Winter 2018/19 Chapter 5: Hash Tables, Winter 2018/19 2 Generalised Search Problem Definition (Search

More information

Lecture Notes for Chapter 17: Amortized Analysis

Lecture Notes for Chapter 17: Amortized Analysis Lecture Notes for Chapter 17: Amortized Analysis Chapter 17 overview Amortized analysis Analyze a sequence of operations on a data structure. Goal: Show that although some individual operations may be

More information

Motivation. Dictionaries. Direct Addressing. CSE 680 Prof. Roger Crawfis

Motivation. Dictionaries. Direct Addressing. CSE 680 Prof. Roger Crawfis Motivation Introduction to Algorithms Hash Tables CSE 680 Prof. Roger Crawfis Arrays provide an indirect way to access a set. Many times we need an association between two sets, or a set of keys and associated

More information

( ) ( ) or ( ) ( ) Review Exercise 1. 3 a 80 Use. 1 a. bc = b c 8 = 2 = 4. b 8. Use = 16 = First find 8 = 1+ = 21 8 = =

( ) ( ) or ( ) ( ) Review Exercise 1. 3 a 80 Use. 1 a. bc = b c 8 = 2 = 4. b 8. Use = 16 = First find 8 = 1+ = 21 8 = = Review Eercise a Use m m a a, so a a a Use c c 6 5 ( a ) 5 a First find Use a 5 m n m n m a m ( a ) or ( a) 5 5 65 m n m a n m a m a a n m or m n (Use a a a ) cancelling y 6 ecause n n ( 5) ( 5)( 5) (

More information

CSCB63 Winter Week10 - Lecture 2 - Hashing. Anna Bretscher. March 21, / 30

CSCB63 Winter Week10 - Lecture 2 - Hashing. Anna Bretscher. March 21, / 30 CSCB63 Winter 2019 Week10 - Lecture 2 - Hashing Anna Bretscher March 21, 2019 1 / 30 Today Hashing Open Addressing Hash functions Universal Hashing 2 / 30 Open Addressing Open Addressing. Each entry in

More information

Searching, mainly via Hash tables

Searching, mainly via Hash tables Data structures and algorithms Part 11 Searching, mainly via Hash tables Petr Felkel 26.1.2007 Topics Searching Hashing Hash function Resolving collisions Hashing with chaining Open addressing Linear Probing

More information

Randomized Load Balancing:The Power of 2 Choices

Randomized Load Balancing:The Power of 2 Choices Randomized Load Balancing: The Power of 2 Choices June 3, 2010 Balls and Bins Problem We have m balls that are thrown into n bins, the location of each ball chosen independently and uniformly at random

More information

Hash tables. Hash tables

Hash tables. Hash tables Basic Probability Theory Two events A, B are independent if Conditional probability: Pr[A B] = Pr[A] Pr[B] Pr[A B] = Pr[A B] Pr[B] The expectation of a (discrete) random variable X is E[X ] = k k Pr[X

More information

Hash tables. Hash tables

Hash tables. Hash tables Dictionary Definition A dictionary is a data-structure that stores a set of elements where each element has a unique key, and supports the following operations: Search(S, k) Return the element whose key

More information

Hash tables. Hash tables

Hash tables. Hash tables Dictionary Definition A dictionary is a data-structure that stores a set of elements where each element has a unique key, and supports the following operations: Search(S, k) Return the element whose key

More information

CS 161 Summer 2009 Homework #2 Sample Solutions

CS 161 Summer 2009 Homework #2 Sample Solutions CS 161 Summer 2009 Homework #2 Sample Solutions Regrade Policy: If you believe an error has been made in the grading of your homework, you may resubmit it for a regrade. If the error consists of more than

More information

Hash Tables. Direct-Address Tables Hash Functions Universal Hashing Chaining Open Addressing. CS 5633 Analysis of Algorithms Chapter 11: Slide 1

Hash Tables. Direct-Address Tables Hash Functions Universal Hashing Chaining Open Addressing. CS 5633 Analysis of Algorithms Chapter 11: Slide 1 Hash Tables Direct-Address Tables Hash Functions Universal Hashing Chaining Open Addressing CS 5633 Analysis of Algorithms Chapter 11: Slide 1 Direct-Address Tables 2 2 Let U = {0,...,m 1}, the set of

More information

Lecture: Analysis of Algorithms (CS )

Lecture: Analysis of Algorithms (CS ) Lecture: Analysis of Algorithms (CS483-001) Amarda Shehu Spring 2017 1 Outline of Today s Class 2 Choosing Hash Functions Universal Universality Theorem Constructing a Set of Universal Hash Functions Perfect

More information

Introduction to Hash Tables

Introduction to Hash Tables Introduction to Hash Tables Hash Functions A hash table represents a simple but efficient way of storing, finding, and removing elements. In general, a hash table is represented by an array of cells. In

More information

CS 5321: Advanced Algorithms Amortized Analysis of Data Structures. Motivations. Motivation cont d

CS 5321: Advanced Algorithms Amortized Analysis of Data Structures. Motivations. Motivation cont d CS 5321: Advanced Algorithms Amortized Analysis of Data Structures Ali Ebnenasir Department of Computer Science Michigan Technological University Motivations Why amortized analysis and when? Suppose you

More information

Graduate Analysis of Algorithms Dr. Haim Levkowitz

Graduate Analysis of Algorithms Dr. Haim Levkowitz UMass Lowell Computer Science 9.53 Graduate Analysis of Algorithms Dr. Haim Levkowitz Fall 27 Lecture 5 Tuesday, 2 Oct 27 Amortized Analysis Overview Amortize: To pay off a debt, usually by periodic payments

More information

Robot Position from Wheel Odometry

Robot Position from Wheel Odometry Root Position from Wheel Odometry Christopher Marshall 26 Fe 2008 Astract This document develops equations of motion for root position as a function of the distance traveled y each wheel as a function

More information

Stirling Numbers of the 1st Kind

Stirling Numbers of the 1st Kind Daniel Reiss, Colebrook Jackson, Brad Dallas Western Washington University November 28, 2012 Introduction The set of all permutations of a set N is denoted S(N), while the set of all permutations of {1,

More information

ANOVA 3/12/2012. Two reasons for using ANOVA. Type I Error and Multiple Tests. Review Independent Samples t test

ANOVA 3/12/2012. Two reasons for using ANOVA. Type I Error and Multiple Tests. Review Independent Samples t test // ANOVA Lectures - Readings: GW Review Independent Samples t test Placeo Treatment 7 7 7 Mean... Review Independent Samples t test Placeo Treatment 7 7 7 Mean.. t (). p. C. I.: p t tcrit s pt crit s t

More information

CS5314 Randomized Algorithms. Lecture 15: Balls, Bins, Random Graphs (Hashing)

CS5314 Randomized Algorithms. Lecture 15: Balls, Bins, Random Graphs (Hashing) CS5314 Randomized Algorithms Lecture 15: Balls, Bins, Random Graphs (Hashing) 1 Objectives Study various hashing schemes Apply balls-and-bins model to analyze their performances 2 Chain Hashing Suppose

More information

If X = c is the lower boundary of the upper critical region, require P( Xc

If X = c is the lower boundary of the upper critical region, require P( Xc Quality of tests 8A a H :p=.5 H :p>.5, so that X B(,.5), so require suh that P( X) .5 and P(

More information

Hashing. Dictionaries Hashing with chaining Hash functions Linear Probing

Hashing. Dictionaries Hashing with chaining Hash functions Linear Probing Hashing Dictionaries Hashing with chaining Hash functions Linear Probing Hashing Dictionaries Hashing with chaining Hash functions Linear Probing Dictionaries Dictionary: Maintain a dynamic set S. Every

More information

Application: Bucket Sort

Application: Bucket Sort 5.2.2. Application: Bucket Sort Bucket sort breaks the log) lower bound for standard comparison-based sorting, under certain assumptions on the input We want to sort a set of =2 integers chosen I+U@R from

More information

Lecture 5: Loop Invariants and Insertion-sort

Lecture 5: Loop Invariants and Insertion-sort Lecture 5: Loop Invariants and Insertion-sort COMS10007 - Algorithms Dr. Christian Konrad 11.01.2019 Dr. Christian Konrad Lecture 5: Loop Invariants and Insertion-sort 1 / 12 Proofs by Induction Structure

More information

Chapter 7. 1 a The length is a function of time, so we are looking for the value of the function when t = 2:

Chapter 7. 1 a The length is a function of time, so we are looking for the value of the function when t = 2: Practice questions Solution Paper type a The length is a function of time, so we are looking for the value of the function when t = : L( ) = 0 + cos ( ) = 0 + cos ( ) = 0 + = cm We are looking for the

More information

UNIT 5 QUADRATIC FUNCTIONS Lesson 2: Creating and Solving Quadratic Equations in One Variable Instruction

UNIT 5 QUADRATIC FUNCTIONS Lesson 2: Creating and Solving Quadratic Equations in One Variable Instruction Lesson : Creating and Solving Quadratic Equations in One Variale Prerequisite Skills This lesson requires the use of the following skills: understanding real numers and complex numers understanding rational

More information

EVALUATIONS OF EXPECTED GENERALIZED ORDER STATISTICS IN VARIOUS SCALE UNITS

EVALUATIONS OF EXPECTED GENERALIZED ORDER STATISTICS IN VARIOUS SCALE UNITS APPLICATIONES MATHEMATICAE 9,3 (), pp. 85 95 Erhard Cramer (Oldenurg) Udo Kamps (Oldenurg) Tomasz Rychlik (Toruń) EVALUATIONS OF EXPECTED GENERALIZED ORDER STATISTICS IN VARIOUS SCALE UNITS Astract. We

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

:s ej2mttlm-(iii+j2mlnm )(J21nm/m-lnm/m)

:s ej2mttlm-(iii+j2mlnm )(J21nm/m-lnm/m) BALLS, BINS, AND RANDOM GRAPHS We use the Chernoff bound for the Poisson distribution (Theorem 5.4) to bound this probability, writing the bound as Pr(X 2: x) :s ex-ill-x In(x/m). For x = m + J2m In m,

More information

Algorithms for Data Science

Algorithms for Data Science Algorithms for Data Science CSOR W4246 Eleni Drinea Computer Science Department Columbia University Tuesday, December 1, 2015 Outline 1 Recap Balls and bins 2 On randomized algorithms 3 Saving space: hashing-based

More information

Solving Systems of Linear Equations Symbolically

Solving Systems of Linear Equations Symbolically " Solving Systems of Linear Equations Symolically Every day of the year, thousands of airline flights crisscross the United States to connect large and small cities. Each flight follows a plan filed with

More information

Online Supplementary Appendix B

Online Supplementary Appendix B Online Supplementary Appendix B Uniqueness of the Solution of Lemma and the Properties of λ ( K) We prove the uniqueness y the following steps: () (A8) uniquely determines q as a function of λ () (A) uniquely

More information

PRODUCTS THAT ARE POWERS. A mathematical vignette Ed Barbeau, University of Toronto

PRODUCTS THAT ARE POWERS. A mathematical vignette Ed Barbeau, University of Toronto PRODUCTS THAT ARE POWERS. A mathematical vignette Ed Barbeau, University of Toronto This investigation was originally designed for school students to gain fluency with the factoring of positive integers

More information

Homework 1 Submission

Homework 1 Submission Homework Submission Sample Solution; Due Date: Thursday, May 4, :59 pm Directions: Your solutions should be typed and submitted as a single pdf on Gradescope by the due date. L A TEX is preferred but not

More information

Divide and Conquer. Arash Rafiey. 27 October, 2016

Divide and Conquer. Arash Rafiey. 27 October, 2016 27 October, 2016 Divide the problem into a number of subproblems Divide the problem into a number of subproblems Conquer the subproblems by solving them recursively or if they are small, there must be

More information

A Lecture on Hashing. Aram-Alexandre Pooladian, Alexander Iannantuono March 22, Hashing. Direct Addressing. Operations - Simple

A Lecture on Hashing. Aram-Alexandre Pooladian, Alexander Iannantuono March 22, Hashing. Direct Addressing. Operations - Simple A Lecture on Hashing Aram-Alexandre Pooladian, Alexander Iannantuono March 22, 217 This is the scribing of a lecture given by Luc Devroye on the 17th of March 217 for Honours Algorithms and Data Structures

More information

k 6, then which of the following statements can you assume to be

k 6, then which of the following statements can you assume to be MA-UY2314 Discrete Mathematics Quiz 9 Name: NYU Net ID: 1.1) Suppose that in a proof by strong induction, the following statement is the inductive hypothesis: For k 6, P(j) is true for any j in the range

More information

Polynomial Degree and Finite Differences

Polynomial Degree and Finite Differences CONDENSED LESSON 7.1 Polynomial Degree and Finite Differences In this lesson, you Learn the terminology associated with polynomials Use the finite differences method to determine the degree of a polynomial

More information

Step 4: Calculate the partial pressures of A, B, C, and D P A = x A *P total ; P B = x B *P total ; P C = x C *P total ; P D = x D *P total ; 2 θ θ

Step 4: Calculate the partial pressures of A, B, C, and D P A = x A *P total ; P B = x B *P total ; P C = x C *P total ; P D = x D *P total ; 2 θ θ 1. sealed container was filled with 1.00 mol,.00 mol, and 1.00 mol D. The following reaction is expected to occur (g) + (g) C(g) + D(g). When equilirium state is estalished, the resulting mixture contains

More information

Example: Use a direct argument to show that the sum of two even integers has to be even. Solution: Recall that an integer is even if it is a multiple

Example: Use a direct argument to show that the sum of two even integers has to be even. Solution: Recall that an integer is even if it is a multiple Use a direct argument to show that the sum of two even integers has to be even. Solution: Recall that an integer is even if it is a multiple of 2, that is, an integer x is even if x = 2y for some integer

More information

Module 1: Analyzing the Efficiency of Algorithms

Module 1: Analyzing the Efficiency of Algorithms Module 1: Analyzing the Efficiency of Algorithms Dr. Natarajan Meghanathan Professor of Computer Science Jackson State University Jackson, MS 39217 E-mail: natarajan.meghanathan@jsums.edu What is an Algorithm?

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

Balls & Bins. Balls into Bins. Revisit Birthday Paradox. Load. SCONE Lab. Put m balls into n bins uniformly at random

Balls & Bins. Balls into Bins. Revisit Birthday Paradox. Load. SCONE Lab. Put m balls into n bins uniformly at random Balls & Bins Put m balls into n bins uniformly at random Seoul National University 1 2 3 n Balls into Bins Name: Chong kwon Kim Same (or similar) problems Birthday paradox Hash table Coupon collection

More information

Cuckoo Hashing and Cuckoo Filters

Cuckoo Hashing and Cuckoo Filters Cuckoo Hashing and Cuckoo Filters Noah Fleming May 7, 208 Preliminaries A dictionary is an abstract data type that stores a collection of elements, located by their key. It supports operations: insert,

More information

Let N > 0, let A, B, and C be constants, and let f and g be any functions. Then: S2: separate summed terms. S7: sum of k2^(k-1)

Let N > 0, let A, B, and C be constants, and let f and g be any functions. Then: S2: separate summed terms. S7: sum of k2^(k-1) Summation Formulas Let > 0, let A, B, and C e constants, and let f and g e any functions. Then: k Cf ( k) C k S: factor out constant f ( k) k ( f ( k) ± g( k)) k S: separate summed terms f ( k) ± k g(

More information

Lecture 7: Amortized analysis

Lecture 7: Amortized analysis Lecture 7: Amortized analysis In many applications we want to minimize the time for a sequence of operations. To sum worst-case times for single operations can be overly pessimistic, since it ignores correlation

More information

NTHU MATH 2810 Midterm Examination Solution Nov 22, 2016

NTHU MATH 2810 Midterm Examination Solution Nov 22, 2016 NTHU MATH 2810 Midterm Examination Solution Nov 22, 2016 A1, B1 24pts a False False c True d True e False f False g True h True a False False c True d True e False f False g True h True A2, B2 14pts a

More information

Quicksort. Where Average and Worst Case Differ. S.V. N. (vishy) Vishwanathan. University of California, Santa Cruz

Quicksort. Where Average and Worst Case Differ. S.V. N. (vishy) Vishwanathan. University of California, Santa Cruz Quicksort Where Average and Worst Case Differ S.V. N. (vishy) Vishwanathan University of California, Santa Cruz vishy@ucsc.edu February 1, 2016 S.V. N. Vishwanathan (UCSC) CMPS101 1 / 28 Basic Idea Outline

More information

Chem(bio) Week 2: Determining the Equilibrium Constant of Bromothymol Blue. Keywords: Equilibrium Constant, ph, indicator, spectroscopy

Chem(bio) Week 2: Determining the Equilibrium Constant of Bromothymol Blue. Keywords: Equilibrium Constant, ph, indicator, spectroscopy Ojectives: Keywords: Equilirium Constant, ph, indicator, spectroscopy Prepare all solutions for measurement of the equilirium constant for romothymol Make a series of spectroscopic measurements on the

More information

Collision. Kuan-Yu Chen ( 陳冠宇 ) TR-212, NTUST

Collision. Kuan-Yu Chen ( 陳冠宇 ) TR-212, NTUST Collision Kuan-Yu Chen ( 陳冠宇 ) 2018/12/17 @ TR-212, NTUST Review Hash table is a data structure in which keys are mapped to array positions by a hash function When two or more keys map to the same memory

More information

Completing the Square

Completing the Square 3.5 Completing the Square Essential Question How can you complete the square for a quadratic epression? Using Algera Tiles to Complete the Square Work with a partner. Use algera tiles to complete the square

More information

6.854 Advanced Algorithms

6.854 Advanced Algorithms 6.854 Advanced Algorithms Homework Solutions Hashing Bashing. Solution:. O(log U ) for the first level and for each of the O(n) second level functions, giving a total of O(n log U ) 2. Suppose we are using

More information

1 Probability Review. CS 124 Section #8 Hashing, Skip Lists 3/20/17. Expectation (weighted average): the expectation of a random quantity X is:

1 Probability Review. CS 124 Section #8 Hashing, Skip Lists 3/20/17. Expectation (weighted average): the expectation of a random quantity X is: CS 24 Section #8 Hashing, Skip Lists 3/20/7 Probability Review Expectation (weighted average): the expectation of a random quantity X is: x= x P (X = x) For each value x that X can take on, we look at

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

Dynamical Systems Solutions to Exercises

Dynamical Systems Solutions to Exercises Dynamical Systems Part 5-6 Dr G Bowtell Dynamical Systems Solutions to Exercises. Figure : Phase diagrams for i, ii and iii respectively. Only fixed point is at the origin since the equations are linear

More information

1 Maintaining a Dictionary

1 Maintaining a Dictionary 15-451/651: Design & Analysis of Algorithms February 1, 2016 Lecture #7: Hashing last changed: January 29, 2016 Hashing is a great practical tool, with an interesting and subtle theory too. In addition

More information

Sorting algorithms. Sorting algorithms

Sorting algorithms. Sorting algorithms Properties of sorting algorithms A sorting algorithm is Comparison based If it works by pairwise key comparisons. In place If only a constant number of elements of the input array are ever stored outside

More information

N/4 + N/2 + N = 2N 2.

N/4 + N/2 + N = 2N 2. CS61B Summer 2006 Instructor: Erin Korber Lecture 24, 7 Aug. 1 Amortized Analysis For some of the data structures we ve discussed (namely hash tables and splay trees), it was claimed that the average time

More information

Today: Amortized Analysis

Today: Amortized Analysis Today: Amortized Analysis COSC 581, Algorithms March 6, 2014 Many of these slides are adapted from several online sources Today s class: Chapter 17 Reading Assignments Reading assignment for next class:

More information

Section Summary. Sequences. Recurrence Relations. Summations. Examples: Geometric Progression, Arithmetic Progression. Example: Fibonacci Sequence

Section Summary. Sequences. Recurrence Relations. Summations. Examples: Geometric Progression, Arithmetic Progression. Example: Fibonacci Sequence Section 2.4 1 Section Summary Sequences. Examples: Geometric Progression, Arithmetic Progression Recurrence Relations Example: Fibonacci Sequence Summations 2 Introduction Sequences are ordered lists of

More information

Review for Exam 2/Solutions

Review for Exam 2/Solutions MTH 310-3 Astract Algera I and Numer Theory S18 Review for Eam 2/Solutions 1. Let n e an integer. (a) For 0 n 10, verify that n 2 n + 11 is a prime. () If n 0, 1 and n 0, 1 (mod 11), show that n 2 n +

More information

Problem 1: (Chernoff Bounds via Negative Dependence - from MU Ex 5.15)

Problem 1: (Chernoff Bounds via Negative Dependence - from MU Ex 5.15) Problem 1: Chernoff Bounds via Negative Dependence - from MU Ex 5.15) While deriving lower bounds on the load of the maximum loaded bin when n balls are thrown in n bins, we saw the use of negative dependence.

More information

An Algebraic Approach to the Immutability of the Slope of a Line

An Algebraic Approach to the Immutability of the Slope of a Line An Algeraic Approach to the Immutaility of the Slope of a Line Julia S. Roman Incarnate Word College 01 Broadway San Antonio, Texas 7809 jlroman@tenet.edu For the past forty years educators have een grappling

More information

12 Hash Tables Introduction Chaining. Lecture 12: Hash Tables [Fa 10]

12 Hash Tables Introduction Chaining. Lecture 12: Hash Tables [Fa 10] Calvin: There! I finished our secret code! Hobbes: Let s see. Calvin: I assigned each letter a totally random number, so the code will be hard to crack. For letter A, you write 3,004,572,688. B is 28,731,569½.

More information

SVETLANA KATOK AND ILIE UGARCOVICI (Communicated by Jens Marklof)

SVETLANA KATOK AND ILIE UGARCOVICI (Communicated by Jens Marklof) JOURNAL OF MODERN DYNAMICS VOLUME 4, NO. 4, 010, 637 691 doi: 10.3934/jmd.010.4.637 STRUCTURE OF ATTRACTORS FOR (a, )-CONTINUED FRACTION TRANSFORMATIONS SVETLANA KATOK AND ILIE UGARCOVICI (Communicated

More information

Homework 7 Solutions to Selected Problems

Homework 7 Solutions to Selected Problems Homework 7 Solutions to Selected Prolems May 9, 01 1 Chapter 16, Prolem 17 Let D e an integral domain and f(x) = a n x n +... + a 0 and g(x) = m x m +... + 0 e polynomials with coecients in D, where a

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

? 11.5 Perfect hashing. Exercises

? 11.5 Perfect hashing. Exercises 11.5 Perfect hashing 77 Exercises 11.4-1 Consider inserting the keys 10; ; 31; 4; 15; 8; 17; 88; 59 into a hash table of length m 11 using open addressing with the auxiliary hash function h 0.k/ k. Illustrate

More information

Expansion formula using properties of dot product (analogous to FOIL in algebra): u v 2 u v u v u u 2u v v v u 2 2u v v 2

Expansion formula using properties of dot product (analogous to FOIL in algebra): u v 2 u v u v u u 2u v v v u 2 2u v v 2 Least squares: Mathematical theory Below we provide the "vector space" formulation, and solution, of the least squares prolem. While not strictly necessary until we ring in the machinery of matrix algera,

More information

Written Homework #1: Analysis of Algorithms

Written Homework #1: Analysis of Algorithms Written Homework #1: Analysis of Algorithms CIS 121 Fall 2016 cis121-16fa-staff@googlegroups.com Due: Thursday, September 15th, 2015 before 10:30am (You must submit your homework online via Canvas. A paper

More information

Amortized Analysis (chap. 17)

Amortized Analysis (chap. 17) Amortized Analysis (chap. 17) Not just consider one operation, but a sequence of operations on a given data structure. Average cost over a sequence of operations. Probabilistic analysis: Average case running

More information

Section 2.1: Reduce Rational Expressions

Section 2.1: Reduce Rational Expressions CHAPTER Section.: Reduce Rational Expressions Section.: Reduce Rational Expressions Ojective: Reduce rational expressions y dividing out common factors. A rational expression is a quotient of polynomials.

More information

Mid-term Exam Answers and Final Exam Study Guide CIS 675 Summer 2010

Mid-term Exam Answers and Final Exam Study Guide CIS 675 Summer 2010 Mid-term Exam Answers and Final Exam Study Guide CIS 675 Summer 2010 Midterm Problem 1: Recall that for two functions g : N N + and h : N N +, h = Θ(g) iff for some positive integer N and positive real

More information

Dynamic Fields, Maxwell s Equations (Chapter 6)

Dynamic Fields, Maxwell s Equations (Chapter 6) Dynamic Fields, Maxwell s Equations (Chapter 6) So far, we have studied static electric and magnetic fields. In the real world, however, nothing is static. Static fields are only approximations when the

More information

Mathematical Induction Again

Mathematical Induction Again Mathematical Induction Again James K. Peterson Department of Biological Sciences and Department of Mathematical Sciences Clemson University January 12, 2017 Outline Mathematical Induction Simple POMI Examples

More information

Mathematical Induction Again

Mathematical Induction Again Mathematical Induction Again James K. Peterson Department of Biological Sciences and Department of Mathematical Sciences Clemson University January 2, 207 Outline Mathematical Induction 2 Simple POMI Examples

More information

INTRODUCTION TO HASHING Dr. Thomas Hicks Trinity University. Data Set - SSN's from UTSA Class

INTRODUCTION TO HASHING Dr. Thomas Hicks Trinity University. Data Set - SSN's from UTSA Class Dr. Thomas E. Hicks Data Abstractions Homework - Hashing -1 - INTRODUCTION TO HASHING Dr. Thomas Hicks Trinity University Data Set - SSN's from UTSA Class 467 13 3881 498 66 2055 450 27 3804 456 49 5261

More information

The first property listed above is an incredibly useful tool in divisibility problems. We ll prove that it holds below.

The first property listed above is an incredibly useful tool in divisibility problems. We ll prove that it holds below. 1 Divisiility Definition 1 We say an integer is divisile y a nonzero integer a denoted a - read as a divides if there is an integer n such that = an If no such n exists, we say is not divisile y a denoted

More information

Suppose that you have three coins. Coin A is fair, coin B shows heads with probability 0.6 and coin C shows heads with probability 0.8.

Suppose that you have three coins. Coin A is fair, coin B shows heads with probability 0.6 and coin C shows heads with probability 0.8. Suppose that you have three coins. Coin A is fair, coin B shows heads with probability 0.6 and coin C shows heads with probability 0.8. Coin A is flipped until a head appears, then coin B is flipped until

More information

4.5 Applications of Congruences

4.5 Applications of Congruences 4.5 Applications of Congruences 287 66. Find all solutions of the congruence x 2 16 (mod 105). [Hint: Find the solutions of this congruence modulo 3, modulo 5, and modulo 7, and then use the Chinese remainder

More information

Practical Session #3 - Recursions

Practical Session #3 - Recursions Practical Session #3 - Recursions Substitution method Guess the form of the solution and prove it by induction Iteration Method Convert the recurrence into a summation and solve it Tightly bound a recurrence

More information

Minimum Wages, Employment and. Monopsonistic Competition

Minimum Wages, Employment and. Monopsonistic Competition Minimum Wages, Employment and Monopsonistic Competition V. Bhaskar Ted To University of Essex Bureau of Laor Statistics August 2003 Astract We set out a model of monopsonistic competition, where each employer

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

SIX GEMS FROM C3 & C4

SIX GEMS FROM C3 & C4 008 MEI CONFERENCE SIX GEMS FROM C3 & C4 Nick Lord 7/4/008 . Squared squares [C3: Proof]. Prolem For which whole numers n can a square e su-divided into n smaller squares, not necessarily all of the same

More information

Quicksort (CLRS 7) We previously saw how the divide-and-conquer technique can be used to design sorting algorithm Merge-sort

Quicksort (CLRS 7) We previously saw how the divide-and-conquer technique can be used to design sorting algorithm Merge-sort Quicksort (CLRS 7) We previously saw how the divide-and-conquer technique can be used to design sorting algorithm Merge-sort Partition n elements array A into two subarrays of n/2 elements each Sort the

More information

Exploring Lucas s Theorem. Abstract: Lucas s Theorem is used to express the remainder of the binomial coefficient of any two

Exploring Lucas s Theorem. Abstract: Lucas s Theorem is used to express the remainder of the binomial coefficient of any two Delia Ierugan Exploring Lucas s Theorem Astract: Lucas s Theorem is used to express the remainder of the inomial coefficient of any two integers m and n when divided y any prime integer p. The remainder

More information

Lecture 19 : Chinese restaurant process

Lecture 19 : Chinese restaurant process Lecture 9 : Chinese restaurant process MATH285K - Spring 200 Lecturer: Sebastien Roch References: [Dur08, Chapter 3] Previous class Recall Ewens sampling formula (ESF) THM 9 (Ewens sampling formula) Letting

More information

Tutorial 4. Dynamic Set: Amortized Analysis

Tutorial 4. Dynamic Set: Amortized Analysis Tutorial 4 Dynamic Set: Amortized Analysis Review Binary tree Complete binary tree Full binary tree 2-tree P115 Unlike common binary tree, the base case is not an empty tree, but a external node Heap Binary

More information

Insert Sorted List Insert as the Last element (the First element?) Delete Chaining. 2 Slide courtesy of Dr. Sang-Eon Park

Insert Sorted List Insert as the Last element (the First element?) Delete Chaining. 2 Slide courtesy of Dr. Sang-Eon Park 1617 Preview Data Structure Review COSC COSC Data Structure Review Linked Lists Stacks Queues Linked Lists Singly Linked List Doubly Linked List Typical Functions s Hash Functions Collision Resolution

More information

Materials Science and Engineering A

Materials Science and Engineering A Materials Science and Engineering A 528 (211) 48 485 Contents lists availale at ScienceDirect Materials Science and Engineering A journal homepage: www.elsevier.com/locate/msea Study o strength and its

More information

Hashing. Why Hashing? Applications of Hashing

Hashing. Why Hashing? Applications of Hashing 12 Hashing Why Hashing? Hashing A Search algorithm is fast enough if its time performance is O(log 2 n) For 1 5 elements, it requires approx 17 operations But, such speed may not be applicable in real-world

More information

Randomized Sorting Algorithms Quick sort can be converted to a randomized algorithm by picking the pivot element randomly. In this case we can show th

Randomized Sorting Algorithms Quick sort can be converted to a randomized algorithm by picking the pivot element randomly. In this case we can show th CSE 3500 Algorithms and Complexity Fall 2016 Lecture 10: September 29, 2016 Quick sort: Average Run Time In the last lecture we started analyzing the expected run time of quick sort. Let X = k 1, k 2,...,

More information

An initiation to SPH

An initiation to SPH An initiation to SPH Lucas Braune, Thomas Lewiner Department of Mathematics, PUC Rio Rio de Janeiro, Brazil Figure 1. An SPH simulation of a dam reak. Astract The recent expansion of particle-ased methods

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