Hello, dear friend, you can consult us at any time if you have any questions, add WeChat: daixieit

CSCI 2100: Course Project (Fall 2022))

Due: 12 noon, 20 December 2022

(absolute deadline as we need to assign grades)

Goals of Course Project

1.  To carry out the design of a solution for solving an application problem using some of the data structures learned in CSCI 2100 and to analyze the resulting performance of your solution.

2.  Programming is one of the essential parts of the project in implementing your solution. However, a good design and an evaluation of your solution are equally important and will be graded accordingly.

3. You submission is graded according to the following parts:

❼ Tests passed (half are simple, half are complex) (35% total score),

❼ Report and analysis of results (35% total score),

❼ Program and functions implemented with proper documentation and comments (30% total score)

– Implementing a hash table with insertion and deletion (10%)

– Implementing the k-selection and range-selection functions (10%)

– Quality of code (10%)

4. Your submission (through Blackboard) should have the following parts:

❼ A short (1-2 page) report containing the following:

– The design of the your program and tradeoffs made (for instance, why do you choose one solution over another). It should include all the parameter combinations studied in your implementation. Examples of tradeoffs include the size of the hash table and the parameters of the hash function.

– A summary of the amortized performance in processing the queries, including the space/time complexity of your algorithm, total and   amortized times in generating your results on the test data for each type of query. You should discuss the effects of your trade-   offs on solution times.

– A summary of the amortized performance relative to the case of a hash table of one entry,

– Discuss with justifications the best choice of the hash table size and the hash function parameters to support this application. Analyze the results you have obtained and other approaches to improve them.

❼ A properly documented program that can be tested by the teaching assistants in running new test queries beyond those available to you. Your program should compile correctly with no errors and be able to run using the data supplied by the teaching assistants.

❼ A VeriGuide report on your submission.

Project Specifications

1. You are given 100K data records in a text file, each line containing two fields of a fixed length. The records are not given in any particular order, and the keys were generated randomly using a uniform distribution over its space.

2.  The first field in each record contains a search key with 256 bits.  The range of the search key (U = 2256 − 1) is much larger than the number of records (n ≈ 100000) in the text file and those added by the queries.

3.  Create an empty hash table and a database to store the records.  Read the text file, one line at a time to insert the record into the database and the corresponding pointer and other information in the hash table. Each database record is identified by its starting address (or index) of the record.

4. You are given a sequence of queries on the database (in files test hash table .py, test hash table .java, test hash table . cpp) of the following types:

❼ Inserting new records into the database or deleting existing records from the database, one at a time, each using the given search key;

❼ Finding the pointer to the record with the  k-th smallest value of the search key (and a set of pointers to multiple records if there are duplicates), where k can range from  1 to the number of database records;

❼ Returning the pointers of all database records who key values are in a given range of the search key; examples of ranges are the 1000 records with the smallest keys, records whose keys are the 200 largest, and records whose keys are in in a given range of key values (say 105  to 5 × 105 ).

5. We will provide you with the following program files that can be down- loaded from Blackboard (as a zip file)

❼ Record.py, Record. cpp, Record.java: for reading data from the input file and classes to store the data records,

❼ example .py,  example . cpp,  example .java: the class of HashTable that annotate what you will implement,

❼ test hash table .py, test hash table . cpp, test hash table .java: tests that you run to test your program.

6. Your design should not be hard-coded for a given database.

❼ Your solution should be able to adapt to the dynamic growth and shrinking of the database.

❼ Your solution should be based on hashing only; all the queries should be run using the hash tables maintained; you should not maintain any sorted list of the keys.  However, auxiliary information derived from the hash table can be maintained.

❼ If you used a linear search, a binary search, or any sorted list in your solution, you will get a very low score.

Suggested Solution Approach

1. You should create an initially empty hash table of m entries; each entry of the hash table should include fields for the forward and backward pointers of the linked list maintained by this table entry, the range of key values hashed into this location (b1 ,b2 ), the number of elements in the linked list pointed to by this table entry, and other fields if necessary.  An example of a hash table entry is as follows:

lower bound of key range b1

upper bound of key range b2

forward ptr to LL

backward ptr to LL

# entries in linked list

Each node in the linked list of the hash table entry should include a pointer (or index) to the database containing the record.  It would also include forward and backward pointers to other nodes in the linked list, if any. An example of a node in the linked list is as follows:

backward pointer in LL

forward pointer in LL

pointer to DB record

2. You should populate the hash table and your database by inserting the 100K records from the text file, one at a time.

3. You will then process the queries, one at a time.   As database records with new keys may be inserted or existing records deleted, you will need to dynamically update the hash table as the queries are processed.

4. You will report the result of each query, the times taken, and the number of logical steps (you need to decide how to measure the number of logical steps).

5.  Since you need to search for keys in a specific range, you should be dividing the keys into ranges and use hashing on a range of keys into a unique hash table location. Each hash table entry should contain a range of keys that can be hashed into, and a pointer to a linked list of the records in this list.

6.  To find the k-th smallest record, you will hash into the specific range and search all the records in a linear fashion. A better solution (not required) is to do second-level hashing on those keys in the list or to maintain an auxiliary table of sorted keys (as done in the tutorial).

7. You should report the following summary results over all the queries pro- cessed:

(a)  amortized time of inserting a key into the hash table (and the database)

(b)  amortized time of deleting a key in the hash table (and the database)

(c)  amortized time of processing a query to retrieve the k-th smallest key value,

(d)  amortized time of retrieving a set of keys in a given range,

(e)  all the amortized times in (a) to (d) for a reference case of a hash table of size one,

(f)  all the amortized times in (a) to (d) normalized with respect to those of the reference case in (e),

(g) the distribution of the length of linked lists in the hash table after processing all the queries.

8.  The tune-able parameter to be evaluated in your program is the size of the hash table (and the range of hash keys to go into each entry of the hash table).  You may also consider tuning the parameters used in the hash function.  By adjusting the hash table size, you will get different results on the metrics in your evaluation.

9. You can implement your solution using C++, python, or Java. There are existing solutions to generate hash keys, although they may not fit exactly what we need here.  If you use an existing solution, you should cite the source where you get the existing code.

Zero Tolerance for Cheating.   You are required to do the implementation on your own. You may be required to attend an interview to explain the details about the code.   All submissions must pass through VeriGuide, and may be subject to additional plagiarism checks.   Any confirmed case will receive a 0 mark outright, and be reported to the university for disciplinary actions.