Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Suppose a manufacturing company has an inventory file of more than 100 records e

ID: 3548805 • Letter: S

Question

Suppose a manufacturing company has an inventory file of more than 100 records each record having a unique 5-digit record number such as 12345, product type instance, and quantity. Product type has product name and size. The requirements are that the company likes to retrieve any record fast by expected single access to the record and does not want to waste an unacceptably large amount of spaces because it is extremely unlikely that it stocks more than a few thousand records. what data structure u used information and big-o

Explanation / Answer

Hash table


Gives you a O(1) search time and O(n) memory.


Implementation:


Create a class in which object has a unique ID (like 12345). The other attributes are quantity left and product type.

Now using objects for each new product, construct a hash table (#include<map> in C++). Because the inventory remains fixed after construction even the worst case search time is O(1).

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote