Answered step by step
Verified Expert Solution
Question
1 Approved Answer
6. Suppose we construct a data structure to store distinct nonnegative integers as follows: We have a standard list (1-d array) A for which
6. Suppose we construct a data structure to store distinct nonnegative integers as follows: We have a standard list (1-d array) A for which each entry has the form [a, ptr] where a is a nonnegative integer and ptr is a pointer to a sorted linked list. The list A is sorted by the integer values. Given an integer k which we wish to store, Let a be the leftmost half (rounding down) of the digits in k and let be the rightmost remaining digits. (For example if k = 1234 then a = 12 and B 34 and if k 12345 then a = 12 and = 345.) = = We first see if [a, ptr] (for some pointer ptr) exists in A and if it does then we insert into the linked list which ptr points to, otherwise we create a linked list pointed to by ptr consisting of the value and insert [a, ptr] into A. (a) Illustrate the data structure look like after the following are inserted: k = = 46, 456, 1234, 409 (b) As a function of n, the number of elements in the data structure, What is the worst-case O time complexity of inserting some integer k? Assume that we can use a binary search on A (but not on the linked lists) and that extracting a and from k are O(1). Explain.
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started