Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

3 Programming Question (50 points) 3.1 Instructions You need to write the code by yourself. Your implementation must use C/C++ and your code must run

image text in transcribed

image text in transcribed

3 Programming Question (50 points) 3.1 Instructions You need to write the code by yourself. Your implementation must use C/C++ and your code must run on the Linux machine general.asu.edu. Please refer to the programming guide (available under the Assignments folder on Blackboard) for using the general.asu.edu server, as well as compiling and running C/C++ code under Linux For this question, you that runs on the Linux machine general.asu.edu. Our TA will write a script to compile and run all student submissions; therefore, executing the command make in the Code folder must produce the executable a3 also located in the Code folder need to provide a Makefile that compiles your program to an executable named a3 3.2 Requirements In this question, you will write a serial program that executes a sequence of commands that operate on individual files. Valid commands include: Start Name, where Name is a character string of maximum length 20 alphabetic characters representing the name of the data file (Name.txt). The structure of Name.txt is an integer N indicating the total number of data entries contained in this file, followed by N additional lines of integers (the actual data entries). This command first reads N from the file Name.txt, dynamically allocates an array of integers of size N, and then reads the remaining N data entries into the array. the End command are to be applied to the resulting data array. The output of the Start command is: Processing data from: Name.txt The commands that follow until End Name, which indicates the end of the processing for the data in file Name.txt. The Start and End commands will always come in pairs with matching names. Any memory dynamically allocated for Name must be freed on an End command. The output of the End command is End of processing data from: Name.txt BuildHash Table, which builds a hash table storing all the integers from the array of size N. Your implementation must repeatedly insert one integer at a time into the hash table using hash function h(k) = k mod 9, resolving collision by chaining. When finished, output the following information Time to build hash table (ms): t Hash TableSize, which outputs the number of elements (integers) stored at each slot of the hash table. If no hash table has been built, output Build hash table first! Otherwise, go through each slot i of the hash table, and output the number of elements (integers) stored at that slot ni in the following format Number of elements in slot i: i Exit, which indicates that there are no more commands to execute, ie., the program terminates Test your program against the following command sequence. All the test files (the same as assignment #2) are provided in the folder named 'data files'. Start test 1 BuildHash Table Hash TableSize End test 1

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Database Concepts

Authors: David M Kroenke, David J Auer

6th Edition

0132742926, 978-0132742924

More Books

Students also viewed these Databases questions

Question

In an Excel Pivot Table, how is a Fact/Measure Column repeated?

Answered: 1 week ago