r/learnprogramming • • Apr 05 '22

Name one programming/comp sci concept you never understood and if you understand it, try to explain it to them

Name a programming concept such as virtual functions, pointers, certain algorithms, etc that you always had a hard time understanding and why.

Someone else who reads yours and does understand it, try to explain it to them to help them learn

1.6k Upvotes

738 comments sorted by

View all comments

Show parent comments

3

u/Rote515 Apr 05 '22 edited Apr 05 '22

Modulo has to do with math in discrete finite sets rather than our traditional thinking of math done under infinite sets. So if we have a problem 2+x(where x is an integer) with no modulus then we are working with all integers both positive and negative from -infinity to infinity. If on the other hand we have the same problem mod 10, then we’re only working with numbers 0-9, a discrete set rather than the infinite set, as any equation mod 10 will always be 0<=x<10 as our function is divided by 10 at the end and the answer is the remainder after the division.

Understanding this, and discrete math in general is really helpful in programming as a lot of what we do is don’t over finite sets.

1

u/Patrickstarho Apr 05 '22

Interesting. It’s kinda like linked lists vs arrays because arrays always have a fixed length while linked lists are dynamic right?

2

u/Rote515 Apr 05 '22

A linked list is actually still a discrete set as it still has a size when we work on it. Also as a annoying note careful with array terminology as JavaScript arrays for example don’t have a fixed size, and behave like lists(this bugged the shit out of me when I first started learning). Are you going to school for programming or self-taught? If school take a discrete math course if you can, if self-taught there’s a number of youtube tutorials on discrete math that are worth at least taking a look at(as well as numberless books). I can give a better example later if you want one(working at the moment)

1

u/Patrickstarho Apr 05 '22

I’m going self taught route and I purchased a discrete math course on Udemy.

What books do you recommend btw?