Re: [algogeeks] Re: Endian-ness check

2010-06-16 Thread Sundeep Singh
little-endian else big-endian (there exists mixed-endianness also, but lets leave that for now.) --Sundeep. On Tue, Jun 15, 2010 at 9:05 PM, Lego Haryanto legoharya...@gmail.comwrote: On Mon, Jun 14, 2010 at 5:13 AM, Sundeep Singh singh.sund...@gmail.comwrote: @saurav: your code

Re: [algogeeks] unique number in an array

2010-06-15 Thread Sundeep Singh
use a hash map On Mon, Jun 14, 2010 at 12:14 AM, jalaj jaiswal jalaj.jaiswa...@gmail.comwrote: give an algo to find a unique number in an array for eg a[]={1,3,4,1,4,5,6,1,5} here 3 is the unique number as it occur only once... moreover array contains only 1 unique number -- With

Re: [algogeeks] Re: Endian-ness check

2010-06-15 Thread Sundeep Singh
@saurav: your code will always print 2 irrespective of the system's endianness! correct thing to do is: printf(%d, *(char *) (0x0002)) --Sundeep. On Mon, Jun 14, 2010 at 3:02 AM, Minotauraus anike...@gmail.com wrote: How about a pointer? :D On Jun 13, 5:56 am, debajyotisarma

Re: [algogeeks] Re: binary nos

2010-06-10 Thread Sundeep Singh
@rohit: fibonacci sequence may be the answer to the prob, but I am curious why? I haven't come across any such fib sequence property... On Wed, Jun 9, 2010 at 9:16 PM, Rohit Saraf rohit.kumar.sa...@gmail.comwrote: @junta : are fibonacci sequence is the answer of the prob, it is not used :D

Re: [algogeeks] Re: binary nos

2010-06-09 Thread Sundeep Singh
Whats the logic behind using Fibonacci in determining the number of such sequences? -Sundeep. On Wed, Jun 9, 2010 at 8:02 AM, Rohit Saraf rohit.kumar.sa...@gmail.comwrote: Fib comes because she wants the number of such sequences -- -- Rohit

Re: [algogeeks] Re: divisible by 3

2010-06-07 Thread Sundeep Singh
@Anand and @Minotaurus The code seems to fail for 15. Am I missing something? On Mon, Jun 7, 2010 at 2:20 AM, Minotauraus anike...@gmail.com wrote: @Anand: Thanks for the code. I knew you could do it by bit shifting. :-) On Jun 5, 10:21 pm, Anand anandut2...@gmail.com wrote: Here is a

Re: [algogeeks] Puzzle

2010-06-06 Thread Sundeep Singh
place the L block diagonally... --Sundeep. On Sun, Jun 6, 2010 at 7:29 PM, sharad sharad20073...@gmail.com wrote: A square Island surrounded by bigger square, and in between there is infinite depth water. The distance between them is L. The wooden blocks of L are given. The L length block

Re: [algogeeks] Check if 2 linked lists are identical

2010-06-03 Thread Sundeep Singh
merge sort both lists: O(nlogn) Now, for both lists to be identical, just compare the corresponding elements in the lists i.e. L1(1) == L2(1), L1(2) == L2(2) ... = O(n) --Sundeep. On Wed, Jun 2, 2010 at 10:47 PM, Raj N rajn...@gmail.com wrote: @Antony: The 2 lists should have the same

Re: [algogeeks] value of n

2010-05-03 Thread Sundeep Singh
oops On Sat, May 1, 2010 at 5:50 PM, Sundeep Singh singh.sund...@gmail.comwrote: Hi Amit, here's the answer: (I am assuming in your equation lg implies log to the base 10) n 8 log(n) = n/8 log(n) = 10 ^(n/8) n The final deduction was incorrect!! for log base 10, the answer is: 2

Re: [algogeeks] value of n

2010-05-03 Thread Sundeep Singh
it on paper? -Regards Amit Agarwal Contact: 09765348182 www.amitagrwal.com On Mon, May 3, 2010 at 3:02 PM, Sundeep Singh singh.sund...@gmail.comwrote: oops On Sat, May 1, 2010 at 5:50 PM, Sundeep Singh singh.sund...@gmail.comwrote: Hi Amit, here's the answer: (I am assuming in your

Re: [algogeeks] Re: Implement a queue using a stack

2010-03-23 Thread Sundeep Singh
. There is room for a little optimization if both stacks are empty when enquing, as you can push the item directly onto stack B. Furthermore, when popping from stack A and pushing onto stack B, you don't need to push the last item popped, as it is the return value. Dave On Mar 22, 9:29 am, Sundeep

Re: [algogeeks] Implement a queue using a stack

2010-03-22 Thread Sundeep Singh
Hey Brian, Better still, for inserting in queue, just keep pushing onto the stack A. You need stack B only for dequeuing: for dequeuing, push all items into stack B, pop as many as you want from stack B and then push back all remaining items in stack A. Regards, Sundeep. On Mon, Mar 22, 2010