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-oExplanation / 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).
Related Questions
Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.