solving problems More concretely, producing an efficient piece of code that gives the correct output to a given problem or input in a short time period
ability Improves knowledge of algorithms, how to optimize code Makes you much better and faster at turning your thoughts and abstract ideas into concrete solutions Great practice for technical interviews Can win honor, glory, and cool prizes at competitions
you almost never write code to do unit tests Very large data sets that impose constraints on the algorithms you can use Don’t have to integrate with libraries, or code from other developers Code not meant to be maintainable, but does have to readable/easily debuggable
and know its libraries and I/O functions most common languages are Java and C++ try out different online judges to find your favorite codeforces, codechef, projecteuler, hackerrank get out there and code in competitive programming, you learn by doing
quizzes Daily lecture on some topic in competitive programming Practice problems due the next week that use the covered topic, and may build on previous topics
your input size consider a 2 GHz processor can run ~2 billion cycles, or simple operations (adds, shifts, xors, etc...) per second but programs also have to read from memory
• if variable is not in a register, or is part of an array, it must be loaded into a register from memory • when the processor reads from memory, it first looks in the cache • if the value is not in the cache, it reads it from memory, and then stores it in the cache
processor is 2 GHz, it does 2 operations every nanosecond, or one every .5 nanoseconds • L1 cache is 1 cycle • L2 cache is 14 cycles • if not cached, 200 cycles • reading array with ~1 million things takes ¼ of a millisecond • reading a 1 MB input file, or at least 100,000 integers, takes 20 ms
program a non-trivial amount of that can be just reading your input in from disk to memory if you have a big dataset, cache locality can make or break your runtime the Big-O of your algorithm is hugely important
example, if N=10,000, we can estimate that it takes 50000 cycles, and doing that 10000 times is 500 million cycles, or ¼ of a second on a 2 GHz processor. complexity maximum N (N) 100 000 000 (N log N) 40 000 000 (N^2) 10 000 (N^3) 500 (N^4) 90 (2^N) 20 (N!) 11
TopCoder Algorithm Tutorials are dense but insightful and useful usaco.org has a training section acm biweekly competitive programming club meetings and workshops
have any questions, want to talk about competitive programming, or especially if you need help getting started or are stuck on a problem, then definitely come talk to us. Arnav:3:30-4:30 Wednesday, GDC 3rd floor lab Jaime:3:30-4:30 Thursday, GDC 3rd floor lab