Can someone help me on this question about hashing please? Big thanks and thumbs
ID: 3827224 • Letter: C
Question
Can someone help me on this question about hashing please? Big thanks and thumbs up if your answer makes sense. Note: the programming language is java for this quesiton.
(b) Hashing. 5 points We are implementing a set in an array b using linear probing. The set currently has size n. Give the tightest worst-case complexity formula for enumerating all elements of the set. Do not use the load factor, which for the purpose of this question is unknown. Hint: think about what has to be done to find all the elements in the set.Explanation / Answer
#include <stdio.h>
int main()
{
int array[100], search, c, n;
printf("Enter the number of elements in array ");
scanf("%d",&n);
printf("Enter %d integer(s) ", n);
for (c = 0; c < n; c++)
scanf("%d", &array[c]);
printf("Enter the number to search ");
scanf("%d", &search);
for (c = 0; c < n; c++)
{
if (array[c] == search)
{
printf("%d is present at location %d. ", search, c+1);
break;
}
}
if (c == n)
printf("%d is not present in array. ", search);
return 0;
}
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.