Documents

week1_programming_challenges.pdf

Description
Description:
Categories
Published
of 31
All materials on our website are shared by users. If you have any questions about copyright issues, please report us to resolve them. We are always happy to assist you.
Share
Transcript
  Algorithmic Toolbox at Coursera:Programming Challenges (Week 1) March 20, 2019 Contents 1 Sum of Two Digits 3 1.1 Implementing an Algorithm . . . . . . . . . . . . . . . . . . 41.2 Submitting to the Grading System at Coursera . . . . . . . . 6 2 Maximum Pairwise Product 9 2.1 Naive Algorithm . . . . . . . . . . . . . . . . . . . . . . . . . 102.2 Fast Algorithm . . . . . . . . . . . . . . . . . . . . . . . . . . 142.3 Testing and Debugging . . . . . . . . . . . . . . . . . . . . . 142.4 Can You Tell Me What Error Have I Made? . . . . . . . . . . 162.5 Stress Testing . . . . . . . . . . . . . . . . . . . . . . . . . . . 172.6 Even Faster Algorithm . . . . . . . . . . . . . . . . . . . . . 212.7 A More Compact Algorithm . . . . . . . . . . . . . . . . . . 22 3 Solving a Programming Challenge in Five Easy Steps 22 3.1 Reading Problem Statement . . . . . . . . . . . . . . . . . . 223.2 Designing an Algorithm . . . . . . . . . . . . . . . . . . . . 233.3 Implementing an Algorithm . . . . . . . . . . . . . . . . . . 233.4 Testing and Debugging . . . . . . . . . . . . . . . . . . . . . 243.5 Submitting to the Grading System . . . . . . . . . . . . . . . 25  4 Appendix 25 4.1 Compiler Flags . . . . . . . . . . . . . . . . . . . . . . . . . . 254.2 Frequently Asked Questions . . . . . . . . . . . . . . . . . . 272  To introduce you to our automated grading system, we will discusstwo simple programming challenges and walk you through a step-by-stepprocess of solving them. We will encounter several common pitfalls andwill show you how to fix them.Below is a brief overview of what it takes to solve a programming chal-lenge in five steps: Reading problem statement.  The problem statement specifies the input-output format, the constraints for the input data as well as time andmemory limits. Your goal is to implement a fast program that solvesthe problem and works within the time and memory limits. Designing an algorithm.  When the problem statement is clear, start de-signinganalgorithmanddon’tforgettoprovethatitworkscorrectly. Implementing an algorithm.  After you developed an algorithm, startimplementing it in a programming language of your choice. Testing and debugging your program.  Testing is the art of revealingbugs. Debugging is the art of exterminating the bugs. When yourprogram is ready, start testing it! If a bug is found, fix it and testagain. Submitting your program to the grading system.  After testing and de-bugging your program, submit it to the grading system and wait forthe message “Good job!”. In the case you see a di ff  erent message,return back to the previous stage.3  1 Sum of Two Digits Sum of Two Digits Problem Compute the sum of two single digit numbers. Input:  Two single digit numbers. Output:  The sum of these num-bers. 2+3 = 5 We start from this ridiculously simple problem to show you thepipeline of reading the problem statement, designing an algorithm, im-plementing it, testing and debugging your program, and submitting it tothe grading system. Input format.  Integers  a  and  b  on the same line (separated by a space). Output format.  The sum of   a  and  b . Constraints.  0  ≤ a,b  ≤  9. Sample. Input: 9 7 Output: 16 Time limits (sec.): C C++ Java Python C# Haskell JavaScript Kotlin Ruby Rust Scala 1 1 1.5 5 1.5 2 5 1.5 5 1 3 Memory limit.  512 Mb.4
We Need Your Support
Thank you for visiting our website and your interest in our free products and services. We are nonprofit website to share and download documents. To the running of this website, we need your help to support us.

Thanks to everyone for your continued support.

No, Thanks
SAVE OUR EARTH

We need your sign to support Project to invent "SMART AND CONTROLLABLE REFLECTIVE BALLOONS" to cover the Sun and Save Our Earth.

More details...

Sign Now!

We are very appreciated for your Prompt Action!

x