Questions tagged [linear-probing]

Questions about linear probing, the technique for resolving collisions in hash tables.

52 questions
0
votes
0 answers

time limit exceeded in linear probing in hashing

I am learning how to implement linear probing in hash functions. I am getting error time limit exceeded for the code below how can I improve this code? vector linearProbing(int hashSize, int arr[], int sizeOfArray) { vector
Anshul
  • 13
  • 7
0
votes
2 answers

I'm getting this warning sign Array index 4001 is past the end of the array (which contains 4001 elements)

I have two questions First: When i try to run the code it gives me a warning where it says "Array index 4001 is past the end of the array (which contains 4001 elements)" Second: I want to read the words from the file and then pass them through the…
0
votes
1 answer

C++ HashTable Quadratic Probing Insert method with resize not working?

This method is supposed to resize the array once the threshold exceeds the predetermined amount of 0.65. The problem is after this is resized the destructor deletes the array with all the newly copied information on it. I don't know how to fix…
Kman
  • 76
  • 4
0
votes
0 answers

Issue with hashtable in c

So I have an assignment to create a program in c that reads a couple of sentences(a 140mb file), and based on the 2nd input, which is a number, I need to return the Nth most common word. My idea was to build a hash table with linear probing, every…
user14192734
0
votes
0 answers

Adding elements after array used for linear probing is full

When the array used for linear probing hashing technique is full, can I add further elements ?
Atulya Jha
  • 153
  • 1
  • 2
  • 10
0
votes
0 answers

Linear Probing Overwriting Records in C

I am trying to implement linear probing for collision resolution for a hash table in C. I am inserting and retrieving the information from a file using the RRN (record relative number) to locate the index where each register will be…
0
votes
1 answer

Should 'get' method fail in linear probing, if there is a null in between. If not how do I implement the get method?

So I am building a hashtable from scratch using linear probing in Java with the following methods: put(int key, String value), get(int key), remove(int key) and size(). So I successfully implemented these methods, but I have a theoretical question.…
user11319000
0
votes
1 answer

What is the algorithm for searching for entries using linear probing?

Please could someone help by telling me a general algorithm for searching for entries using linear probing. I have the following, but I think it is pseudo code instead of an algorithm: 1) use hash function to find index of where an item should…
0
votes
2 answers

Number of different insertion sequence of Key values in a hash table

A hash table of length 10 uses open addressing with hash function h(k)=k mod 10, and linear probing. After inserting 8 values into an empty hash table, the table is as shown below 0 | 1 | 91 2 | 2 3 | 13 4 | 24 5 | 12 6 | 62 7 | 77 8 | 82 9 | How…
Ved sinha
  • 69
  • 3
  • 9
0
votes
1 answer

Why isn't my hashmap returning a word count?

I am creating a hashmap that does linear probing to find an index for the key. If the key is already in the index, I want to increase its value, not add one to a new index. For example, if I get a word count for the string "five, five, five" my…
0
votes
1 answer

What's the difference between collision and probe length in a hash table?How to keep track of them?

Hi I'm new to Python and i implemented a hash table class which resolves collisions with linear probing. Now I'm trying to write a function to keep track of the number of collisions and the probe length.I've written the function to keep track of…
Sook Lim
  • 541
  • 6
  • 28
0
votes
1 answer

How hashtables are linear on same or collision values?

I was looking at this StackOverflow answer to understand hashing better and saw the following (regarding the fact that we would need to get bucket size in constant time): if you use something like linear probing or double hashing, finding all the…
rb612
  • 5,280
  • 3
  • 30
  • 68
0
votes
2 answers

Solution to hash table and linear probing for multiple elements

I'm trying to write a solution for linear probing in a hash table dealing with multiple "animals", similar to the one below that was given to me. index++; if(index == hashAnimals.length) { index = 0; } if(hashAnimals[index] == null){ …
user7939273
0
votes
1 answer

Marking a bucket as removed in Hash Table

I have been having some trouble finding a decent explanation on this. I am writing a linear probing hash table using C++, but I am having trouble with the remove() operation. I am hashing a dictionary collection of strings, and I am wondering how I…
bb13
  • 9
  • 6
0
votes
3 answers

implement linear probing in c++ for a generic type

I wanted to implement linear probing for hashtabe in c++,but the key,value pair would be of generic type like: vector< pair< key,value> >(where key,value is of generic type). Now,in linear probing if a cell is occupied we traverse the vector until…
Saurabh
  • 60
  • 12