ICSCT - Analyzing Algorithms for Efficiency Lesson

Analyzing Algorithms for Efficiency

We've discussed that there is more than one way to solve a problem. Some solutions are more efficient than others, and as programs get more and more complicated the number of steps that a program has to take can affect the time it takes to run the program. Not every problem requires the most efficient solution. But, as the data size for the algorithm increases so does the complexity. The bigger the input size the more time and space needed to run an algorithm.  

Software engineers study algorithms analytically and empirically. When you study the algorithm analytically you analyze the components of the algorithm, its suitability for particular applications and compare the run-time to other algorithms. As you test the algorithm you study it empirically to observe the behavior and results given various input sizes. Algorithm efficiency is crucial to applications such as games, finance, and robotics.    

In Scratch, optimization is important for larger projects. 3D projects, for example, run at a poor frame rate typically in Scratch because Scratch is not efficient enough or optimized for 3D.  Furthermore, in Scratch, most of the rendering is done by the processor, which makes it even more CPU-intense.

One common problem in Scratch that makes projects run slower is the use of multiple scripts that are very similar. Take the following, for example:    

Rather than using two scripts, it would be more efficient to combine them into one:

[CC BY 4.0] UNLESS OTHERWISE NOTED | IMAGES: LICENSED AND USED ACCORDING TO TERMS OF SUBSCRIPTION