r/learnprogramming • u/Temporary-Warthog250 • 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
2
u/Sasquatch_actual Apr 06 '22
I can't stand using books for stuff like this.
The most simple way to learn time complexity stuff is to code up some simple demonstrations.
The trick to this is using ridiculously large datasets.
If your dataset has 10 numbers in it, anything you do is going to complete nearly instantly after you click run.
Make an array with 500 million integers in it.
Try some constant time operations. They happen instantly.
Try some linear time operations. Search for 50k random integers between 0 and 500 million. That's going to take a while (minutes) to complete. Print out a timestamp before and after that process, see how long it takes.
Do the same thing again. But this time use binary search in logarithmic time. It'll blow your mind how fast it is. A few seconds maybe.
Play with each time complexity with large enough numbers to make a difference. Some may never finish,
Look at your data structures, and their different complexity for different operations. Think how loading half a billion items would be fast or slow.
Any operations that's making you iterate over that entire length of half a billion you'll feel it, when you try it.