Re: [algogeeks] Addition Of numbers in SLL

2010-08-14 Thread UMESH KUMAR
On Sat, Aug 14, 2010 at 12:52 PM, AlgoBoy manjunath.n...@gmail.com wrote: Add two numbers represented in a SLL. Each digit is represented as a node...the length of the lists may be more than 2000... Wat is the most efficient soln...store the added digits in another SLL...and return the head

Re: [algogeeks] Addition Of numbers in SLL

2010-08-14 Thread Lokesh Agarwal
first reverse the both link list and than add -- 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. To unsubscribe from this group, send email to

[algogeeks] Re: P ! = NP

2010-08-14 Thread LawCounsels
On 11 Aug, 23:54, Kishen Das kishen@gmail.com wrote: http://www.telegraph.co.uk/science/science-news/7938238/Computer-scie... Check out this cool news. Kishen On 10 Aug, 06:50, Niels Fröhling spamt...@adsignum.com wrote: Up to date reactions, comments of the community/researchers

[algogeeks] Algorithm to find all subsets of size K

2010-08-14 Thread asdf
Most efficient algorithm to find all subsets of size K?? -- 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. To unsubscribe from this group, send email to

[algogeeks] how to implement TAIL command of unix.

2010-08-14 Thread amit
I am trying using fseek but somehow its not working? -- 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. To unsubscribe from this group, send email to

[algogeeks] Re: Addition Of numbers in SLL

2010-08-14 Thread Gaurav Singh
Reversing the lists and then adding and then reversing the final list is the most appropriate method. Bcoz the lists may contain arbitarily large numbers, so forming integers then adding is not logical here. -- You received this message because you are subscribed to the Google Groups

[algogeeks] a help

2010-08-14 Thread rahul rai
can anyone suggest me lectures / videos for BASICS of BITS manipulation? thanks in advance Rahul K Rai rahulpossi...@gmail.com -- 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.

Re: [algogeeks] a help

2010-08-14 Thread Asit Baran Das
http://graphics.stanford.edu/~seander/bithacks.html http://graphics.stanford.edu/~seander/bithacks.htmlit has all that you need. On Sat, Aug 14, 2010 at 7:53 PM, rahul rai raikra...@gmail.com wrote: can anyone suggest me lectures / videos for BASICS of BITS manipulation? thanks in advance

Re: [algogeeks] a help

2010-08-14 Thread rahul rai
Thanks a lot , it's a life saver , i will work it out fully . 2010/8/14, Asit Baran Das asitbaran@gmail.com: http://graphics.stanford.edu/~seander/bithacks.html http://graphics.stanford.edu/~seander/bithacks.htmlit has all that you need. On Sat, Aug 14, 2010 at 7:53 PM, rahul rai

[algogeeks] Back tracking in list

2010-08-14 Thread UMESH KUMAR
explain ,if anybody known how to back tracking a Singly link list as a Doubly list with XOR -operation or any method if implementation of a Doubly link list using only one pointer . Explain with help of example -- You received this message because you are subscribed to the Google Groups

Re: [algogeeks] Re: Addition Of numbers in SLL

2010-08-14 Thread Rahul Singhal
i think we can access numbers from last so no need to reverse it and also we can store it in linke list in stack way so again no need to reverse the linked list. On Sat, Aug 14, 2010 at 7:03 PM, Gaurav Singh gogi.no...@gmail.com wrote: Reversing the lists and then adding and then reversing the

Re: [algogeeks] Re: Addition Of numbers in SLL

2010-08-14 Thread Lokesh Agarwal
how can you traverse from last without reversing it. and there is no need fof using extra stack space. -- 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. To unsubscribe from this

Re: [algogeeks] Re: Addition Of numbers in SLL

2010-08-14 Thread Rahul Singhal
I men to say ki just traverse from last instead of reversing it and storing result in a stack in linked list form so that we dont need to reverse again.Hope,i made myself clear. On Sat, Aug 14, 2010 at 11:40 PM, Lokesh Agarwal lokesh...@gmail.comwrote: how can you traverse from last without

Re: [algogeeks] Re: Addition Of numbers in SLL

2010-08-14 Thread Manjunath Manohar
Reversing and then again reversing the answer will not be an efficient algorithm... on the fly computation of sum must be done...any ideas On 8/14/10, Rahul Singhal nitk.ra...@gmail.com wrote: I men to say ki just traverse from last instead of reversing it and storing result in a stack in

[algogeeks] Re: Back tracking in list

2010-08-14 Thread Gene
Part 1 of the trick is that if you know A xor B and you have either A or B, you can get the other value. This is because A xor (A xor B) = B and B xor (A xor B) = B. [Incidentally, you can use subtraction rather than XOR. If you know A - B and have A, you can compute A - (A - B) to get B. If

[algogeeks] Re: Generate all bit strings of length n

2010-08-14 Thread Prem Mallappa
On 13 Aug, 17:05, Chonku cho...@gmail.com wrote: Start with number 1. It will have a binary representation of 00...1 (Total of n-bits) Keeping adding 1 to it until you reach a number with all 1's in its binary representation. Looks correct to me, here is a small implementation

[algogeeks] Re: how to implement TAIL command of unix.

2010-08-14 Thread Prem Mallappa
Tail by default displays last 10 lines of file. 1. mmap the file 2. keep two pointers(A, B) pointing to beginning of the file 2. search for 10th \n using B, if not found i.e file has less than 10 lines, print from beginning to end 3. if found, start incrementing both A and B to the next \n.

Re: [algogeeks] Re: P ! = NP

2010-08-14 Thread Kishen Das
http://rjlipton.wordpress.com/2010/08/12/fatal-flaws-in-deolalikars-proof/ Looks like there are serious flaws with this proof but it can produce other interesting results. http://rjlipton.wordpress.com/2010/08/12/fatal-flaws-in-deolalikars-proof/ Kishen On Sat, Aug 14, 2010 at 7:30 AM,

Re: [algogeeks] Re: Addition Of numbers in SLL

2010-08-14 Thread Prashant Kulkarni
i think we can use recursion method to reverse the list -- Prashant Kulkarni On Sat, Aug 14, 2010 at 11:40 PM, Lokesh Agarwal lokesh...@gmail.comwrote: how can you traverse from last without reversing it. and there is no need fof using extra stack space. -- You received this message

[algogeeks] Shuffling a deck of cards

2010-08-14 Thread amit
write a program to shuffle an pack of cards in the most efficient way. -- 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. To unsubscribe from this group, send email to

Re: [algogeeks] Shuffling a deck of cards

2010-08-14 Thread sharad kumar
for(i=0;i52;++i) { int r=rand()%52; swap(a[i],a[r]); } On Sat, Aug 14, 2010 at 11:46 PM, amit amitjaspal...@gmail.com wrote: write a program to shuffle an pack of cards in the most efficient way. -- You received this message because you are subscribed to the Google Groups Algorithm Geeks

[algogeeks] Re: Shuffling a deck of cards

2010-08-14 Thread Dave
@Sharad: Your code does not produce equally probable shuffles. You can see this by noting that a[0] is swapped with one of 52 cards, same for a[1], a[2], ..., a[51]. Thus, there are 52^52 possible sets of swaps. But there are only 52! possible outcomes, and 52^52 / 52! is not an integer. You can

[algogeeks] Re: how to implement TAIL command of unix.

2010-08-14 Thread Gene
Tail works on stdin, too. Can't mmap that. The usual way is to buffer the last N lines read in a ring buffe.r On Aug 14, 4:22 pm, Prem Mallappa prem.malla...@gmail.com wrote: Tail by default displays last 10 lines of file. 1. mmap the file 2. keep two pointers(A, B) pointing to beginning of

[algogeeks] Re: Addition Of numbers in SLL

2010-08-14 Thread Dave
Don't reverse the list. Just store it from low to high order digits. I.e., the head points to the ones digit, which points to the tens digit, etc. That is the assumption I made with my algorithm presented in the second post of this thread, because almost all operations use the number beginning

[algogeeks] Re: how to implement TAIL command of unix.

2010-08-14 Thread Dave
Enter the lines into a FIFO queue as you read them. After you have enqueued n lines, dequeue a line every time you enqueue one, so that the queue will contain the last n (or fewer) lines of the file. Dave On Aug 13, 1:13 pm, amit amitjaspal...@gmail.com wrote: I am trying using fseek but