Programming C, C++, Java, PHP, Ruby, Turing, VB
Computer Science Canada 
Programming C, C++, Java, PHP, Ruby, Turing, VB  

Username:   Password: 
 RegisterRegister   
 recursion
Index -> Programming, Turing -> Turing Help
View previous topic Printable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic
Author Message
nelson




PostPosted: Sun Feb 01, 2004 10:27 pm   Post subject: recursion

i'm trying to solve this problem

" Write a function using Recursion to display all anagrams of the word 'RECURSION' "

having trouble, i started though

code:


var str : string
str := "recursion"
var b : array 1 .. length (str) of int
var a : array 1 .. length (str) of string (1)

for i : 1 .. length (str)
    b (i) := 0
    a (i) := ""
end for


var temp : string
temp := str



proc er (n : int)


    for i : 1 .. length (str)

        a (n) := str (i)



        if n < length (str) then
            er (n + 1)
        else
            for k : 1 .. length (str)
                put a (k) ..
            end for
            put ""
        end if
    end for
end er


put length (str)
er (1)


heh -.,-;;;;;;;; help~
Sponsor
Sponsor
Sponsor
sponsor
Paul




PostPosted: Sun Feb 01, 2004 10:33 pm   Post subject: (No subject)

Isn't an anagram words made by rearranging the letters of the same word? correct me if Im wrong, Im not sure.
nelson




PostPosted: Sun Feb 01, 2004 10:37 pm   Post subject: (No subject)

yup
Paul




PostPosted: Sun Feb 01, 2004 10:39 pm   Post subject: (No subject)

Oh! At first I thought you wanted all the "real" words anagram, but you just want all possible combinations right? I think I'll work on that for a bit.
jonos




PostPosted: Sun Feb 01, 2004 10:39 pm   Post subject: (No subject)

i think what you have is right, cause it does print out the whatchamacallits, but i've never used recursion (haven't been taught it in stupid compsci), so i wouldn't really know if you were doing it right.
nelson




PostPosted: Sun Feb 01, 2004 10:40 pm   Post subject: (No subject)

haha if we wanted to do real words,
we would need a dictionary!
Paul




PostPosted: Sun Feb 01, 2004 10:41 pm   Post subject: (No subject)

when I run it, theres alot of words with 4 "R"'s and there arn't 4 of them in Recursion.
nelson




PostPosted: Sun Feb 01, 2004 10:41 pm   Post subject: (No subject)

but the program can only use two r

R ecu R sion

my program starts with 9 Rs
Sponsor
Sponsor
Sponsor
sponsor
Paul




PostPosted: Sun Feb 01, 2004 10:47 pm   Post subject: (No subject)

I see, well I'm sorry, but I can't help you right now, I have to go to bed, but I'll think on it whenver I have the chance. I dunno though, if it was me making it, I'd count the numbers of each letters, might be a stupid idea, Im too tired to think Confused
jonos




PostPosted: Sun Feb 01, 2004 10:50 pm   Post subject: (No subject)

i didn't even notice that (the 4 rs), id help if i could cause i have lots of time, but i have no idea what recursion is.
Paul




PostPosted: Sun Feb 01, 2004 10:51 pm   Post subject: (No subject)

It isn't recursion I think, hes trying to get anagrams (words that are made of the same letters) from the word "recursion"
nelson




PostPosted: Sun Feb 01, 2004 10:53 pm   Post subject: (No subject)

but it's supposed to be recursion problem
so probably we hve to use recursion
jonos




PostPosted: Sun Feb 01, 2004 10:58 pm   Post subject: (No subject)

could anyone explain to me what recursion is, then maybe i could have a go at it... thankyou Laughing
santabruzer




PostPosted: Sun Feb 01, 2004 11:00 pm   Post subject: (No subject)

enjoy:
Quote:
A function that calls a simpler version of itself to arrive at a solution. For example, the factorial function (n!) can be defined recursively as (n(n-1)!), where (0!) is defined as equal to1. If a function calls another function that calls back the original function again, it is called mutual recursion; most ray-tracing programs fall into this general category.
jonos




PostPosted: Sun Feb 01, 2004 11:17 pm   Post subject: (No subject)

uh, thanks for that definition, could yo uplease translate it into laymans terms Very Happy thanks for the definition, i think i have an idea of what it is
Display posts from previous:   
   Index -> Programming, Turing -> Turing Help
View previous topic Tell A FriendPrintable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic

Page 1 of 1  [ 15 Posts ]
Jump to:   


Style:  
Search: