Question: Use any of the languages from C, Python, or java. Python preferred. [10] For this problem, we define the golden element of a collection of
Use any of the languages from C, Python, or java. Python preferred. 
[10] For this problem, we define the golden element of a collection of n elem ents to be the element at index0.618x n in the sorted list of all the elements (where index starts from 1). Note that this definition does not imply that the collection of elements is always fully sorted. It is only a convenient way to define the notion of "golden element rigorously, by imagining the elements in sorted order Consider the following abstract data type that we will call a "GOLDEN-SET." 3. Objects: A collection of elements taken from an ordered set (i.e., elements can be compared with each other). Duplicate elements are allowed (this is why we use the term "collection" instead of "set") Operations: INSERT(S,z): Add element r to the collection S FIND-GOLD(S): Return the golden element of collection S without removing it DIG-GOLD(S): Remove and return the golden element of collectionS Requirements: Let n be the size of S, INSERT(S, x) must have worst-case runtime O(logn) FIND-GOLD(S) must have worst-case runtime O(1) DIG-GOLD(S) must have worst-case runtime O(log n) Give a detailed description of a data structure that implements GOLDEN-SET and satisfies the above requirements on runtime. Described your algorithms for each of the operations, and justify that they are correct and have the required worst-case runtime
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
