N marbles puzzle: find the heaviest among them. Suppose there are $N$ marbles and a two-pan balance used to compare the weight of 2 things. All of the marbles weigh the same except for one, which is heavier than all of the others. How would you find the heaviest marble in minimum number of comparisons.This link explains for $N=12$ .I have tried solving for $N$ but haven't come up with any solution.How it be can generalised for $N$ marbles? Explain in detail.

Divide your marbles into three groups. Compare group 1 vs group 2. If they are the same then you know the heavier marble is in group 3. If group 1 is heavier then the heavier marble is in group 1.  If group 2 is heavier then the heavier marble is in group 2. Repeat this process until you are comparing individual marbles. If you have a situation where you can not divide them evenly by three use marbles that have already been identified as normal to make up the difference. If the initial number of marbles doesn't evenly divide by 3 then make group 3 have one more or one less marble in it.
Each step will reduce the number of remaining (unidentified) marbles to a third (rounded up). So if there are N marbles after the $x^{th}$ weighing you will have only $\lceil\frac{N}{3^x}\rceil$ left. You want to continue until you get down to one. In the base case you'll have $N=3^x$. In the worst case $N=3^{x+1}-1$. So you will require $\lceil\log_3N\rceil$ weighs.
