[algogeeks] Re: program

2012-07-26 Thread Dave
@Ahmad: This is known as a Collatz Sequence. It is hypothesized that the sequence will eventually reach 1 for every starting number N. So here is an algorithm to find where they meet, using O(1) space: 1. Generate each sequence and count the number of iterations required to reach 1. You need n

[algogeeks] Re: program puzzle

2011-08-15 Thread Gene
The normal meaning of "in place" is only constant additional storage. You're using much more than that. On Aug 15, 12:52 pm, Don wrote: > #include > #include > > int main(int argc, char* argv[]) > { >         char line[500]; >         char tmp[500]; >         char *words[100]; >         int wor

Re: [algogeeks] Re: program puzzle

2011-08-15 Thread Pervinder Singh
First reverse the whole sentence and then reverse every word of the sentence Example : "I am a programmer" Step 1 Reverse entire sentence "remmargorp a ma I" Step 2 Now reverse every word in a sentence programmer a am I Complexity O(n) On Mon, Aug 15, 2011 at 10:22 PM, Don wrote: > #includ

[algogeeks] Re: program puzzle

2011-08-15 Thread Don
#include #include int main(int argc, char* argv[]) { char line[500]; char tmp[500]; char *words[100]; int wordCount = 0; char *p, *wordStart=0; printf("Enter string:"); fgets(line,500,stdin); for(p = line; *p; ++p) {

[algogeeks] Re: program to find max and min element in an array using recursion...

2011-08-01 Thread Amethy hobby
#include "stdafx.h" #include using namespace std; typedef pair node;// first is max. second is min typedef int m_iterator; node maxmin(int *a,m_iterator start,m_iterator end) { if(start==end-1){ //only hava one elements return make_pair(a[start],a[start]); }

[algogeeks] Re: program for evaluation of remainders

2010-12-11 Thread Dave
-Original Message- > From: algogeeks@googlegroups.com [mailto:algoge...@googlegroups.com] On > > Behalf Of Dave > Sent: Friday, December 10, 2010 8:10 PM > To: Algorithm Geeks > Subject: [algogeeks] Re: program for evaluation of remainders > > @Ankit: Why not just use th

RE: [algogeeks] Re: program for evaluation of remainders

2010-12-11 Thread Shiv Shankar
, 2010 8:10 PM To: Algorithm Geeks Subject: [algogeeks] Re: program for evaluation of remainders @Ankit: Why not just use the algorithm I proposed in http://groups.google.com/group/algogeeks/msg/2941ab071a39517c: x = 0; for( i = (n < N ? n : N) ; i > 0 ; --i ) x = (i * x + i) % n; Dave

[algogeeks] Re: program for evaluation of remainders

2010-12-10 Thread haxxpop
@Dave Because he wants to optimize it if we can get the boundary of running time, we'll get the faster algorithm haxxpop -- 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 uns

[algogeeks] Re: program for evaluation of remainders

2010-12-10 Thread Dave
@Ankit: Why not just use the algorithm I proposed in http://groups.google.com/group/algogeeks/msg/2941ab071a39517c: x = 0; for( i = (n < N ? n : N) ; i > 0 ; --i ) x = (i * x + i) % n; Dave On Dec 10, 4:23 am, ankit sablok wrote: > @Dave > we will use residues then i think the property of m

[algogeeks] Re: program for evaluation of remainders

2010-12-10 Thread ankit sablok
@Dave we will use residues then i think the property of modulus 1!mod997 + 2!mod997 + 3!mod997 .. + 997!mod997 i just proposed the solution using congruences for the case n wrote: > @Ankit: So how does that work with, e.g., N = n = 997? I.e., what is > the calculation? > > Dave > > On Dec 8,

Re: [algogeeks] Re: program for evaluation of remainders

2010-12-09 Thread haxxpop
@jai gupta why is this work?? I think it just calculates (N+1)! %n haxxpop -- 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 algog

[algogeeks] Re: program for evaluation of remainders

2010-12-09 Thread haxxpop
@Dave I like this. use mem just O(1) , my algo use O(N). Thxx haxxpop -- 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+u

[algogeeks] Re: program for evaluation of remainders

2010-12-09 Thread haxxpop
997 is a prime number, so the calculation must be (1!+2!+...+996!) mod 997 -- 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 algogee

[algogeeks] Re: program for evaluation of remainders

2010-12-08 Thread Dave
@Ankit: So how does that work with, e.g., N = n = 997? I.e., what is the calculation? Dave On Dec 8, 11:33 am, ankit sablok wrote: > @ all the authors thanx for the suggestions actually wt i know about > the problem is i think we can solve the problem mathematically if we > know about congruence

[algogeeks] Re: program for evaluation of remainders

2010-12-08 Thread ankit sablok
@ all the authors thanx for the suggestions actually wt i know about the problem is i think we can solve the problem mathematically if we know about congruences for instance if N=100 1! + 2! + . + 100! and n=12 we find that 4!mod24=0 hence the above equation reduces to the (1!+2!+3!)mod

[algogeeks] Re: program for evaluation of remainders

2010-12-08 Thread Dave
Using this idea makes my solution into x = 0; for( i = (n < N ? n : N) ; i > 0 ; --i ) x = (i * x + i) % n; Dave On Dec 8, 7:27 am, Ashim Kapoor wrote: > Let me try. Any thing involving n would leave no remainder. > > so (1  + 2 ! + ... + n ! + + N !) mod n = (1 + 2 ! + ... + (n-1)! )

Re: [algogeeks] Re: program for evaluation of remainders

2010-12-08 Thread jai gupta
rem=1; for(j=3;j<=N+1;j++) rem=(rem*j)%n; return rem; -- 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+unsubscr...@googl

[algogeeks] Re: program for evaluation of remainders

2010-12-08 Thread Dave
@Ankit: Try this: x = 0; for( i = N ; i > 0 ; --i ) x = (i * x + i) % n; Dave On Dec 8, 7:19 am, ankit sablok wrote: > Q) can anyboy find me the solution to this problem > > Given an integer N and an another integer n we have to write a program > to find the remainder of the following probl

[algogeeks] Re: Program This!

2006-03-28 Thread BiGYaN
Hey Admin, Please ban this fellow. He's just using the group for his own well being and spamming the group !! --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Algorithm Geeks" group. To post to this group, send emai