http://cslibrary.stanford.edu/105/LinkedListProblems.pdf
-Moheed
On Sun, Dec 25, 2011 at 11:39 PM, atul anand atul.87fri...@gmail.comwrote:
@ashish : please provide link for that page
On Sun, Dec 25, 2011 at 10:36 PM, Ashish Goel ashg...@gmail.com wrote:
refer stanford page
1,2,3,4,5,6
Any reasonable algorithm is goingto compute a histogram of the data
then sort into frequency order to produce the output.
The histogram (map from data values to frequency counts) can be stored
in a simple array if the data are small integers as in the example.
If the data are not nice, then a
give an algorithm to find if a given integer is of the form m^n where
m 1 and n 1
One Approach I can think of is to find prime factors and verify if
they are of the form m^n
--
You received this message because you are subscribed to the Google Groups
Algorithm Geeks group.
To post to this
This problem is very old and O(NlgN) may be the best runtime .
--
You received this message because you are subscribed to the Google Groups
Algorithm Geeks group.
To post to this group, send email to algogeeks@googlegroups.com.
To unsubscribe from this group, send email to
@Gene:
I am wondering about the the N log N factor.
I agree with the log N component, but, can u clarify on the first component
in N * log N (N being no. of unique numbers)
we still check for each element in the input (n), the binary search among
'N' unique values.
Isn't this n log N
n -
From Wht I can understand from problm to check whether N can be
expressed a m^n : Eg: 1331=11^3
What comes to my mind is to get all prime factors from 2 to SQRT(N)
[Prime Sieve] , Here N is the Given Integer .
Now Iterate over the prime number(p) from 2 to Sqrt(N)
do
T=N;
if(!(T%p))
This algorithm won't work as primes might have different power. for
eg. N=12
12 is divisible by 2 so it ends up being 3. then 3 divides by 3. So it
prints possible. But the actual answer is no.
Correct code:
for (int i=2;i=sqrt(n);i++)
{
float ans = log(n)/log(2);
int an = ans;
if
Hello Samm
I got your approach
It seems it is not working for some of the examples
Eg: N = 6
6 = 2X3 = 1X6 and hence it is not possible
but your code prints Yes possible.
On Dec 26, 9:03 pm, SAMMM somnath.nit...@gmail.com wrote:
From Wht I can understand from problm to check whether N can
@lucifer: can you explain to me in the current median calculation why if
there is a Diff =1 or -1 you are using M and top(maxh) or M and top(minh)
for median calculation. If the number of elements from the stream so far is
odd then median is just one element and not average of 2 elements right?