Complexity of algorithms with fundamental control structures
In this section, we will learn about a crucial concept known as control structures. By the end of this chapter, you should have basic knowledge of control structures, their types, how they work, and their computational complexity.
Control structures are used to specify the direction of flow in programs. They are used to analyze and choose the direction in which the program flows, based on some parameters or conditions. In short, control structures are just the decision making that the computer makes. There are three basic types of fundamental control structures:
- Sequential flow
- Selection flow
- Repetitive flow
Let's understand each of these in turn.
Sequential flow
In this kind of flow, the algorithm flow depends on the series of instructions given to the computer, and the steps are executed in an obvious sequence. The sequence might be given by means of numbered steps explicitly...