Re: [algogeeks] Sum of the Sequence

2009-11-05 Thread Prunthaban Kanthakumar
This is a 'finite calculus' (differences summations) problem. You can solve it using difference operator (actually its inverse which gives you the discrete integration which is nothing but summation). If you do not know finite calculus, Google for it (or refer Concrete Mathematics by Knuth). The

[algogeeks] Re: 100!

2009-10-11 Thread Prunthaban Kanthakumar
On Sun, Oct 11, 2009 at 6:40 PM, Gautham Muthuravichandran gautha...@gmail.com wrote: 9.. All the factorials above 5! is divisible by 9. Divisible by 9 does not mean exactly 9. -Gautham On Sun, Oct 11, 2009 at 11:54 AM, Debanjan debanjan4...@gmail.com wrote: On Oct 11, 10:29 am,

[algogeeks] Re: n balls and k different colors 1=k=n

2009-10-10 Thread Prunthaban Kanthakumar
didn't get anything plz elaborate On Oct 10, 10:44 am, Prunthaban Kanthakumar pruntha...@gmail.com wrote: Sterling numbers of second kind. On Sat, Oct 10, 2009 at 10:41 AM, vicky mehta...@gmail.com wrote: example: n=10,k=10 ans:1 n=30,k=7 ans: 475020 On Oct 10, 9:51

[algogeeks] Re: n balls and k different colors 1=k=n

2009-10-09 Thread Prunthaban Kanthakumar
Sterling numbers of second kind. On Sat, Oct 10, 2009 at 10:41 AM, vicky mehta...@gmail.com wrote: example: n=10,k=10 ans:1 n=30,k=7 ans: 475020 On Oct 10, 9:51 am, vicky mehta...@gmail.com wrote: u have to color n similar balls with k diff. colors , such that every color must be

[algogeeks] Re: Missing numbers

2009-08-03 Thread Prunthaban Kanthakumar
Here is the right answer: Find the sum of missing numbers. Call it S (this is a easy to do). Now the two missing numbers are such that one is =S/2 and the other is S/2 Have two variables S1 and S2, traverse the array and add everything = S/2 to S1 and S/2 to S2. Now First number = (Sum of

[algogeeks] Re: Missing numbers

2009-08-01 Thread Prunthaban Kanthakumar
Try {2, 1} On Sat, Aug 1, 2009 at 11:45 AM, Devi G devs...@gmail.com wrote: @Vivek I had told abt tat border case already once.. Suppose the two missin numbers are greater than n, then m==0 when exitin the loop. So they will be n+1 and n+2 only. in case, one of the missin numbers is

[algogeeks] Re: Pigeon Hole Principle

2007-03-25 Thread Prunthaban Kanthakumar
On 3/25/07, Rajiv Mathews [EMAIL PROTECTED] wrote: On 3/25/07, Prunthaban Kanthakumar [EMAIL PROTECTED] wrote: If you see carefully his proof does not assume anything about sections colored continuously. His proof assumes only one thing Half of them are red and half of them are white

[algogeeks] Re: Pigeon Hole Principle

2007-03-25 Thread Prunthaban Kanthakumar
Ouch I got the question completely wrong assuming the inner disc is continuous.Sorry for the confusion. On 3/25/07, Prunthaban Kanthakumar [EMAIL PROTECTED] wrote: On 3/25/07, Rajiv Mathews [EMAIL PROTECTED] wrote: On 3/25/07, Prunthaban Kanthakumar [EMAIL PROTECTED] wrote: If you

[algogeeks] Re: Pigeon Hole Principle

2007-03-25 Thread Prunthaban Kanthakumar
not understand - For each inner section,no matter white or black ,there is 100 color-matching events. Can somebody explain? ~Vishal On 3/25/07, Prunthaban Kanthakumar [EMAIL PROTECTED] wrote: Ouch I got the question completely wrong assuming the inner disc is continuous.Sorry

[algogeeks] Re: Pigeon Hole Principle

2007-03-24 Thread Prunthaban Kanthakumar
Hi, The proof given by Vishal is correct irrespective of the arrangement (which he himself did not realize). If you see carefully his proof does not assume anything about sections colored continuously. His proof assumes only one thing Half of them are red and half of them are white Half does not

[algogeeks] Re: The Game

2007-02-21 Thread Prunthaban Kanthakumar
Try googling for Josephus Permutation On 2/22/07, Manish Garg [EMAIL PROTECTED] wrote: hi, I m posting a game, its like this: Suppose N people are playing the game. All of them are numbered from 1 to N. They all sit in a circle such that their numbering order is also maintained, so that

[algogeeks] Re: (need help) How to solve this random number generatioin problem?

2007-01-31 Thread Prunthaban Kanthakumar
Then you will get only the following numbers (1*7)/5 = 1 (2*7)/5 = 2 (3*7)/5 = 4 (4*7)/5 = 5 (5*7)/5 = 7 What you will do to get 3 and 6? On 2/1/07, pramod [EMAIL PROTECTED] wrote: Why can't we simply take the 1..5 random number, multiply by 7 and divide by 5.

[algogeeks] Re: whats the fastest way to find the odd man out?

2007-01-16 Thread Prunthaban Kanthakumar
XOR is the best computationally as well as space complexity. On 1/16/07, Satish [EMAIL PROTECTED] wrote: Hangjin Zhang wrote: Do an XOR on all numbers. The resulte is the number which occurs only once HZ On 12/30/06, Abhishek [EMAIL PROTECTED] wrote: Hi, Suppose I have a

[algogeeks] Re: Kurukshetra Online Programming Contest

2006-12-27 Thread Prunthaban Kanthakumar
Hi all, This does not look like a 'open to all' contest. The registration asks for college information! Can CEG guys confirm? Regards, Prunthaban On 12/26/06, Aravind Narayanan [EMAIL PROTECTED] wrote: Hello There! College of Engineering, Guindy announces the Kurukshetra Online Programming

[algogeeks] Re: Copying Books from Sphere online judge.

2006-10-11 Thread Prunthaban Kanthakumar
to the binary search. regards Arunachalam. On 10/10/06, Prunthaban Kanthakumar [EMAIL PROTECTED] wrote: hi, Giving a short thought... I think an O(n^2) greedy solution will work. Regards, Prunthaban On 10/10/06, Amal [EMAIL PROTECTED] wrote: http://www.spoj.pl/problems/BOOKS1/ For this problem

[algogeeks] Re: Nice question!! (part 2)

2006-09-26 Thread Prunthaban Kanthakumar
= 42 (This is lesser than previous one) So the optimum one including 4 is,is 4+7+8 Now appy the same O(n) procedure to both small half arrays... On 9/26/06, GoCooL [EMAIL PROTECTED] wrote: Prunthaban Kanthakumar wrote: Hi, The proposed solution does not talk about multiplication. It talks about

[algogeeks] Re: Nice question!! (part 2)

2006-09-25 Thread Prunthaban Kanthakumar
Hi, The proposed solution does not talk about multiplication. It talks about the sum alone. The sum is simply a[m]. Of course you need to muliply later.But that does not affect the correctness of the solution! Regards, Prunthaban On 9/24/06, GoCooL [EMAIL PROTECTED] wrote: This is the original

[algogeeks] Re: MineSweeper...

2006-08-25 Thread Prunthaban Kanthakumar
I didn't look into thecorrectness of the algorithm. But I can tell you the reason for that compilation error Visual Studio 6.0 does not follow ANSI standards! Especially the scope of the loop variable 'i' is the thing which causes compilation error for you. In ANSI C (or gcc for that matter), if

[algogeeks] Re: Nice question!!

2006-07-04 Thread Prunthaban Kanthakumar
When you have a nice algorithm from Googmeister in O(n log n) why try something else...? On 7/5/06, mg [EMAIL PROTECTED] wrote: #includestdio.hstruct key {int min;doublesum;}; int main(int argc,char **argv){int n,i,j,k;int start=0,end=0;double currentValue=0,eValue=0;struct key

[algogeeks] Re: DataStructure - Push,Pop Find_Min in O(1)

2006-03-26 Thread Prunthaban Kanthakumar
You can't sort using push-pop-findmin. @rajivmat push --- 4, 5, 6, 1, 3, 2- minarray = {0,3}pop -- 4, 5, 6, 1, 3 - minarray = {0,3}pop -- 4, 5, 6, 1- minarray = {0,3}find_min = 3rd element = 1pop -- 4, 5, 6 - minarray{0} =(Now top = mintop so minarray is also popped) find_min = 0th element = 4pop

[algogeeks] DataStructure - Push,Pop Find_Min in O(1)

2006-03-25 Thread Prunthaban Kanthakumar
Hi All,One of my friends asked me this questions:Can you frame a Stack like Data structure where Push,Pop and find_min takes O(1) time?Well...A Stack is already doing a good job by giving O(1) for Push and Pop. We need a method to make it support O(1) find_min too.Let me share my ideas. Comments

[algogeeks] Re: tree lock problem

2006-03-24 Thread Prunthaban Kanthakumar
Hi All,If I have understood the question correctly, then this will work! DFS is recursive. So even though our tree has no parent pointers, we will get such a 'pointer for free' , due to recursion. (Remember recursion allows you to pass information from child to parent) So a single highly pruned

[algogeeks] Re: tree lock problem

2006-03-24 Thread Prunthaban Kanthakumar
Hi all,I think there can be one more solution... where a BFS is folowed by DFS works.Algo 2:IsLockable(Node N){ queue Q; if(root is not locked) Q.insert(root); while(!Q.empty()) { Node n = Q.removeHead(); if(n == N) return DFS(n); for(each child a of N) If(a is not locked) Q.insert(a); } return

[algogeeks] Re: tree lock problem

2006-03-24 Thread Prunthaban Kanthakumar
Hi all,The third solution is... (I hope there will not be any fourth ;) )Two BFSs...1. The first BFS will traverse all unlocked nodes (same as solution one)...2. The second BFS will traverse until one locked node is encountered. Hey, guys... this is boring...It is always possible to convert

[algogeeks] Re: An interesting problem from Code4bill second round

2006-02-04 Thread Prunthaban Kanthakumar
No, dp[2] is 100 110 010 011 This is3 * dp[1] + 1 = 3 * 1 + 1 = 4 steps Regards, Prunthaban

[algogeeks] Re: rules for round3 code4bill

2006-02-03 Thread Prunthaban Kanthakumar
Use console application System calls are calls which modify the process,etc (Like fork() in unix) Win32 calls - (Accessing win32 api - Don't include windows.h) On 2/3/06, prick [EMAIL PROTECTED] wrote: hi everyoneRules for round 3 code4billf.Headers/Libraries: You can use the standard libraries

[algogeeks] Re: An interesting problem from Code4bill second round

2006-02-03 Thread Prunthaban Kanthakumar
Hi all, Sorry for the late reply. Anyway here is the solution... I want to note down 2 facts... 1. With 1 one the maximum reachable is 1 2. Any sequence of move is exactly reversible. You just have to toggle the bits in reverse order. Now the solution. With n ones.. 1. Use first n-1 ones

[algogeeks] Re: Abacus Online Programming Contest - January 29th

2006-01-18 Thread Prunthaban Kanthakumar
Inmost of the good opcs(Including Abacus)only the best code survives the tests! You can't write bubble sort when asked for a sorting algorithm! It will simply time out! So provided only the best algo survives, the next criteria for evaluation will obviously be How quick u came out with the idea

[algogeeks] Integer Partiotioning into 'n' equal sets!

2005-12-26 Thread Prunthaban Kanthakumar
Hi Guys, I havea question... Integer partitioning is NP-complete. So partitioning a set into 'n' number of equal sets is also in NP (When n=2 we get the first one). But Integer partitioning has a nice DP solution (though not in P)... Similarly does Integer partitioning into 'n' equal sets also

[algogeeks] Bitwise 06

2005-12-25 Thread Prunthaban Kanthakumar
Hi guys, I think most of you knew it... Incase some of you don't know... Bitwise is BACK! http://www.bitwise.iitkgp.ernet.in/ Check out on Jan 1st to register...