{[ promptMessage ]}

Bookmark it

{[ promptMessage ]}

lec0406-Hashing1-ann - Announcements 7 We 6933 Canoe[In s...

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

View Full Document Right Arrow Icon
Background image of page 1

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

View Full Document Right Arrow Icon
Background image of page 2
Background image of page 3

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

View Full Document Right Arrow Icon
Background image of page 4
Background image of page 5

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

View Full Document Right Arrow Icon
Background image of page 6
Background image of page 7

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

View Full Document Right Arrow Icon
Background image of page 8
Background image of page 9

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

View Full Document Right Arrow Icon
Background image of page 10
Background image of page 11

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

View Full Document Right Arrow Icon
Background image of page 12
Background image of page 13
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: Announcements 7% We 6933 Canoe [In] s , availab e. Due 4/15. 11 :59p. Today: Hashing Introduction: Suppose we have the following data... Now suppose our keys are not so nicely described... Keg chit Course Number -> Schedule info Color -> 8MP Vertex -> Set of incident edges Flight number -> arrival information URL -> htmi page Some general vocabulary A dictionary is a structure supporting the following: void insert(kType & k, void remove(kType & k) dType find(kType & k) ’ 4% \‘chz ‘ Andnct‘gnary Overloads the operator for insert and find: =ényDictionary[“Miguel"] = 22; dType d = myDictionary[“Miguel"]; dType & d) Hashing: (defn) Keyspace - a (mathematical) description of the keys for a set of data. Goal: use a function to map the keyspace into a small set of W- I‘M; cJ “¢(‘] \dficc 5 What's fuzzy about this goal? Basic Idea: we seek a mapping, h(k) My] hash function “33-49 Aperfect hash function: Hm, Audion I‘S 5‘ n. black cat) ‘jgtm.HP) ry. spy) = ' . bball player) (glen. butterfly) Gin cereal killer) . ghost) t NmthN-b Collisions: 8" hi: S-{203.205.212‘....5W.595.600) / A Hash Table consists of: ‘ h | H . 1.An array 2.A hash function 3.A collision resolution strategy Hash Functions: - Consist of 2 parts: ___D1. A Hash: Function mapping a key to an integer i A compression: function mapping i into the array cells 0 to n-1. - SUHA: Sim \o Halfwm “MW AFR”: .“ifi’f' “Probu‘aPuui‘fiou ‘3 'b ‘ “we 3‘ ' x. 92.359... unmu 3.. — II“.- 3 3 N an... - Choosing a hash function is tric y... ‘—"'——_—) — Don't create your own (yet) I ‘ ‘ - Smart people can produce poor hash functions (what's a Ead hash fynction?) - Knuth": rnulbpbcativo hash in ‘lhe M 04 Conwlev Progremrnng' ) ’, } Hash Functions: - Computed in a“) time. ml: m «\oij uni-ant - Deterministic. MKXLW ‘5 0‘ Mi"? &_ - Satist the SUHA. Hash Functions strspage Easy, if |KeySpace| ~ N Hashing Strings (an example) Given: 8 character strings are easy to hash The idea: Select 8 random positions from long st A bunch of strings: “‘1L_-gb,rtcz- . liurk, ~1n: rt h a.: '1 going L 1. “» :.‘;-! h, 1-3c-u»11c)....- azv ' J ‘..a real dead N a a-‘ "I!" 15 than ~orn~<' -.-. 2'1 s:'tan harv- ' to 'h- VIII} :1 y ‘x at! " rv-sls‘tahJ-n 3' an" 1.4' In.— kx;, I m: .kll.‘:'l I 4 1.! an :au, nu! 'h..l '.I¢ 41!qu n! . A t Him! in In :rat‘ 1!. -- )5 a I"h¢: 11 'IJnQ. Kn nos: flow, 7cm, hun't I u .an, but {ti-mlly .t, ~11; 1y Ia, ‘I'rwn Y . H. -:l.1n't do that rur‘B ! swu- zn't awn? ’ 3. v1.1 IXIH’T wrl :y? (in-f, :h‘ .'d 53., '1tph' Tum any-«1’9 ' !' i‘my'j ."« 1.”. y ‘x. '-- .:k. You 'A~‘|J1-’Jh.t .u-k x15 ":1"! t fry! 50m" t."—-. 9' mam} In A01], i'LL ‘1 LoLB Zu 'hu -S'Jd~x fut a h an )no icv fund 1:. L2 3' u'l; .ct me All :1-3!‘.'. liu:k, x": a u.‘n.:f C‘rc along 14111 you“ '1" f' -- d '-.1'. cu? T'at’; qc '- I Aqt. d Ihnnqv . 1' l r":ko- gvlvnlo- a 't'ou m Q: bl. '. Winn '1 ‘1 (1 tag Vt start Jh, :LJ!.' 012. He'll qs'. [La 1.0).. toqelh ngflud hash that substring. Hashing Strings (an example) Given: 8 character strings are easy to hash The idea: Select 8 random positions from Io bunch of strings: A in; Ltt;:’flon.u.t1ptdia. :q http:'£on.u;k3p¢dta.crq httrt'fen.w1kzprdto.firq httrt’fen.w1kip'dia.‘rq thp:/!un.w.k5p~4ia.szg All; :«',«’an.-.k3pwiia. r4; htt;:#£en.w;kiprdta.’rq LII; :v' ,v’unya'akifio-IHG.JK<; ntty:/xan.w:kir«dia.nrq nttytx/on.w:kir+4ia.qu tht:#len.w.k3;~Jta.)rq Lttytlfen.w;k5;cdta.3rq httyzflfen.wzkir*dio.)rq Lt:p:rflan.uxk5;~dia.4:g http:ffcn.w1k1;cdla.3rq http://en.w1kapcdlc.)rq Lttgzvflon.w1k5;«41c.3rq nt152/Nen.wiktr«lio.wtq httgz'xon.wtk1p+dlc.)rq, http:/Ion.wxxzpsdta.azq: all) H111 vth Hikz all; viii H1!) ail: viii vlkx ail) will H1!) .11; Viki Hlkl all; Hlki at!) Hill Lo'FUI9Bno_Crobld st ngs mu hash that substring. Bluw_tho_Man_Down 5wr*_K‘C3\B6nlq f‘0h_Covalry_Conmando_Reqinent_iAustralxal Alma" ZbrahlmrMohAnod All A1 Khalxla High I‘mhuol h: w c ou/ k ‘1... Beo;t1ful._Dtrty,_Rach er IL3004) Blithriqhk (band) JArVy_Vinond Vatan Mctorthy_936_3tone _Hev_uanpsh1re A_L'.no_of_Doalhloun_KSng i )Ie'xtoundland_1r1sh “k2 H t o u / Beatr1c¢_Pollt: Bono_$1)abat sanding Dr_Haflbohan_51nqh_5cholcrsh1p Rol;qton_tn_Jordan III I flvdlvulu Saizsbury. 501! Hash Functions K6 ace Typical approach: “randomize” the key via bit scrambling and than take a subset ofthe scrambled bits. ...
View Full Document

{[ snackBarMessage ]}

Page1 / 13

lec0406-Hashing1-ann - Announcements 7 We 6933 Canoe[In s...

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

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