
Write an efficient
Problem will be on repeat numbers
input will be ARRAY[1,2, ... , n] number of positive numbes.
Output will any one number that is repeated more than n/3 times.
for example, if you have [1,1,2,2,2,1], since n = 6 and n/3 = 2, both 1 and 2 showed up more than n/3 times. the output will be either 1 or 2 (just one of the values are required)
if you have [1,1,3,4,5,6,7,8,9], since 1 is only repeated twice, and n/3 = 3, output will be "none"

Trending nowThis is a popular solution!
Step by stepSolved in 5 steps with 4 images

- Suppose that each row of an n × n array A consists of 1's and 0's such that in any row of A all the 1's come before any O's in that row. Assuming that A is already in memory, describe an algorithm running in O(n) time for finding the row that contains the most 1's. Write the algorithm following the style of your course-notes.arrow_forwardIn c++ im supposed to use small sort algorythim to sort an array but im not sure how to do thatarrow_forwardSuppose that you have five different algorithms (A, B, C, D and E) for solving a problem. To solve a problem of size n, the number of operations used by each algorithm is as follows. As n grows, which algorithm uses the most operations? Algorithm number of operations n2+n3 B 2n+1 log n' 26+ log n n(logn)? +1 n100 Algorithm D Algorithm C Algorithm A Algorithm B o Algorithm Earrow_forward
- write a computer program that produces the desired output from the given input. Input: Elements in a finite set SOutput: Elements in ℘(S)Algorithm: Use recursion.arrow_forwardAre all of my answers correct?arrow_forwardConsider a variation of the Bucket Sort algorithm which uses an unknown number of buckets. We're given that the worst-case runtime of the algorithm is O(n.), Let the number of buckets be n* (n to the power of x). Fill in the following box with the proper numeric value of x such that the algorithm has the given runtime. For example, you could fill in 0, 1, 2, 3, 3.14 4.2, etc. Recall that we use Insertion Sort to sort each bucket. Answer:arrow_forward
- Write a program that, given an array a[] of Ndouble values, finds a closest pair : two values whose difference is no greater than thethe difference of any other pair (in absolute value). The running time of your programshould be linearithmic in the worst casearrow_forwardJAVA Make a function that will get the value of ln(n!). use Math.log() function in replace to ln()arrow_forwardkindly solve this problem using pythonarrow_forward
- Database System ConceptsComputer ScienceISBN:9780078022159Author:Abraham Silberschatz Professor, Henry F. Korth, S. SudarshanPublisher:McGraw-Hill EducationStarting Out with Python (4th Edition)Computer ScienceISBN:9780134444321Author:Tony GaddisPublisher:PEARSONDigital Fundamentals (11th Edition)Computer ScienceISBN:9780132737968Author:Thomas L. FloydPublisher:PEARSON
- C How to Program (8th Edition)Computer ScienceISBN:9780133976892Author:Paul J. Deitel, Harvey DeitelPublisher:PEARSONDatabase Systems: Design, Implementation, & Manag...Computer ScienceISBN:9781337627900Author:Carlos Coronel, Steven MorrisPublisher:Cengage LearningProgrammable Logic ControllersComputer ScienceISBN:9780073373843Author:Frank D. PetruzellaPublisher:McGraw-Hill Education





