Please convert toC language
//linear probing#include using namespace std;void add_using_linear_probing(int hash[], int a){ //hash function h(x)=x%10 int k = a % 10; //linear probing while (true) { if (hash[k] == -1) { hash[k] = a; break; } k = (k + 1) % 10; //linear increment of probe }}int main(){ //set of input numbers vector arr{ 123, 124, 333, 4679, 983 }; //initialize the hash table //each entry of the hash table is a single entry int hash[10]; //size of hashtable is 10 memset(hash, -1, sizeof(hash)); //initialize with empty initially for (int a : arr) { //hashing add_using_linear_probing(hash, a); } cout < "---------using="" linear=""> cout < "hash="" table=""> for (int i = 0; i < 10;="" i++)=""> if (hash[i] == -1) cout < i="">< "-="">" < "empty"=""><> else cout < i="">< "-="">" < hash[i]=""><> } return 0;}Output:Extracted text: ----using linear probing-- Hash table is: 0->Empty 1->Empty 2->Empty 3->123 4->124 5->333 6->983 7->Empty 8->Empty 9->4679
void add_using_linear_probing(int hash[], int a){ //hash function h(x)=x%10 int k = a % 10;
//linear probing while (true) { if (hash[k] == -1) { hash[k] = a; break; } k = (k + 1) % 10; //linear increment of probe }}
int main(){ //set of input numbers vector arr{ 123, 124, 333, 4679, 983 }; //initialize the hash table //each entry of the hash table is a single entry int hash[10]; //size of hashtable is 10 memset(hash, -1, sizeof(hash)); //initialize with empty initially for (int a : arr) { //hashing add_using_linear_probing(hash, a); } cout < "---------using="" linear=""> cout < "hash="" table=""> for (int i = 0; i < 10;="" i++)=""> if (hash[i] == -1) cout < i="">< "-="">" < "empty"=""><> else cout < i="">< "-="">" < hash[i]=""><> } return 0;}Output:Extracted text: ----using linear probing-- Hash table is: 0->Empty 1->Empty 2->Empty 3->123 4->124 5->333 6->983 7->Empty 8->Empty 9->4679
//initialize the hash table //each entry of the hash table is a single entry int hash[10]; //size of hashtable is 10 memset(hash, -1, sizeof(hash)); //initialize with empty initially
for (int a : arr) { //hashing add_using_linear_probing(hash, a); }
cout < "---------using="" linear="">
cout < "hash="" table="">
for (int i = 0; i < 10;="" i++)=""> if (hash[i] == -1) cout < i="">< "-="">" < "empty"=""><> else cout < i="">< "-="">" < hash[i]=""><> }
return 0;}
Output:
Already registered? Login
Not Account? Sign up
Enter your email address to reset your password
Back to Login? Click here