Re: [algogeeks] Re: Algorithm page

2012-02-14 Thread rahul
@Wladimir, Nice articles. Thanks. Best Regards, Rahul. On Tue, Feb 14, 2012 at 5:05 AM, Wladimir Tavares wrote: > > Hi Guys, > > I transfer some text for this blog. > http://marathoncode.blogspot.com > > Some good posts: > http://marathoncode.blogspot.com/2012/01/rand8-usando-rand5.html > http:

Re: [algogeeks] Digest for algogeeks@googlegroups.com - 13 Messages in 5 Topics

2012-02-14 Thread Sudhakar Kalmari
algogeeks@googlegroups.com wrote: >= >Today's Topic Summary >= > >Group: algogeeks@googlegroups.com >Url: http://groups.google.com/group/algogee

Re: [algogeeks] spoj

2012-02-14 Thread Dheeraj Sharma
i thnk for 1 2 3 4 5 6 & 1 2 3 4 5 6 7 ..o/p is 4.. it can be done by circular doubly linked list On Mon, Feb 13, 2012 at 10:45 PM, atul anand wrote: > what will the output of following input: > 1) 1 2 3 4 5 6 > 2) 1 2 3 4 5 6 7 > > i am bit confused.because in the given link for input 2 ...o

[algogeeks] Re: [Combinatorics] count possible number of binary search trees, given number of nodes

2012-02-14 Thread WgpShashank
HI , consider that each value could be the root. Recursively find the size of the left and right subtrees. thats it . lets try for n=2 e.g. 1,2 there ways to select the root wither 1 or 2 , if u choose one , size of left subtree will be 0 & size of right subtree will be 1 so , similarly i

Re: [algogeeks] spoj

2012-02-14 Thread atul anand
@ Dheeraj : yes it can be done using circular linked list..but i have some doubt related to output... i dont think so it would be 4 for both input. On Tue, Feb 14, 2012 at 6:42 PM, Dheeraj Sharma wrote: > i thnk for 1 2 3 4 5 6 & 1 2 3 4 5 6 7 ..o/p is 4.. > it can be done by circular doubly lin

Re: [algogeeks] spoj

2012-02-14 Thread vickywiz
in 1 2 3 4 5 6...o/p "ll b 5 -- You received this message because you are subscribed to the Google Groups "Algorithm Geeks" group. To view this discussion on the web visit https://groups.google.com/d/msg/algogeeks/-/eWlM2oyysowJ. To post to this group, send email to algogeeks@googlegroups.com.

Re: [algogeeks] Re: how can we check for primality for very large number

2012-02-14 Thread Akshat Sapra
Go to link Primality Testing there are some algorithms that are discussed here. These algorithms test the primality on the basis of probability -- Akshat Sapra Under Graduation(B.Tech) IIIT-Allahabad(Amethi Campus

[algogeeks] Re: how can we check for primality for very large number

2012-02-14 Thread Don
Also, if you want to build this into a program, you can get the NTL library. It includes a ZZ class which implements an extended precision integer type. It has a ProbPrime method which does a probabilistic test for primeness. It can handle numbers with thousands of digits. http://www.shoup.net/ntl

[algogeeks] Re: count possible number of binary search trees, given number of nodes

2012-02-14 Thread Don
For a binary search tree the solution is called the Catalan Numbers. The formula is (2n)!/(n!(n+1)!) The first few terms are: 1, 1, 2, 5, 14, 42, 132, 429, 1430, 4862, 16796, 58786, 208012, 742900, 2674440, 9694845, 35357670, 129644790, 477638700, 1767263190, 6564120420, 24466267020, 91482563640,

[algogeeks] Array Problem

2012-02-14 Thread TUSHAR
Given an array of size N having numbers in the range 0 to k where k<=N, preprocess the array inplace and in linear time in such a way that after preprocessing you should be able to return count of the input element in O(1). Please give some idea !! Thanks.. -- You received this message b

Re: [algogeeks] Array Problem

2012-02-14 Thread Kartik Sachan
if n is less than 10^6 hasing works fine ..and we count in O(1) time only -- You received this message because you are subscribed to the Google Groups "Algorithm Geeks" group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from this group, send email to algogeek

Re: [algogeeks] Array Problem

2012-02-14 Thread atul anand
@kartik : question says inplace . so using hashing would be violation... i dont think so it can be done if array is unsorted and with given restriction On Wed, Feb 15, 2012 at 10:05 AM, Kartik Sachan wrote: > if n is less than 10^6 hasing works fine ..and we count in O(1) time only > > -- >

Re: [algogeeks] Array Problem

2012-02-14 Thread Kartik Sachan
@atul if array is not sorted we have to take extra array for this...otherwise this cannn't be done in O(n) time. -- You received this message because you are subscribed to the Google Groups "Algorithm Geeks" group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe f

Re: [algogeeks] Array Problem

2012-02-14 Thread atul anand
yeah...only if given array is sorted ..we can do it in O(n) and O(1) fetch with all given restriction On Wed, Feb 15, 2012 at 10:14 AM, Kartik Sachan wrote: > @atul if array is not sorted we have to take extra array for > this...otherwise this cannn't be done in O(n) time. > > -- > You received

[algogeeks] Re: Array Problem

2012-02-14 Thread TUSHAR
That means,,,we have to sort the array first in O(n). Is there any way to sort the array inplace in O(n) ? -- You received this message because you are subscribed to the Google Groups "Algorithm Geeks" group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from th

[algogeeks] TRIE problem

2012-02-14 Thread shady
will TRIE be the best solution for this problem ? Link -- You received this message because you are subscribed to the Google Groups "Algorithm Geeks" group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from this group, send e

[algogeeks] Re: Array Problem

2012-02-14 Thread Pranav
Array 'A' contains N elements st A[i] <=k N then k=A[i] mod N go to A[k] and write A[k] = A[k] + N So, lets take a sample array of size 5: 1,2,1,0,4 i=0: k=A[i]=1; A[i] <5; A[1] = A[1] + 5 => A[1] = 7 => A = 1,7,1,0,4 i=1: k=A[i]=7; A[i] > 5; k=A[i] mod N => k=2 => A[2] = A[2] + 5 => A=1,7,6,

Re: [algogeeks] Re: Array Problem

2012-02-14 Thread amrit harry
@tushar lower bound for sorting an array is nlogn. http://www.bowdoin.edu/~ltoma/teaching/cs231/fall11/Lectures/6-moresorting/sortLB.pdf On Wed, Feb 15, 2012 at 11:16 AM, TUSHAR wrote: > That means,,,we have to sort the array first in O(n). > Is there any way to sort the array inplace in O(n) ?

Re: [algogeeks] Re: Array Problem

2012-02-14 Thread atul anand
@amit : it is valid for comparison based model.. On Wed, Feb 15, 2012 at 12:05 PM, amrit harry wrote: > @tushar > lower bound for sorting an array is nlogn. > > http://www.bowdoin.edu/~ltoma/teaching/cs231/fall11/Lectures/6-moresorting/sortLB.pdf > > > On Wed, Feb 15, 2012 at 11:16 AM, TUSHAR

Re: [algogeeks] Re: Array Problem

2012-02-14 Thread atul anand
@pranav : i will check for other test cases , if it work fine for all..then its cool one :) :) On Wed, Feb 15, 2012 at 12:41 PM, atul anand wrote: > @amit : it is valid for comparison based model.. > > > On Wed, Feb 15, 2012 at 12:05 PM, amrit harry wrote: > >> @tushar >> lower bound for sor