Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Please I need this as soon as possible I need this code running according to the given information. In c++ and don't use external libraries

Please I need this as soon as possible

I need this code running according to the given information.

In c++ and don't use external libraries also don't use #include Just use #include

The task given to you by NADRA is to design an ID system that supports fast searching, insertion, and deletion. The current methods using arrays and linked lists have a time complexity of O(n) for these operations in the worst case, and AVL trees have a time complexity of log(n) but have issues with balancing and high depth. The proposed solution is to use a hash table, but collision is a problem that must be dealt with for the best performance.

To accomplish this, you are given the following tasks:

Design a hash function that minimizes the number of collisions. Insert data into a hash table using this function.

The Hash function is used to map the data, in this case ID card numbers, to an array index, also known as a key. So the goal is to create a hash function that will distribute the keys uniformly across the array and minimize collisions.

Implement linear probing to avoid collisions.

Linear probing is a collision resolution technique in which when a collision occurs, the next empty slot is checked, and if it is also occupied, the next one is checked, and so on. This way, the program can find an empty slot to insert the data.

Implement linked-list-based chaining to avoid deletion problems.

Chaining is a technique in which, instead of storing the data in the array index, a linked list is stored. When a collision occurs, the new data is added to the linked list, and the program checks the linked list for the data instead of checking the array.

Implement BST-based chaining A binary search tree is another way of resolving collisions. Each key is inserted into a separate binary search tree. When a collision occurs, the new data is inserted into the tree instead of the array

The system must be able to perform insertion, deletion, and searching using both chaining and probing. A suggested technique for the hash function is to use the format of the ID card numbers, but any other technique can also be used. The data used will be randomly generated ID card numbers, and the system will be tested by inserting 1000 numbers and searching 100 numbers. The system should also include a menu for searching, deletion, and insertion of user input ID card numbers. The performance of the different methods (linear probing, linked-list chaining, and BST chaining) should be compared in terms of the number of collisions and comparisons.

The system should also be able to handle deletion correctly. With linear probing, when an element is deleted, the elements after it may have to be shifted to fill the gap. With chaining, the element can be removed from the linked list or BST without affecting the other elements.

In summary, the task is to design an ID system that uses a hash table to support fast searching, insertion, and deletion. To accomplish this, you need to design a hash function that minimizes collisions, implement linear probing, linked-list-based chaining, and BST-based chaining to resolve collisions, and also handle deletion properly. The system should also include a menu for user input and be tested using randomly generated ID card numbers. The performance of the different methods should be compared in terms of collisions and comparisons.

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 Driven Web Sites

Authors: Joline Morrison, Mike Morrison

2nd Edition

? 061906448X, 978-0619064488

More Books

Students also viewed these Databases questions