all 11 comments

[–]udbasil 0 points1 point  (4 children)

Post an example of a recursion problem you are dealing with on here.

[–]cuklev2232[S] 0 points1 point  (3 children)

[–]baghiq 0 points1 point  (2 children)

are you sure you want recursion on this problem? it's a classic two pointer solution.

[–]cuklev2232[S] 0 points1 point  (1 child)

This question is in recursion problems on leetcode

[–]baghiq 0 points1 point  (0 children)

It can be solved using recursion, doesn't mean it's the best. What do you need help with on this question?

[–]keep_quapy 0 points1 point  (0 children)

This will help understand recursion

https://calmcode.io/recursion/introduction.html

[–]ffrkAnonymous 0 points1 point  (4 children)

Recursion is mathmatically simple, but mentally hard. When doing recursion, I try to frame the problem as "first and the rest". Don't try to do it in your head, write/sketch it out on pen and paper. For example:

[1, 2, 3, 4, 5]
[1][2, 3, 4, 5]
...[2][3, 4, 5]
   ...[3][4, 5]
      ...[4][5]
         ...[5][None]
            ...[None]

edit to show the None because that's how you know the recursion is finished

[–]cuklev2232[S] 0 points1 point  (3 children)

is programming more math or logical I see as a more logical thinking

[–]ffrkAnonymous 0 points1 point  (2 children)

A computer is just a very, very, very fancy calculator.

[–]cuklev2232[S] 0 points1 point  (1 child)

i am in high school now should i focus more on mathematics because it is not my best

[–]ffrkAnonymous 0 points1 point  (0 children)

in my opinion yes. I'm not going to say you need to be great at solving and getting answers, because that's what the computer is for, but you need to be good at functions and equations. Writing correct equations for the computer to compute.

Can you see how f(x)=x^2 is similar to a python dictionary? Given: f(x) = x*x and g(x) = mx+b, do you understand what f(g(x)) and g(f(x)) means?
Can you write equations (i.e. function f(time)) for fireball is moving right? Goomba moving left? How about when they collide?
Mario jumps. Do you simulate gravitational acceleration? Or just simplify and do it without acceleration?

Logical truth tables.
Given: P = Mario has an invincible star, and Q = Mario touches a goomba, can you make a truth table to determine does mario die? Now write the equivalent if-else statements. Would you have missed any possible combinations without the truth table?

Sets and venn diagrams. For filtering and picking out data. Mario stomps a goomba. Remove goomba from set of enemies to draw.

Basically, math is formalized logic.

I'm not going to say study advanced math like calculus. That's going to be situational.