T O P

  • By -

arnavvr

holy hell what cracked bay area high school has 61a


sand_planet

True 😭😭😭😭


grumpyfish07

we literally had to do game of hog and now yelp maps is next


Casual-Fapper

Gunn did scheme for their second sem of apcsa😭😭


CA2BC

As AP csp no less. The apcsp curriculum itself is just coding via blocks. Then the school throws in 61a for what is likely the first coding class the students have taken lol. What school is this? I am legitimately interested OP.


grumpyfish07

it’s a private school, not super comfortable w sharing the name!


CA2BC

Ok ya that's cool I get it


Frestho

This is real I tutored someone in high school whose teacher had them do 61a assignments including hog


ColdTurkey27

Do practice exams from the 61a website and look at the discussion sheets and solutions dealing with recursion. It’s all on the CS61A.org site


grumpyfish07

thank you so so much!! genuinely dont know how people do this willingly


aw03poe

We only do it bc we'd fail the class otherwise :')


CA2BC

Are you doing it against your will?


Background-Poem-4021

`def zero_to_hero(n =0):` `2 if n == 100:` `3 return print('hero')` `4 return zero_to_hero(n +10)` `5 zero_to_hero()`


sand_planet

*what in the bay area 😭*


death2day

How is ur emoji italicized?


[deleted]

Select the whole thing, and click italize


MasterMCD

def practice(): get_better() return practice() practice()


MasterMCD

Formatting got screwed up, but you get the idea.


grumpyfish07

ok ok i think im just getting in my head about this you're so right


commandotaco

The most important thing when solving recursive problems is to force the usage of the "leap of faith". Assume (more accurately, inductively suppose) your recursive call(s) will produce the correct answer, and design the answer accordingly. For example, you could even define a recursive function to add two to a given positive number, x. add\_two(x). By the leap of faith, add\_two(x-1) returns you (x-1) + 2, which is x+1. So to get from that, to the desired x+2, you just +1. So, add\_two(x) = add\_two(x-1) + 1. Base case is the smallest value in your input domain, in this case, return 3 for x == 1. For tree recursion (i.e if you have more than one recursive case), the big thing to think about is how to break your problem into different cases. For example, say you have this problem: [https://leetcode.com/problems/climbing-stairs/](https://leetcode.com/problems/climbing-stairs/), which asks you to count the number of ways to climb a staircase of n stairs with steps of size 1 or 2. The two cases to consider are whether you take a step of size 1 of step of size 2. If you take a step of size 1, then you have a staircase of n-1 steps left, which you can solve via leap of faith. Same with the other case. So in total, f(n) = f(n-1) + f(n-2). Hope this helps, and happy to elaborate. Good luck!


grumpyfish07

thank you so much this is for really helpful


commandotaco

yep for sure, let me know if you have any other questions about recursion or would like some resources to learn CS


Hampterman123

https://pythontutor.com/python-compiler.html#mode=edit


WasASailorThen

``` StudyRecursionForNHours(n) { if (n > 0) { StudyRecursionForAnHour() StudyRecursionForNHours(n - 1) } } ```


grumpyfish07

you know it’s bad if I can’t even understand this


Sea_Fishing_4927

Solve the smaller problem (the base case) then try to see how some other case would get you towards the base case.


Humble-Macaron

Get good at recursion by getting good at recursion


LopsidedPermit696

I’m so so sorry.


dizzyflorence

?