Re: [algogeeks] a google question

2010-05-02 Thread Shishir Mittal
This problem has been discussed before @ http://groups.google.co.in/group/algogeeks/browse_thread/thread/9c1e1aa8cf1ed437/d451cd9468d985f7 I believe, the problem can't be solved in O(n) but only in O(nlog n). @Divya: Are you sure the interviewer explicitly asked for an O(n) time algorithm? On

Re: [algogeeks] Inorder traversal on binary tree

2009-11-28 Thread Shishir Mittal
. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en. -- Shishir Mittal Ph: +91 9936 180 121 -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algoge...@googlegroups.com

[algogeeks] Re: optimum algo for second largest

2009-10-12 Thread Shishir Mittal
(log n) - 2 from (n-1 + n-2) comparisons that would be required in case of a naive algorithm where one first finds the maximum and then finds the maximum of the remaining elements of the array. -- Shishir Mittal Ph: +91 9936 180 121 --~--~-~--~~~---~--~~ You

[algogeeks] Re: optimum algo for second largest

2009-10-11 Thread Shishir Mittal
anyone give me algorithm for finding the second largest element in array using tournament method requiring n+logn-2 compariso -- Shishir Mittal Ph: +91 9936 180 121 --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups

[algogeeks] Re: second highest elemt in an aary

2009-09-29 Thread Shishir Mittal
doesn't provide correct results. Try to dry run the code for some more test cases like ( 4 3 2 1) , ( 3 1 3 2). Refer Introduction to Algorithms, II Ed. (Cormen) Exercise 9.1-1 and the preceding discussion for more info regarding tournament principle. -- Shishir Mittal Ph: +91 9936 180 121

[algogeeks] Re: second highest elemt in an aary

2009-09-28 Thread Shishir Mittal
and then highest among the number which get defeated during tournament. (details in corment). Can anyone do code implemenation for this one. Thanks Nagendra -- Shishir Mittal Ph: +91 9936 180 121 --~--~-~--~~~---~--~~ You received this message because

[algogeeks] Re: second highest elemt in an aary

2009-09-28 Thread Shishir Mittal
the highest number and then highest among the number which get defeated during tournament. (details in corment). Can anyone do code implemenation for this one. Thanks Nagendra -- Shishir Mittal Ph: +91 9936 180 121 --~--~-~--~~~---~--~~ You received

[algogeeks] Re: second highest elemt in an aary

2009-09-28 Thread Shishir Mittal
; int ar[n]; for(i=0;in;i++) cinar[i]; res=sec_largest(ar,n); coutsecond largest number=resendl; } -- Shishir Mittal Ph: +91 9936 180 121 --~--~-~--~~~---~--~~ You received this message because you

[algogeeks] Re: What algorithm can be used to decide the denomination of notes in an ATM machine?

2009-09-21 Thread Shishir Mittal
. What algorithm can be used to decide how to break up the entered amount? -- Shishir Mittal Ph: +91 9936 180 121 --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send

[algogeeks] Re: Z[n^2]={such that z belongs to X+Y

2009-09-19 Thread Shishir Mittal
]+1. In the proposed algorithm, searching for minimum element is done using min heap. -- Shishir Mittal Ph: +91 9936 180 121 --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post

[algogeeks] Re: Z[n^2]={such that z belongs to X+Y

2009-09-15 Thread Shishir Mittal
A correction in the proposed algorithm. On Tue, Sep 15, 2009 at 1:08 PM, Shishir Mittal 1987.shis...@gmail.comwrote: *Algorithm.* 1) Corresponding to each element in X, create a node with 2 values, to be compared indexed of Y, and the corresponding sum. NODE[i] = {yIndex, sum = X[i

[algogeeks] Re: Z[n^2]={such that z belongs to X+Y

2009-09-15 Thread Shishir Mittal
smallest no of Z in O(n) time. Space complexity : No bound on it. But try to optimize it if possible. -- Shishir Mittal Ph: +91 9936 180 121 --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups Algorithm Geeks group

[algogeeks] Re: addition without using arithmetic operators

2009-09-10 Thread Shishir Mittal
0 -- hence 43 + 14 = 111001 = 57 -- Shishir Mittal Ph: +91 9936 180 121 --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks

[algogeeks] Re: minimum difference.

2009-09-01 Thread Shishir Mittal
is minimum. -- Shishir Mittal Ph: +91 9936 180 121 --~--~-~--~~~---~--~~ 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

[algogeeks] Re: Median Finding algorithms.

2009-09-01 Thread Shishir Mittal
understand cann u give an example.. -- Shishir Mittal Ph: +91 9936 180 121 --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks

[algogeeks] Re: 1 Trillion integers on hard disk, find the smallest 1 million of them

2009-09-01 Thread Shishir Mittal
of. -- Shishir Mittal Ph: +91 9936 180 121 --~--~-~--~~~---~--~~ 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

[algogeeks] Re: Median Finding algorithms.

2009-08-31 Thread Shishir Mittal
wrote: Given a set S of n distinct numbers and a positive integer k = n. Determine the k numbers in S that are closest to the median of S. Find an O(n) algorithm -- Shishir Mittal Ph: +91 9936 180 121 --~--~-~--~~~---~--~~ You received this message

[algogeeks] Re: nth number of k bits

2009-08-27 Thread Shishir Mittal
-- Shishir Mittal Ph: +91 9936 180 121 --~--~-~--~~~---~--~~ 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

[algogeeks] Re: nth number of k bits

2009-08-27 Thread Shishir Mittal
There were some errors in my solution. On Thu, Aug 27, 2009 at 6:10 PM, Shishir Mittal 1987.shis...@gmail.comwrote: Its a bit similar to finding the rank of the word COMPUTER in the dictionary among the words formed from C,O,M,P,U,T,E,R. Find maximum r such that (k+r)C(r) n