Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Week 1 - Introduction

Sponsored · SiteGround - Reliable hosting with speed, security, and support you can count on. →

Week 1 - Introduction

University of Texas at Austin CS109: Competitive Programming

Slides for week 1

Avatar for Arnav Sastry

Arnav Sastry

August 28, 2015

Other Decks in Technology

Transcript

  1. What is competitive programming? The art of efficiently analyzing and

    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
  2. Benefits of competitive programming Increases critical thinking and problem solving

    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
  3. Programming vs Competitive Programming Testing consists of limited manual tests,

    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
  4. Actual Contests Online competitions usually individual usually have access to

    internet Offline competitions usually team based no internet access, sometimes have access to pre-prepared written materials team shares one computer
  5. Tips to get you started Become proficient in one language,

    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
  6. Class structure A, B, C, D, F…. No +/- Daily

    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
  7. Course outline General areas covered: • state space search /

    graph algorithms • recursion / backtracking • binary search • greedy algorithms • dynamic programming • advanced graph algorithms • number theory • probability/combinatorics
  8. Brief syllabus https://www.cs.utexas.edu/users/downing/cs109/Grading.html 20 problems, 10 quizzes problems: 3 points

    quizzes: 4 points total: 100 points A: 90-100 B: 80-89 C: 70-79 D: 60-69 No credit: 0-60 3 unexcused absences: -10 points
  9. Runtime analysis Your max runtime can often be determined from

    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
  10. Brief look into processor architecture • processor operates on registers

    • 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
  11. Brief look into memory access times Important parts • if

    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
  12. What to remember You have ~1 second to run your

    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
  13. Big-O analysis This table is derived from those results. For

    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
  14. Resources to get started Places to practice: codeforces.com (class problems)

    codechef.com topcoder.com projecteuler.net usaco.org acm biweekly competitions
  15. Resources to get started Places to learn: CS 314, 331

    TopCoder Algorithm Tutorials are dense but insightful and useful usaco.org has a training section acm biweekly competitive programming club meetings and workshops
  16. Additionally, we have office hours every week, so if you

    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