Is searching a hash table for a value that does not exist O (n)? (linear sensing)

Just trying to understand the logic of linear sensing.

Using hashtable using open addressing, as you can confirm that the item is not in the table.

For example, let's say you have a hashmap of 10 bucket. Suppose you have a key and insert it. Now, if the elements A and B are to be inserted and hashed and reduced to the same bucket, then the elements A and B, if you use a linear probe, are likely to be next to each other.

Now, just because the bucket is empty does not seem to mean that the item does not exist on the map. for example, you look for element B after deleting element A. First you get an empty bucket where you expect B to be, but you need to probe another one and you will find B. It really is. If this logic is correct, you do not have to search the entire table to confirm if there is a key? that is, O (n) performance every time.

What I'm saying, you don’t have to go through the whole map to really confirm it is not there?

When using a separate hashmap binding method, this problem does not exist.

Edit: I mean looking at this photo http://upload.wikimedia.org/wikipedia/commons/b/bf/Hash_table_5_0_1_1_1_1_0_SP.svg

If John Smith is removed and we try to find Sandra Dee.

, . .. , 152 154 ? , . , ted baker 154, 153, . , .

.

+5
3

, , , - , O (n). -.

, , . - , , , . , , , , , , . , - , - .

, , - . , - , .

+4

-, , . , - , , ( -).

, , . , , . , . , , / .

{A0, A1, A2}, . {A0, A1} Hashtable, {A2} - . A0, . A2 ( Hashtable), A0 (), A1, A0, . ( A2, A1 ), , , A1, - .

+3

, , -.

, , , , , "maxProb" , , .

, -, maxProb.

, , N , N - -, O (x), x - .

, - , , , x-, .

0
source

All Articles