Try it on paper first. A hint, the key idea and the worked solution are here when you need them.
In a model with made-up times, a program takes s each time it is run with an interpreter. Compiling it once takes s, and then the executable file takes s for each run. The program is run times.
A compiler translates the whole code at once, before executing it, produces an executable file, and gives an error report for the whole code. An interpreter translates and executes the code line by line and stops when it finds an error. An interpreter is mostly used when developing a program; a compiler translates the final program.
Have you tried it?
Work it out on paper first. It is fine to get stuck or make a mistake: that is how we learn. When you are ready, go through the solution one step at a time, and check each step against your own.
Step 1. The interpreter. s.
Step 2. The compiler. s.
Step 3. The same total. After runs, . So and runs.
Answer: (a) s. (b) s. (c) runs.
Check. At runs: interpreter s, compiler s. The same.
What if? While the program is being written, it is changed and run a few times between changes. Each change needs a new compile, so the interpreter is often quicker then. That is why it is used during development.
Log in to join the discussion.
Loading…