Re: [algogeeks] Finding all prime less than 10^8

2010-04-12 Thread BlackdiamonD
thank kartik thanks but it was with lot of optimized code i was unable to understand though i have changed my code more know it is taking around 8 to 8.5 seconds in my computer but still i am getting TLE on server #includestdio.h #define ten8 (1) const int mod=32; unsigned int

Re: [algogeeks] First k smallest elements

2010-04-12 Thread Nikhil Agarwal
Hey rohit.You were referring to Binary tree.Search keyword was missing.Because rotation makes no sense in binary tree.Please note binary tree and BST are different. On Mon, Apr 12, 2010 at 12:33 PM, Rohit Saraf rohit.kumar.sa...@gmail.comwrote: Read the slides i uploaded. They explain what

Re: [algogeeks] First k smallest elements

2010-04-12 Thread Rohit Saraf
are yaar... i meant BST... i thought that was obvious ! sry if i confused you -- Rohit Saraf Second Year Undergraduate, Dept. of Computer Science and Engineering IIT Bombay http://www.cse.iitb.ac.in/~rohitfeb14 On Mon, Apr 12, 2010 at 12:38

Re: [algogeeks] First k smallest elements

2010-04-12 Thread Nikhil Agarwal
On Mon, Apr 12, 2010 at 12:58 PM, Rohit Saraf rohit.kumar.sa...@gmail.comwrote: are yaar... i meant BST... i thought that was obvious ! sry if i confused you @rohit It's ok.Actually in this group people come up with very different and non-common solutions so its risky to take things

Re: [algogeeks] First k smallest elements

2010-04-12 Thread Rohit Saraf
I have already given an O(n) solution. See above ! The BST solution is O(nlogn) but is practically more nice. :) -- Rohit Saraf Second Year Undergraduate, Dept. of Computer Science and Engineering IIT Bombay http://www.cse.iitb.ac.in/~rohitfeb14

Re: [algogeeks] Re: Complexity of searching in this alternate representation of tree

2010-04-12 Thread vivek bijlwan
@Himanshu. from what i think the complexity would be log(n) but the base would be the no. of siblings that the node has. Check if this answer is correct. On Sun, Apr 11, 2010 at 2:08 PM, Himanshu Aggarwal lkml.himan...@gmail.comwrote: @Dave n Harshi, thanks for your answer. I am still not

Re: [algogeeks] First k smallest elements

2010-04-12 Thread souri datta
Steps: 1. Find the kth element using order statistics - O(n) 2. In one pass over the array, get all the elems less than the kth element. Let me know if this is not correct. On Mon, Apr 12, 2010 at 1:57 PM, Rohit Saraf rohit.kumar.sa...@gmail.comwrote: I have already given an O(n) solution.

Re: [algogeeks] First k smallest elements

2010-04-12 Thread Rohit Saraf
Find the kth element using order statistics - O(n)As far as i know , u will have to use median of medians selection algorithm for this... Rest is fine.. -- Rohit Saraf Second Year Undergraduate, Dept. of Computer Science and Engineering IIT

Re: [algogeeks] First k smallest elements

2010-04-12 Thread Nikhil Agarwal
Oh yes.Median of medians selection algo is with the best complexity O(n). anythin else? On Mon, Apr 12, 2010 at 7:51 PM, Rohit Saraf rohit.kumar.sa...@gmail.comwrote: Find the kth element using order statistics - O(n)As far as i know , u will have to use median of medians selection

Re: [algogeeks] store fractional numbers with high precision

2010-04-12 Thread Himanshu Aggarwal
On Sun, Apr 11, 2010 at 6:55 PM, GentLeBoY vikrantsing...@gmail.com wrote: how to store fractional numbers with a fractional part having 25-30 digits after decimal place, does long double has the same precision as double?. 1 more prob. format specifier for long double is %lf and same for

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

2010-04-12 Thread Dheeraj Jain
Here is code and explanation http://geeksforgeeks.org/?p=5009 On Sat, Apr 10, 2010 at 10:18 PM, Rohit Saraf rohit.kumar.sa...@gmail.comwrote: hmm... that can always be done ! -- Rohit Saraf Second Year Undergraduate, Dept. of Computer Science

Re: [algogeeks] store fractional numbers with high precision

2010-04-12 Thread Anil C R
correct me if I'm wrong but, float has a precision of around 8 digits. and double 16 digits... if you want arbitrary precision floating point numbers, try GNU BigNum library... Anil On Mon, Apr 12, 2010 at 9:54 PM, Himanshu Aggarwal lkml.himan...@gmail.comwrote: On Sun, Apr 11, 2010 at 6:55