LINUX C programming
Please make sure the output is correct
Please do read data from file, the example below is just a example
Third: Hash table (20 points)
In this part, you will implement a hash table containing integers. The hash table has 10,000 buckets. An important part of a hash table is collision resolution. In this assignment, we want you to use chaining with a linked list to handle a collision. This means that if there is a collision at a particular bucket then you will maintain a linked list of all values stored at that bucket. For more information about chaining, see http://research.cs.vt.edu/AVresearch/hashing/openhash.php.
A hash table can be implemented in many ways in C. You must find a simple way to implement a hash table structure where you have easy access to the buckets through the hash function. As a reminder, a hash table is a structure that has a number of buckets for elements to ”hash” into. You will determine where the element falls in the table using the hash function.
You must not do a linear search of the 10,000 element array. We will not award any credit for O(n) time implementation of searches or insertions in the common case.
For this problem, you have to use following hash function: key modulo the number of buckets.
Input format: This program takes a file name as argument from the command line. The file contains successive lines of input. Each line contains a character, either ‘i’ or ‘s’, followed by a tab and then an integer. For each line that starts with ‘i’, your program should insert that number in the hash table if it is not present. If the line starts with a ‘s’, your program should search the hash table for that value.
Output format: Your program my print two counts: (1) the number of insertions where collision occurred, and (2) the number of successful searches. In the first line your program should print the number of collisions, i.e. during insertion if the bucket already had some data (may not be the same value) then you need to count that as one collision. In the next line, your program should print the number of searches where the value was present in the hash table. You can assume that the program inputs will have proper structure.
Example Execution:
Lets assume we have a text file with the following contents:
file2.txt:
i 10
i 12
s 10
i 10010
s 5
s 10010
The the results will be:
$./third file2.txt
1
2
C code:
#include<stdio.h>
int main(int argc,char *args[])
{
char ch,newl;
int n,hash[10000],i,collision=0,search=0;
for(i=0;i<10000;i++)
{
hash[i]=0;
}
FILE *fp;
fp=fopen(args[1],"r"); //open file to read
while(fscanf(fp,"%c%d%c",&ch,&n,&newl)!=EOF)//reading file
{
//operation is stored in ch , nuber is stored in n
//newl is to read new line character in file
//printf("op=%c n=%d ",ch,n);
if(ch=='i') //if operation is insert
{
if(n%10000==0) //check hash table entry n%10000 is empty or not
{
hash[n%10000]=n; //if empty insert there
}
else
{
collision++; //else don't insert and increment collision count
}
}
else //if operation is search
{
if(hash[n%10000]==n) //chech n%10000 contains n or not
{
search++; //if it contains n then increment successful search count by 1
}
}
}
fclose(fp);
printf("Number of collisions:%d ",collision);
printf("Number of successful seaches:%d",search);
}
file2.txt:
i 10
i 12
s 10
i 10010
s 5
s 10010
output:

LINUX C programming Please make sure the output is correct Please do read data from file,...
For this problem, you have to use following hash function: key
modulo the number of buckets.
Input format: This program takes a file name as
argument from the command line. The file is either blank or
contains successive lines of input. Each line contains a character,
either ‘i’ or ‘s’, followed by a tab and then an integer, the same
format as in the Second Part. For each of the lines that starts
with ‘i’, your program should insert that...
Please answer this problem in C++, Thank you! Read and study the sample program: "hashing with chaining using singly linked lists", as well as "hashing with chaining using doubly linked lists". Notice this program is complete except it doesn't include the remove function. Write the remove function and test it with the rest of the program including the given main program. Upload your C++ source file. ---Here is the referenced program: "hashing with chaining using singly linked lists". Below this...
in c++ please
Write a program in c+ to do the following: 1.Save the data shown below (in the same format) to make a text file called "InputData. txt"; use the file as input to enter data into a hash table. Fname Lname 2019-01-31 First Last 2018-02-01 Jonh Doe 2017-03-28 Jane Doe 2016-04-01 as the data items in the file 2. Your hash table should have as many entries 3. The birthday should be used as the hash key by...
To implement a HashTable class in C++ that allows: - the definition of the size (M) of the static array for the hash table - the definition of a hash function HASH(X) suitable for storing string keys (not integers). The student is expected to propose his/her own hash table. - a method for inserting keys in the hash table. The solution MUST consider chaining (e.g. linked lists, trees, etc.) as the collision response criteria. - a method for searching keys...
Please complete the following task: Create a C++ hash table program for generating a hash from a string. Create a hash function then test and evaluate the results. The set of strings are from a "words.txt" file (there are 45,402 words in the file, no repeating words. Map the words to 45,402 buckets using a hash function). Requirements: Create an array of 45,402 integers and initialize each to zero. These will be used to store how many times each index...
I really need assistance with creating a C++ hash table program for generating a hash from a string. Create a hash function then test and evaluate the results. The set of strings are from a "words.txt" file (there are 45,402 words in the file, no repeating words. Map the words to 45,402 buckets using a hash function). Requirements: Create an array of 45,402 integers and initialize each to zero. These will be used to store how many times each index...
I really need assistance with creating a C++ hash table program for generating a hash from a string. Create a hash function then test and evaluate the results. The set of strings are from a "words.txt" file (there are 45,402 words in the file, no repeating words. Map the words to 45,402 buckets using a hash function). Requirements: Create an array of 45,402 integers and initialize each to zero. These will be used to store how many times each index...
Project Description: In this project, you will combine the work you’ve done in previous assignments to create a separate chaining hash table. Overview of Separate Chaining Hash Tables The purpose of a hash table is to store and retrieve an unordered set of items. A separate chaining hash table is an array of linked lists. The hash function for this project is the modulus operator item%tablesize. This is similar to the simple array hash table from lab 5. However, the...
Java using data structures The objective is to create your own Hash Table class to hold a list of employees and their ID numbers. I've provided the TableEntry class which will be each data object in the hash table. The list of employees will be provided as a .txt file and must be read with the code. please create a .txt file called Employees.txt with the info provided so that the java code can read it in. Employees.txt: (No WhiteSpace...
Objective: Use input/output files, strings, and command line arguments. Write a program that processes a text file by removing all blank lines (including lines that only contain white spaces), all spaces/tabs before the beginning of the line, and all spaces/tabs at the end of the line. The file must be saved under a different name with all the lines numbered and a single blank line added at the end of the file. For example, if the input file is given...