Home > other >  Mergesort algorithm of similar topic don't let the value of an array
Mergesort algorithm of similar topic don't let the value of an array

Time:09-17

Assuming that give you A real array, not directly by means of A [I] to obtain the value of the array number inside
Suppose you can call a function Q () receives an array and then can tell you how many inside the array of repeat number, e.g. T=,2,2 {1}
Q (T)=2Problem: how to use the call Q O (nlogn) time () function to find the array number of repeat all sorts an array by the values and the classification of the same value together, different don't together

Leaders willing to be solved, many people have a look at is the classic mergesort similar topic, but given that cannot be directly to check the number of values, only to find the O (n ^ 2 logn) method, which is a total of recursive logn layer, each layer of recursion with the O (n ^ 2) to find the repeat number, thanks!
  • Related