You are going to implement hashing with chaining with separate chaining. Please implement your hash function accordingly to distribute the data evenly in the array. Fill in the missing code! C only! ASAP!!!   THE CODE: #include // RecordType struct RecordType { int id; char name; int order; }; // Fill out this structure struct HashType { }; // Compute the hash function int hash(int x) { } // parses input file to an integer array int parseData(char* inputFileName, struct RecordType** ppData) { FILE* inFile = fopen(inputFileName, "r"); int dataSz = 0; int i, n; char c; struct RecordType *pRecord; *ppData = NULL; if (inFile) { fscanf(inFile, "%d\n", &dataSz); *ppData = (struct RecordType*) malloc(sizeof(struct RecordType) * dataSz); // Implement parse data block if (*ppData == NULL) { printf("Cannot allocate memory\n"); exit(-1); } for (i = 0; i < dataSz; ++i) { pRecord = *ppData + i; fscanf(inFile, "%d ", &n); pRecord->id = n; fscanf(inFile, "%c ", &c); pRecord->name = c; fscanf(inFile, "%d ", &n); pRecord->order = n; } fclose(inFile); } return dataSz; } // prints the records void printRecords(struct RecordType pData[], int dataSz) { int i; printf("\nRecords:\n"); for (i = 0; i < dataSz; ++i) { printf("\t%d %c %d\n", pData[i].id, pData[i].name, pData[i].order); } printf("\n\n"); } // display records in the hash structure // skip the indices which are free // the output will be in the format: // index x -> id, name, order -> id, name, order .... void displayRecordsInHash(struct HashType *pHashArray, int hashSz) { int i; for (i=0;i

Database System Concepts
7th Edition
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Chapter1: Introduction
Section: Chapter Questions
Problem 1PE
icon
Related questions
Question

You are going to implement hashing with chaining with separate chaining. Please implement your hash function accordingly to distribute the data evenly in the array.

Fill in the missing code! C only!

ASAP!!!

 

THE CODE:

#include <stdio.h>

// RecordType
struct RecordType
{
int id;
char name;
int order;
};

// Fill out this structure
struct HashType
{

};

// Compute the hash function
int hash(int x)
{

}

// parses input file to an integer array
int parseData(char* inputFileName, struct RecordType** ppData)
{
FILE* inFile = fopen(inputFileName, "r");
int dataSz = 0;
int i, n;
char c;
struct RecordType *pRecord;
*ppData = NULL;

if (inFile)
{
fscanf(inFile, "%d\n", &dataSz);
*ppData = (struct RecordType*) malloc(sizeof(struct RecordType) * dataSz);
// Implement parse data block
if (*ppData == NULL)
{
printf("Cannot allocate memory\n");
exit(-1);
}
for (i = 0; i < dataSz; ++i)
{
pRecord = *ppData + i;
fscanf(inFile, "%d ", &n);
pRecord->id = n;
fscanf(inFile, "%c ", &c);
pRecord->name = c;
fscanf(inFile, "%d ", &n);
pRecord->order = n;
}

fclose(inFile);
}

return dataSz;
}

// prints the records
void printRecords(struct RecordType pData[], int dataSz)
{
int i;
printf("\nRecords:\n");
for (i = 0; i < dataSz; ++i)
{
printf("\t%d %c %d\n", pData[i].id, pData[i].name, pData[i].order);
}
printf("\n\n");
}

// display records in the hash structure
// skip the indices which are free
// the output will be in the format:
// index x -> id, name, order -> id, name, order ....
void displayRecordsInHash(struct HashType *pHashArray, int hashSz)
{
int i;

for (i=0;i<hashSz;++i)
{
// if index is occupied with any records, print all
}
}

int main(void)
{
struct RecordType *pRecords;
int recordSz = 0;

recordSz = parseData("input.txt", &pRecords);
printRecords(pRecords, recordSz);
// Your hash implementation
}

I'll attach the input file

1
2
34
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
31
03146 A 0
03270 B 1
06835 C 2
09315 D 3
09966 E 4
11795 F 5
12105 G 6
12415 H 7
13035 I 8
13500 J 9
14275 K 10
14585 L 11
15515 M 12
16135 N 13
17220 0 14
18615 P 15
21715 Q 16
22366 R 17
24815 S 18
26396 T 19
26613 U 20
26985 V 21
27233 W 22
27915 X 23
28442 Y 24
28752 Z 25
28876 a 26
30364 b 27
29310 C 28
31015 d 29
35107 e 30
Transcribed Image Text:1 2 34 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 31 03146 A 0 03270 B 1 06835 C 2 09315 D 3 09966 E 4 11795 F 5 12105 G 6 12415 H 7 13035 I 8 13500 J 9 14275 K 10 14585 L 11 15515 M 12 16135 N 13 17220 0 14 18615 P 15 21715 Q 16 22366 R 17 24815 S 18 26396 T 19 26613 U 20 26985 V 21 27233 W 22 27915 X 23 28442 Y 24 28752 Z 25 28876 a 26 30364 b 27 29310 C 28 31015 d 29 35107 e 30
Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 5 steps with 5 images

Blurred answer
Knowledge Booster
Hash Table
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
Database System Concepts
Database System Concepts
Computer Science
ISBN:
9780078022159
Author:
Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:
McGraw-Hill Education
Starting Out with Python (4th Edition)
Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON
Digital Fundamentals (11th Edition)
Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON
C How to Program (8th Edition)
C How to Program (8th Edition)
Computer Science
ISBN:
9780133976892
Author:
Paul J. Deitel, Harvey Deitel
Publisher:
PEARSON
Database Systems: Design, Implementation, & Manag…
Database Systems: Design, Implementation, & Manag…
Computer Science
ISBN:
9781337627900
Author:
Carlos Coronel, Steven Morris
Publisher:
Cengage Learning
Programmable Logic Controllers
Programmable Logic Controllers
Computer Science
ISBN:
9780073373843
Author:
Frank D. Petruzella
Publisher:
McGraw-Hill Education