How difficult is it to find an item by key?
It depends on which data structure to use.
In a singly linked list, linear complexity.
In a sorted array or in a binary search tree, log complexity.
In a hash table, the complexity is constant. But this is at best. And at worst ... tends to be linear ...
-, ?
- . , - , - , , , -.
! , .
, " " OTUS , -.
- . , - . , !
, , - “dog”, -, , , , “”
!
?
, 10.000 -. - 10.000 . “” --, , ? , , “” .
- “(A * k + B) % N”
, A
, “” - . k
- (ulong) , N - .
.
“”, - “”, .
. “” “”, - “”. “ ”, .
“” “”.
, , “” () “” . , .
, 100 10.000 10.
,
- “(A * k + B) % N”
. “”, . “” () “”.
K “” K²
“”. “ ” A
B
K , (, - ). “” -, “”.
!
- :
“”
i
-k: “(A * k + B) % N”
.
:
Ai
,Bi
,K²
.
“” :
“(Ai * k + Bi) % K²
”
“”.
( , ) “” , .
, “” -. , ( ).
, , - N = 10 . 0 10 . , .
: “” N
, “” - 1.9 * N
. : 2.9 * N = (N)
- .
, -, -- () - , .
. 15 Demo Day " " OTUS, .
, :