Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

You are given a list L of n, not necessarily distinct, integers. Your task is to devise an algorithm that outputs a list of the

You are given a list L of n, not necessarily distinct, integers. Your task is to devise an algorithm that outputs a list of the distinct integers in L, in order of non-increasing frequency (the frequency of an element in L is the number of times it occurs in L). For example, if L is 2, 5, 4, 4, 2, 3, 4, 3, then a suitable output is 4, 3, 2, 5; the only other suitable output for this list is 4, 2, 3, 5. In this example, L contains only small integers, but this is not always the case. You cannot make any assumption on the integers in L (e.g., their maximum size, or distribution). In particular, some integers of L can very large, and so it is not feasible to use tables of size proportional to these integers. a. Give a Hash Table-based algorithm for this problem whose expected time complexity is O(n), under some Hash Table assumptions that you must clearly state. Explain why, your algorithm achieves this time complexity under these assumptions. What is the worst-case time complexity of your algorithm? Use the notation and justify your answer. Hint: As part of your algorithm, you may find useful to discover a way to sort n numbers in the range 0 to n in O(n) worst-case time. b. Give an algorithm for this problem whose worst-case time complexity is O(n log n). Explain why your algorithm achieves this time complexity.

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

MFDBS 91 3rd Symposium On Mathematical Fundamentals Of Database And Knowledge Base Systems Rostock Germany May 6 9 1991

Authors: Bernhard Thalheim ,Janos Demetrovics ,Hans-Detlef Gerhardt

1991st Edition

3540540091, 978-3540540090

More Books

Students also viewed these Databases questions

Question

Methods of Delivery Guidelines for

Answered: 1 week ago