A community for students.

Here's the question you clicked on:

55 members online
  • 0 replying
  • 0 viewing

anonymous

  • 5 years ago

pset 3 #1 i managed to make the iterative program, but how do i make the recursive program?

  • This Question is Closed
  1. anonymous
    • 5 years ago
    Best Response
    You've already chosen the best response.
    Medals 0

    and just to clarify: iterative involves a while loop, and recursive contains a command within a function to repeat that function again?

  2. anonymous
    • 5 years ago
    Best Response
    You've already chosen the best response.
    Medals 0

    What I did for pset 3a recursive was I used find on the first line and on the second I did return if x!=-1 and your function with the arguments target[x+1:],key and then add 1 to keep track of how many times it found it. That is not correct syntax thats just to put you on right track. The target[x+1:] is so that the next function will start at the position after the last found solution and go to the end.

  3. anonymous
    • 5 years ago
    Best Response
    You've already chosen the best response.
    Medals 0

    ok i did it, but it involves a global variable which im afraid breaks the rules of it being strictly recursive.

    1 Attachment
  4. anonymous
    • 5 years ago
    Best Response
    You've already chosen the best response.
    Medals 0

    i just don't get how you have a counter in a recursive function, because you have to set it to zero in the beginning, right? and if its recursive, it will reset itself to zero every time.

  5. anonymous
    • 5 years ago
    Best Response
    You've already chosen the best response.
    Medals 0

    Sorry wrong attachment: heres the right one

    1 Attachment
  6. anonymous
    • 5 years ago
    Best Response
    You've already chosen the best response.
    Medals 0

    never mind got it

  7. anonymous
    • 5 years ago
    Best Response
    You've already chosen the best response.
    Medals 0

    Hey can you post your final code?

  8. anonymous
    • 5 years ago
    Best Response
    You've already chosen the best response.
    Medals 0

    1 Attachment
  9. anonymous
    • 5 years ago
    Best Response
    You've already chosen the best response.
    Medals 0

    Ok cool here is what I did. Idk which is "better" but mine is shorter. http://dpaste.com/hold/529915/

  10. Not the answer you are looking for?
    Search for more explanations.

    • Attachments:

Ask your own question

Sign Up
Find more explanations on OpenStudy
Privacy Policy

Your question is ready. Sign up for free to start getting answers.

spraguer (Moderator)
5 → View Detailed Profile

is replying to Can someone tell me what button the professor is hitting...

23

  • Teamwork 19 Teammate
  • Problem Solving 19 Hero
  • You have blocked this person.
  • ✔ You're a fan Checking fan status...

Thanks for being so helpful in mathematics. If you are getting quality help, make sure you spread the word about OpenStudy.

This is the testimonial you wrote.
You haven't written a testimonial for Owlfred.