What do you understand by Algorithm for any program? Discuss different types of control structures for classification of Algorithm.
CS Professional · Information Technology and Systems Audit · PYQS · June 2018
What do you understand by Algorithm for any program? Discuss different types of control structures for classification of Algorithm.
Answer & Explanation:
Algorithm To make a computer do anything, one need to write a computer program. To write a computer program, one have to tell the computer, step by step, exactly what he want it to do. The computer then "executes" the program, following each step mechanically, to accomplish the end goal. An algorithm is a step to step procedure to solve a given problem. It is a sequence of instructions (or set of instructions) to make a program more readable; a process to answer a question. The number of steps of an algorithm will be countable and finite. In short an algorithm can be defined as: "A sequence of activities to be processed for getting desired output from a given input." Most computer programmers spend a large percentage of their time creating algorithms. The goal is to create efficient algorithms that do not waste more computer resources (such as RAM and CPU time) than necessary. Poorly written algorithms can cause programs to run slowly and even crash. Type of Algorithm There are three types of control structure for the classification of Algorithm: Sequence Branching (Selection) Loop (Repetition) These three control structures are sufficient for all purposes. The sequence is exemplified by sequence of statements place one after the other – the one above or before another gets executed first. The branch refers to a binary decision based on some condition. If the condition is true, one of the two branches is explored; if the condition is false, the other alternative is taken. The loop allows a statement or a sequence of statements to be repeatedly executed based on some loop condition. It is represented by the 'while' and 'for' constructs in most programming languages, for unbounded loops and bounded loops respectively. The loop is also known as the repetition structure.
Topics: Programming Concepts
Related Questions in this Topic
- Write short notes on the following: Flow Chart
- A housing society having 400 members pay the electricity bill at the following rates: No. of Units consumed Charges...
- Define Algorithm. Briefly explain the various control structures used in Algorithm.
- A company has appointed marketing professionals at a monthly salary of ₹50,000. At the time of their annual appraisal al...
- Write short notes on the following: Advantages of using Flow Charts