![]() ![]() only m slots out of the n slots are used and we are wasting memory occupied by ( m-n) slots. Now, only the slots corresponding to the keys in the yellow region have values and the rest are NIL i.e. The yellow region contains the m number of keys that correspond to the m variety of fruits and vegetables that you chose. ![]() ![]() Now, your direct access table would look like this. Suppose you are planning to sell only m (m < n) varieties of fruits and vegetables and every week you are going to change the variety. Let us continue with our shop owner scenario.Īfter some time you notice that your shop is running at a loss and you decide to sell only a limited variety of fruits and vegetables. INSERT(T, key, value): T = value DELETE(T, key): T = NIL SEARCH (T, key): return TĪll three operations have a worst-case time complexity of O(1) which is the best we could ever achieve. It would be clear from the diagram that slot k in array T corresponds to the key k in the universal set U and T is the value corresponding to the key k.Īny data structure would support three main functionalities: insert, delete, and search. Here, pᵢ is the price corresponding to key i. Every element in set U is mapped to its corresponding slot in the array T (only the keys 0, 1, and 2 are mapped in the diagram for simplicity). ![]()
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. Archives
December 2022
Categories |