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

2009-09-21 Thread Nagendra Kumar
idea is to give note of each denomination at least once (if possible). On Mon, Sep 21, 2009 at 10:59 AM, Shishir Mittal <1987.shis...@gmail.com>wrote: > Let the denominations be D[] = {1000,500,100}, > and amount be N. > Let C[] , denotes the count of each denomination. > for ( i=0 ; i < 2 ; i++)

[algogeeks] second highest elemt in an aary

2009-09-19 Thread Nagendra Kumar
I want an algo for finding second highest element in n + log n- 2 comparisons. The algo is first find 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 --~--~-~

[algogeeks] Re: crazy man in the airplane

2009-09-11 Thread Nagendra Kumar
1/2 On Thu, Sep 10, 2009 at 10:51 PM, ankur aggarwal wrote: > crazy man in the airplane > > A line of 100 airline passengers is waiting to board a plane. they each hold > a ticket to one of the 100 seats on that flight. (for convenience, let's say > that the nth passenger in line has a ticket f

[algogeeks] probabiltiy + DP

2009-09-09 Thread Nagendra Kumar
@all: There are k baised coins with probabilty of coming head is P(i) i = 1 to k. If all these coins are tossed together. find the probabilty of getting i heads ( i < = k). think in Dynamic Programming. -Nagendra --~--~-~--~~~---~--~~ You received t

[algogeeks] Re: random number...

2009-09-07 Thread Nagendra Kumar
@ankur: u r right. On Mon, Sep 7, 2009 at 9:36 PM, ankur aggarwal wrote: > I KNow a sol for given a rand_5() function which generates 0 to 5 > and we have to find rand_7() for 0 to 7 > > could not think about it... > > > > On Mon, Sep 7, 2009 at 9:26 PM, ankur aggarwal > wrote: >> >> Given a ran

[algogeeks] Re: find triangle in a graph

2009-09-07 Thread Nagendra Kumar
is it not finding a cycle in a graph of length 3. On Sun, Sep 6, 2009 at 9:02 PM, Dufus wrote: > > The following approach might work. > Let K be the maximum degree of a vertex in the graph > Enumerate each of the n vertex as 1...n > Enumerate undirected edge between vertex i and j  (i.e. i--j

[algogeeks] Re: Find longest palindrom in a give n string in O(N)

2009-09-06 Thread Nagendra Kumar
@all: T(i,j) : denotes the length of longest palindrome with start index i and end index j index. T(i,j )= max { 1 , if i == j; 2+T(i+1,j-1) if x[i] == x[j]; max(T(i

[algogeeks] Re: adobe interview question

2009-09-02 Thread Nagendra Kumar
Can anyone recheck and rephrase the question becuase i think it would be always '0' On Wed, Sep 2, 2009 at 10:40 AM, Nayn wrote: > > Guys, We are anticipating an algorithm here. > > The input would be an array containing 0/1 representing black and > white boxes. > > On Sep 1, 8:37 pm, yash wrot

[algogeeks] Re: N-Ary Tree and Resource management

2009-09-01 Thread Nagendra Kumar
its descendant or ancestor is  locked "   .. > > should not be > > " A node cannot be locked if any of its " ancestor "  is > locked." > > On Sat, Aug 29, 2009 at 11:35 PM, nagendra kumar > wrote: >> >> Given a n-ary tree of resources arranged

[algogeeks] Re: adobe interview question

2009-09-01 Thread Nagendra Kumar
@all: Yah it's 100% true that for 32 white and 32 black we have min distance at 0. But question will become difficult when the number of white and blacks are less than 32. -Nagendra On Tue, Sep 1, 2009 at 9:30 PM, Ramaswamy R wrote: > If the white and the black squares are not arrange

Fwd: [algogeeks] Re: String- Anagrams.

2009-09-01 Thread Nagendra Kumar
@Anil: I will request you to completly explain the things. Not just write a bit of code. So what is map and how are you implementing the insert operation. -- Forwarded message -- From: Anil C R Date: Mon, Aug 31, 2009 at 7:59 PM Subject: [algogeeks] Re: String- Anag

[algogeeks] Re: N-Ary Tree and Resource management

2009-09-01 Thread Nagendra Kumar
l (which is a pretty ugly solution considering what >> > unlock >> > > would have to do). >> >> > > If we can supplement the tree node with a lock status and pointer to >> > child >> > > (only used while unlocking) which is locked we should be

[algogeeks] Re: Median Finding algorithms.

2009-09-01 Thread Nagendra Kumar
wrote: > @ Nagendra Kumar > U can refer Cormen book; it is available... > > On Sun, Aug 30, 2009 at 8:06 AM, Dufus wrote: >> >> Is it acceptable if I >> find the median in O(logn) time and then, >> find k numbers closest to the median in O(k) space and O(n) time

[algogeeks] Re: Median Finding algorithms.

2009-08-31 Thread Nagendra Kumar
What ever you have just post here ! On Sun, Aug 30, 2009 at 5:08 PM, Nagendra Kumar 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(

[algogeeks] Re: N-Ary Tree and Resource management

2009-08-30 Thread Nagendra Kumar
NodeToBeLocked) >> > > { >> > >   if(check(NodeToBeLocked)) // If true, Node is free to be locked >> > >   { >> > >     node *m=NodeToBeLocked; >> > >     m->lock=true; >> > >     node *prevChild=m; >> > >     m=

[algogeeks] Median Finding algorithms.

2009-08-30 Thread Nagendra Kumar
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 --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Algorithm G

[algogeeks] Re: String- Anagrams.

2009-08-30 Thread Nagendra Kumar
@Anil: Dictionary is given to you. For each string t in array u = sort(t). if(s == u) print (t). If dictionary has mi

[algogeeks] String- Anagrams.

2009-08-30 Thread Nagendra Kumar
Write a method to print all valid anagrams of a string -Nagendra --~--~-~--~~~---~--~~ 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 unsubscrib

[algogeeks] Re: N-Ary Tree and Resource management

2009-08-30 Thread Nagendra Kumar
>> >     { >> >      m->LockCount++; >> >       prevChild=m; >> >       m=m->parent; >> >     } >> >     return true; >> >   } >> >   return false; //err.. cannot be locked >> > >> > } >> > >

[algogeeks] N-Ary Tree and Resource management

2009-08-29 Thread nagendra kumar
Given a n-ary tree of resources arranged hierarchically. A process needs to lock a resource node in order to use it. But, A node cannot be locked if any of its descendant or ancestor is locked. I was supposed to -> write the structure of node -> write codes for -> islock()- returns true if a giv

[algogeeks] Re: find elements in array with odd frequency

2009-08-24 Thread Nagendra Kumar
> basically corresponds to elements with odd frequency). > > _dufus > > > On Aug 23, 8:44 am, Nagendra Kumar wrote: >> How are u doing with xor. Can u post ur thought here. >> >> Thanks >> Nagendra >> >> >> >> On Sun, Aug 23, 20

[algogeeks] Re: find elements in array with odd frequency

2009-08-22 Thread Nagendra Kumar
How are u doing with xor. Can u post ur thought here. Thanks Nagendra On Sun, Aug 23, 2009 at 2:07 AM, Dufus wrote: > > We can count or XOR but I couldnt find any advantage of XORing except > for preventing overflow. > > _dufus > > > > On Aug 22, 5:03 pm, Nagendra K

[algogeeks] Re: find elements in array with odd frequency

2009-08-22 Thread Nagendra Kumar
come up with a better algo. > > _dufus > > > > > > On Aug 21, 3:01 pm, nagendra kumar wrote: >> Given an array of integers,Print the integers whose appareance are in >> odd times. >> Need not worry abt order while printing the output. >> Need Algoti

[algogeeks] find elements in array with odd frequency

2009-08-21 Thread nagendra kumar
Given an array of integers,Print the integers whose appareance are in odd times. Need not worry abt order while printing the output. Need Algotithm in o(n) time complexity. Need efficient space complexity. --~--~-~--~~~---~--~~ You received this message because you

[algogeeks] Re: Find an element in sorted matrix

2009-08-21 Thread Nagendra Kumar
actually possible. > > _dufus > > > > On Aug 20, 6:41 pm, nagendra kumar wrote: >> How can we find an element in the matrix [n*n] which is sorted row >> wise and column wise in O(log n). > > > > --~--~-~--~~~---~--~~ You rec

[algogeeks] Find an element in sorted matrix

2009-08-20 Thread nagendra kumar
How can we find an element in the matrix [n*n] which is sorted row wise and column wise in O(log n). --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Algorithm Geeks" group. To post to this group, send email to algog