CSc545 Hashing. Symbol-table problem. Resolving collisions by chaining. Hash functions. Analysis of chaining. Search cost

Similar documents
Introduction to Algorithms 6.046J/18.401J

Introduction to Algorithms

COMP 465: Data Mining More on PageRank

Lecture 5 Single factor design and analysis

Introduction to Algorithms

Empirical equations for electrical parameters of asymmetrical coupled microstrip lines

Data Structures. Element Uniqueness Problem. Hash Tables. Example. Hash Tables. Dana Shapira. 19 x 1. ) h(x 4. ) h(x 2. ) h(x 3. h(x 1. x 4. x 2.

Chapter I Vector Analysis

Chapter Linear Regression

MATHEMATICS II PUC VECTOR ALGEBRA QUESTIONS & ANSWER

2/24/2014. The point mass. Impulse for a single collision The impulse of a force is a vector. The Center of Mass. System of particles

Abhilasha Classes Class- XII Date: SOLUTION (Chap - 9,10,12) MM 50 Mob no

ME306 Dynamics, Spring HW1 Solution Key. AB, where θ is the angle between the vectors A and B, the proof

VECTORS VECTORS VECTORS VECTORS. 2. Vector Representation. 1. Definition. 3. Types of Vectors. 5. Vector Operations I. 4. Equal and Opposite Vectors

2. Elementary Linear Algebra Problems

Difference Sets of Null Density Subsets of

Equations from the Millennium Theory of Inertia and Gravity. Copyright 2004 Joseph A. Rybczyk

THE EQUIVALENCE OF GRAM-SCHMIDT AND QR FACTORIZATION (page 227) Gram-Schmidt provides another way to compute a QR decomposition: n

Lecture 3 summary. C4 Lecture 3 - Jim Libby 1

GENERALIZATION OF AN IDENTITY INVOLVING THE GENERALIZED FIBONACCI NUMBERS AND ITS APPLICATIONS

A Dynamical Quasi-Boolean System

Trigonometry. Trigonometry. Solutions. Curriculum Ready ACMMG: 223, 224, 245.

6.6 The Marquardt Algorithm

Physics 11b Lecture #2. Electric Field Electric Flux Gauss s Law

Physics 207 Lecture 16

The Shape of the Pair Distribution Function.

Rotations.

PHYS 2421 Fields and Waves

Physics 1501 Lecture 19

The Area of a Triangle

Chapter 8. Linear Momentum, Impulse, and Collisions

Week 10: DTMC Applications Ranking Web Pages & Slotted ALOHA. Network Performance 10-1

Energy in Closed Systems

Uniform Circular Motion

A. Proofs for learning guarantees

ME 501A Seminar in Engineering Analysis Page 1

U>, and is negative. Electric Potential Energy

Energy Dissipation Gravitational Potential Energy Power

Chapter 1. Model Theory

Answers to test yourself questions

gravity r2,1 r2 r1 by m 2,1

Introduction to Robotics (Fag 3480)

Radial geodesics in Schwarzschild spacetime

Lecture 9-3/8/10-14 Spatial Description and Transformation

Scalars and Vectors Scalar

Chapter 7. Kleene s Theorem. 7.1 Kleene s Theorem. The following theorem is the most important and fundamental result in the theory of FA s:

Chapter Newton-Raphson Method of Solving a Nonlinear Equation

Data Compression LZ77. Jens Müller Universität Stuttgart

8 Baire Category Theorem and Uniform Boundedness

D. Bertsekas and R. Gallager, "Data networks." Q: What are the labels for the x-axis and y-axis of Fig. 4.2?

Module 4: Moral Hazard - Linear Contracts

arxiv: v2 [cs.it] 11 Jul 2014

A. Thicknesses and Densities


PHY2053 Summer C 2013 Exam 1 Solutions

Chapter Fifiteen. Surfaces Revisited

Exercise sheet 6: Solutions

Professor Wei Zhu. 1. Sampling from the Normal Population

Generating Functions, Weighted and Non-Weighted Sums for Powers of Second-Order Recurrence Sequences

Convolutional Data Transmission System Using Real-Valued Self-Orthogonal Finite-Length Sequences

Moments of Generalized Order Statistics from a General Class of Distributions

{nuy,l^, W%- TEXAS DEPARTMENT OT STATE HEALTH SERVICES

3/20/2013. Splines There are cases where polynomial interpolation is bad overshoot oscillations. Examplef x. Interpolation at -4,-3,-2,-1,0,1,2,3,4

5 - Determinants. r r. r r. r r. r s r = + det det det

Solutions to Assignment 1

The formulae in this booklet have been arranged according to the unit in which they are first

Mathematical Reflections, Issue 5, INEQUALITIES ON RATIOS OF RADII OF TANGENT CIRCLES. Y.N. Aliyev

The linear system. The problem: solve

Problem Set 4 Solutions

X-Ray Notes, Part III

22.615, MHD Theory of Fusion Systems Prof. Freidberg Lecture 20

II The Z Transform. Topics to be covered. 1. Introduction. 2. The Z transform. 3. Z transforms of elementary functions

Links in edge-colored graphs

iclicker Quiz a) True b) False Theoretical physics: the eternal quest for a missing minus sign and/or a factor of two. Which will be an issue today?

30 The Electric Field Due to a Continuous Distribution of Charge on a Line

E-Companion: Mathematical Proofs

Lattice planes. Lattice planes are usually specified by giving their Miller indices in parentheses: (h,k,l)

A Study on Root Properties of Super Hyperbolic GKM algebra

Lecture 7 Circuits Ch. 27

Chapter Eight Notes N P U1C8S4-6

Section 2.3. Matrix Inverses

Class Summary. be functions and f( D) , we define the composition of f with g, denoted g f by

UNIT V: Z-TRANSFORMS AND DIFFERENCE EQUATIONS. Dr. V. Valliammal Department of Applied Mathematics Sri Venkateswara College of Engineering

UNIT10 PLANE OF REGRESSION

Topics for Review for Final Exam in Calculus 16A

Chapter #2 EEE State Space Analysis and Controller Design

Set of square-integrable function 2 L : function space F

Chapter 2 Introduction to Algebra. Dr. Chih-Peng Li ( 李 )

Neural Network Introduction. Hung-yi Lee

Geometric Correction or Georeferencing

] dx (3) = [15x] 2 0

«A first lesson on Mathematical Induction»

Math 4318 : Real Analysis II Mid-Term Exam 1 14 February 2013

Rigid Bodies: Equivalent Systems of Forces

Computer Aided Geometric Design

APPLICATIONS OF SEMIGENERALIZED -CLOSED SETS

A GENERALIZATION OF A CONJECTURE OF MELHAM. 1. Introduction The Fibonomial coefficient is, for n m 1, defined by

(8) Gain Stage and Simple Output Stage

Some Equivalent Forms of Bernoulli s Inequality: A Survey *

This immediately suggests an inverse-square law for a "piece" of current along the line.

Transcription:

CS545 Hshng hnks to Pof. Chles. Leseson Sbol-tble poble Sbol tble holdng n eods: eod ke Othe felds ontnng stellte dt Opetons on : INSR, DL, SARCH, k How should the dt stutue be ognzed? Hsh funtons Ide: Use hsh funton h to p the unvese U of ll kes nto,,, : K k k k 4 k 5 U k3 When eod to be nseted ps to n led As ouped eh ke slot s n nseted,, ollson h ps ous. t to slot of. hk hk 4 hk hk 5 hk 3 Resolvng ollsons b hnng Reods n the se slot e lnked nto lst. 49 86 5 h49 h86 h5 Anlss of hnng We ke the ssupton of sple unfo hshng: h ke k K of kes s equll lkel to be hshed to n slot of tble, ndependent of whee othe kes e hshed. Let n be the nube of kes n the tble, nd let be the nube of slots. Defne the lod fto of to be α n/ vege nube of kes pe slot. Seh ost peted te to seh fo eod wth gven ke Θ + α. ppl hsh funton nd ess slot seh the lst peted seh te Θ f α O, o equvlentl, f n O.

Choosng hsh funton he ssupton of sple unfo hshng s hd to guntee, but sevel oon tehnques tend to wok well n pte s long s the defenes n be voded. Dest: A good hsh funton should dstbute the kes unfol nto the slots of the tble. Regult n the ke dstbuton should not ffet ths unfot. Dvson ethod Assue ll kes e nteges, nd defne hk k od. Defen: Don t pk n tht hs sll dvso d. A pepondene of kes tht e onguent odulo d n dvesel ffet unfot. tee defen: If, then the hsh doesn t even depend on ll the bts of k: If k nd 6, then hk. hk Dvson ethod ontnued hk k od. Pk to be pe not too lose to powe of o nd not othewse used ponentl n the oputng envonent. Annone: Soetes, kng the tble sze pe s nonvenent. But, ths ethod s popul, lthough the net ethod we ll see s usull supeo. Multplton ethod Assue tht ll kes e nteges,, nd ou opute hs w-bt wods. Defne hk A k od w sh w, whee sh s the bt-wse ght-shft opeto nd A s n odd ntege n the nge w < A < w. Don t pk A too lose to w. Multplton odulo w s fst. he sh opeto s fst. Multplton ethod eple hk A k od w sh w Suppose tht 8 3 nd tht ou opute hs w 7-bt wods: A 7 k. 6 5 4 3 hk A Modul wheel.. 3A A Dot-podut ethod Rndozed stteg: Let be pe. Deopose ke k nto + dgts, eh wth vlue n the set,,,. ht s, let k k, k,, k, whee k <. Pk,,, whee eh s hosen ndol fo,,,. Defne h k k od. ellent n pte, but epensve to opute.

Resolvng ollsons b open ddessng No stoge s used outsde of the hsh tble tself.. he hsh funton depends on both the ke nd pobe nube: h : U,,,,,,..g. hk k+ od ; hk k+ od Insetng ke k: we hek Τhk,. If ept we nset k, thee. Othewse, we hek Τhk,. If ept we nset k, thee. Othewse, othewse et fo hk,, hk,,, hk,. Mntenne Sn the tble fo te to te, nd get d of ll of ll dues. Fndng ke k: we hek f Τhk, s ept, nd f k. If not we hek f Τhk, s ept, nd f k. If not othewse et fo hk,, hk,,, hk,. Deletng ke k Fnd t e eple wth du wh Resolvng ollsons b open ddessng - ont ple of open ddessng No stoge s used outsde of the hsh tble tself. he pobe sequene hk,, hk,,, hk, should be peutton of,,,. he tble fll up, nd deleton s dffult but not possble. Inset ke k 496:. Pobe h496, 586 33 4 ollson 48 ple of open ddessng ple of open ddessng Inset ke k 496:. Pobe h496,. Pobe h496, 586 ollson 33 4 48 Inset ke k 496:. Pobe h496,. Pobe h496,. Pobe h496, 586 33 4 496 48 nseton

ple of open ddessng Seh fo ke k 496:. Pobe h496,. Pobe h496,. Pobe h496, 586 33 4 496 48 Seh uses the se pobe sequene, tentng suessfull f t fnds the ke nd unsuessfull f t enountes n ept slot. Pobng stteges Lne pobng: Gven n odn hsh funton h k, lne pobng uses the hsh funton hk, h k + od. hs ethod, though sple, suffes fo p lusteng, whee long uns of ouped slots buld up, nesng the vege seh te. Moeove, the long uns of ouped slots tend to get longe. Pobng stteges Double hshng Gven two odn hsh funtons h k nd h k, double hshng uses the hsh funton hk, h k + h k od. hs ethod genell podues eellent esults, but h k ust be eltvel pe to. One w s to ke powe of nd desgn h k to podue onl odd nubes. Anlss of open ddessng We ke the ssupton of unfo hshng: h ke s equll lkel to hve n one of the! peuttons s ts pobe sequene. heoe. Gven n open-ddessed hsh tble wth lod fto α n/ <, the epeted nube of pobes n n unsuessful seh s t ost / α. Poof of the theoe Poof. At lest one pobe s lws neess. Wth pobblt n/, the fst pobe hts n ouped slot, nd seond pobe s neess. Wth pobblt n /, the seond pobe hts n ouped slot, nd thd pobe s neess. Wth pobblt n /, the thd pobe hts n ouped slot, et. Obseve tht n < n α fo,,, n. Poof ontnued heefoe, the epeted nube of pobes s + n + n + n L + L n + + α + α + α L + α L + α + α + α 3 + L α. α he tetbook hs oe goous poof.

Ipltons of the theoe If α s onstnt, then essng n openddessed hsh tble tkes onstnt te. If the tble s hlf full, then the epeted nube of pobes s /.5. If the tble s 9% full, then the epeted nube of pobes s /.9. A wekness of hshng Poble: Fo n hsh funton h, set of kes ests tht n use the vege ess te of hsh tble to skoket. An dves n pk ll kes fo k U : hk fo soe slot. IDA: Choose the hsh funton t ndo, ndependentl of the kes. ven f n dves n see ou ode, he o she nnot fnd bd set of kes, sne he o she doesn t know etl whh hsh funton wll be hosen. Unvesl hshng Defnton. Let U be unvese of kes, nd let H be fnte olleton of hsh funtons, eh ppng U to,,,. We s H s unvesl f fo ll, U, whee, we hve h H : h h H /. ht s, the hne of ollson between nd s / f we hoose h ndol fo H. h : h h H H Unveslt s good heoe. Let h be hsh funton hosen unfol t ndo fo unvesl set H of hsh funtons. Suppose h s used to hsh n bt kes nto the slots of tble. hen, fo gven ke, we hve #ollsons wth < n/. Poof of theoe Poof ontnued Poof. Let C be the ndo vble denotng the totl nube of ollsons of kes n wth, nd let f h h, othewse. Note: / nd C. C ke epetton of both sdes.

Poof ontnued C Lnet of epetton. ke epetton of both sdes. Poof ontnued / C /. Lnet of epetton. ke epetton of both sdes. Poof ontnued n C / ke epetton of both sdes. Lnet of epetton. /. Algeb.. RMMBR HIS! Let be pe. Deopose ke k nto + dgts, eh wth vlue n the set,,,. ht s, let k k, k,, k, whee k <. Rndozed stteg: Pk,,, whee eh s hosen ndol fo,,,. k k h od Defne. How bg s H h? H +. Dot podut, odulo Unveslt of dot-podut hsh funtons heoe. he set H h s unvesl. Poof. Suppose tht,,, nd,,, be dstnt kes. hus, the dffe n t lest one dgt poston, wlog poston. Fo how n h H do nd ollde? od. We ust hve h h, whh ples tht Poof ontnued quvlentl, we hve od o od + od whh ples tht,.

Ft fo nube theo heoe. Let be pe. Fo n z Z suh tht z, thee ests unque z Z suh tht z z od. ple: 7. z 3 4 5 6 z 4 5 3 6 We hve Bk to the poof od, nd sne, n nvese ust est, whh ples tht od. hus, fo n hoes of,,,, etl one hoe of uses nd to ollde. Poof opleted Q. How n h s use nd to ollde? A. hee e hoes fo eh of,,,, but one these e hosen, etl one hoe fo uses nd to ollde, nel od. hus, the nube of h s tht use nd to ollde s H /. Pefet hshng Gven set of n kes, onstut stt hsh tble of sze On suh tht SARCH tkes Θ te n the wost se. IDA: wolevel shee 4 3 3 wth unvesl hshng t 3 both levels. 4 6 6 5 No ollsons 6 9 t level! 86 86 4 S 4 47 h S 3 4 h 3 7 4 S 6 4 37 37 3 4 5 6 7 8 Collsons t level heoe. Let H be lss of unvesl hsh funtons fo tble of sze n. hen, f we use ndo h H to hsh n kes nto the tble, the epeted nube of ollsons s t ost /. Poof. B the defnton of unveslt, the pobblt tht gven kes n the tble ollde unde h s / /n n. Sne thee e ps of kes tht n possbl ollde, the epeted nube of ollsons s n n n <. n n No ollsons t level Cooll. he pobblt of no ollsons s t lest /. Poof. Mkov s neqult ss tht fo n nonnegtve ndo vble X, we hve PX t X/t. Applng ths neqult wth t, we fnd tht the pobblt of o oe ollsons s t ost /. hus, just b testng ndo hsh funtons n H, we ll qukl fnd one tht woks.

Anlss of stoge Fo the level- hsh tble, hoose n, nd let n be ndo vble fo the nube of kes tht hsh to slot n. B usng n slots fo the level- hsh tble S, the epeted totl stoge equed fo the two-level shee s theefoe Θ n Θ n sne the nlss s dentl to the nlss fo etton of the epeted unnng te of buket sot. Fo pobblt bound, ppl Mkov.,