background preloader

Analysis

Facebook Twitter

TopCoder, Inc. | Home of the world's largest development community. Algorithms and Data Structures. Algorithm: a process or set of rules used for calculation or problem-solving, esp. with a computer.Program: a series of coded instructions to control the operation of a computer or other machine. Example Problem: Find the greatest common divisor (GCD) of two integers, m and n.Euclid's Algorithm: while m is greater than zero: If n is greater than m, swap m and n. Subtract n from m. n is the GCD Program (in C): Correctness Why do we believe that this algorithm devised thousands of years ago, is correct? Given m>0 and n>0, let g = gcd(m,n). So the algorithm is correct, provided that it terminates. Termination At the start of each iteration of the loop, either n>m or m≥n. So the algorithm does terminate. Testing Having proved the algorithm to be correct, one might argue that there is no need to test it.

Debugging code be inserted to print the values of m and n at the end of each iteration to confirm that they behave as expected. Complexity Time If m=n, there is just one iteration; this is the best-case. Programming Contests - Codesprints - Interviewstreet. Archive of Interesting Code. The Archive of Interesting Code is an (ambitious) effort on my part to research, intuit, and code up every interesting algorithm and data structure ever invented. In doing so, I hope both to learn the mathematical techniques that power these technologies and to improve my skills as a programmer. In case you're curious what I'm someday hoping to having implemented on this page, you can check out my TODO list. If you're interested in using any of this code in your applications, feel free to do so!

You don't need to cite me or this website as a source, though I would appreciate it if you did. However, please don't plagiarize the code here by claiming authorship - that would just be dishonest. Enjoy! Data Structure Visualization. DelphiForFun Home. 演算法筆記. The Python Challenge. Design and Analysis of Computer Algorithms. Practice and Learn - Google Code Jam. On this page you can see results and code from past rounds of Google Code Jam, and you can try the problems for yourself. If you're new to Code Jam, try following the Quick-Start Guide. Where should I start? If you're new to programming contests, we highly recommend starting with the least difficult problems and moving up from there as you get more confident. Beware: the round that has the easiest problem A may have a very difficult problem B! As you get used to the platform, you can check how many people solved each problem in the "Submissions" box to the left of the dashboard, and use that as a rough gauge of difficulty.

Here are some choice problems for new competitors: Africa 2010, Qualification Round: Store Credit, Reverse Words. Remember, if you get stuck you can look at someone else's solution (click a "solutions" link below) or join our mailing list and ask for help. Finding Solutions You can click a "solutions" link below, but those aren't really indexed in a helpful way.

TopCoder. Codeforces. Jeff Erickson.