Duke ndihmuar Instruktoren e Kursit te Data Structures ne YorkU per Assignment numer 3 me ka dale nje problem i vogel.
Ja faqja, futu ke lectures nen Natalia Vlajic http://www.cs.yorku.ca/course/2011/
Problemi eshte me shume nje inat i vockel personal mbi nje ushtrim ne lidhje me Hash Tables. Po hedh njehere si mendojme ta paraqesim ushtrimin:
Tashti problemi eshte se ne piken (d.) po te ndiqen sakte veprimet duhet te arrihet ne dicka te tilleHash Table [20 points]
Given the input sequence {4371, 1323, 6173, 4199, 4344, 9679, 1989}, a hash table of size b = 10,
and a hash function h(x) = x mod b, show each step needed to build a hash table in each of the
following cases.
a. [5 points] An open hash table, with insertion at the front of the chain.
b. [5 points] A closed hash table using linear probing (that is, f(i) = i).
c. [5 points] A closed hash table using quadratic probing (that is, f(i) = i2).
d. [5 points] A closed hash table using double hashing, with the second hash function as
h(x) = 7 - (x mod 7).
This yields the sequence of hash functions
hi(x) = (x mod b + i⋅(7-(x mod 7))) mod b, for i=0,1,
If, during the course of inserting into the hash table, you reach a point when it is not possible to
complete the insertion, then note this in your write-up. Briefly explain what happened to prevent the
insertion and why.
Por nuk do te kete kurrsesi perseritje nese i ne funksionin e dyte (double Hashing) do te fillonte nga 1 pra i = 1, 2, 3, .... dhe jo nga 0.D- Fourth case:
In our fourth case of the Double Hashing the secondary function is: h(x) = 7 - (x mod 7) which yields to the sequence of hash functions:
hi(x) = (x mod b + i(7-(x mod 7))) mod b, for i=0,1,
4371 -> 1
1323 -> 3
6173+1 -> 4 //since 3 is busy
4199 -> 9
4344+1 mod 10 -> 7 //since 4 is busy
9679+1 mod 10 -> 5 //since 9 and 1 and 3 were busy
1989+3² mod 10 -> error //the runout occurs because there is no tryout that can find a free space on the Hash Table
Une provova nje sere rastesh dhe vura re qe nese i fillon nga 0 bllokim total te vendeve do te ndodhin qe cojne ne Error ndersa nese ( i ) fillon nga 1 edhe shanset per perplasje jane me te rralla.
Tashti eshte rastesi apo ka te beje me ndonje vecori matematike, ky eshte gjithe "inati" qe kemi pasi nese dua ti ve kapak qe eshte vecori duhet dhe ta provoj.
Une kerkova ca dhe nje Profesor Rus e fillonte ( i ) nga 1 por vertetim s'gjeta gje. I thava ca trute me induksionin por sikur s'po leviz dot gje.
Them qe po te kete ndonje qe ka mbaruar per Pure Math e ka buke e djathe se nusja qe e ka marre Minor bashke me COSC s'me beri dot gje.
Krijoni Kontakt