Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Please Help This is not a programming assignment. Write code or pseudocode 1. Given an array A, return a list that has those elements of

Please Help

image text in transcribed

This is not a programming assignment. Write code or pseudocode 1. Given an array A, return a list that has those elements of A that occur most often, in the order of their first appearance in A. Solve the problem using hash tables in expected time of O(n) For example, if A= {2,6,3,4,5,4,6,3,5,4,5,6). mostOften (A) returns {6,4). Both elements appear 3 times in A, more often than the other elements, and the first occurrence of 6 in A is before the first occurrence of 4 Analyze the expected running time of the algorithm. Optional problem for extra credit: 2. Given an array A of integers, find the length of a longest streak of consecutive integers that occur in A (not necessarily contiguously). Solve the problem using hash tables in expected time of O(n). For example, if A -11,7,9,4,1,7,4,8,7,1), then longestStreak (A) returns 3, corresponding to the streak (7,8,9 of consecutive integers that occurs somewhere in A Explain why the expected running time of your algorithm is O(n). This is not a programming assignment. Write code or pseudocode 1. Given an array A, return a list that has those elements of A that occur most often, in the order of their first appearance in A. Solve the problem using hash tables in expected time of O(n) For example, if A= {2,6,3,4,5,4,6,3,5,4,5,6). mostOften (A) returns {6,4). Both elements appear 3 times in A, more often than the other elements, and the first occurrence of 6 in A is before the first occurrence of 4 Analyze the expected running time of the algorithm. Optional problem for extra credit: 2. Given an array A of integers, find the length of a longest streak of consecutive integers that occur in A (not necessarily contiguously). Solve the problem using hash tables in expected time of O(n). For example, if A -11,7,9,4,1,7,4,8,7,1), then longestStreak (A) returns 3, corresponding to the streak (7,8,9 of consecutive integers that occurs somewhere in A Explain why the expected running time of your algorithm is O(n)

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

XML Data Management Native XML And XML Enabled Database Systems

Authors: Akmal Chaudhri, Awais Rashid, Roberto Zicari, John Fuller

1st Edition

0201844524, 978-0201844528

More Books

Students also viewed these Databases questions

Question

How does selection differ from recruitment ?

Answered: 1 week ago

Question

Question What is the advantage of a voluntary DBO plan?

Answered: 1 week ago