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/TangerineX Apr 05 '22

You can think of computers like marbles flowing through a large marble contraption. At the end of the contraption, there are several buckets. If your marble can flow through the contraption and land in some of the specific buckets, then we consider the program to return "true" and if not, the program returns "false".

Now instead of a bucket, what if it just leads to the start of another marble contraption. This is the basis of how functions work, we feed the results of functions into each other.

Now consider the case where we don't know exactly which functions we should use, or what data we should use to get our results. Imagine a scenario where the only thing we can do is try a huge number of combinations. In our marble example, we have a ton of input locations, and we have to find the right one to drop it.

So quantum computing is fast because what it allows us to do is simulate dropping the marble into all (or at least a lot) of the start location at once. Sure, a lot of them will fail, but we're only interested in the ones that succeed.

This is very very simplified explanation of how quantum computing as a whole, and I'm sure you can read more into it

2

u/Putnam3145 Apr 06 '22

simplified to the point of being wrong, since this sorta implies that it allows you to do NP-complete problems in polynomial time with quantum computers, which you can't (unless P = NP)