Fundamentals of Algorithms and Flowcharts PDF 2020

Summary

This document introduces algorithms and flowcharts, essential concepts in computer science. It explains fundamental concepts, provides examples, and discusses the advantages and differences between algorithms and flowcharts.

Full Transcript

Fundamentals of Algorithms and Flowcharts 2020 ALGORITHM AND FLOW CHART Department of Computer Science Page 1 Fundamentals of Algorithms and Flowcharts 2020 PROBLEM SOLVING: Can you think of a day in you...

Fundamentals of Algorithms and Flowcharts 2020 ALGORITHM AND FLOW CHART Department of Computer Science Page 1 Fundamentals of Algorithms and Flowcharts 2020 PROBLEM SOLVING: Can you think of a day in your life which goes without problem solving? Answer to this question is of course, No. In our life we are bound to solve problems. In our day to day activity such as purchasing something from a general store and making payments, depositing fee in school, or withdrawing money from bank account. All these activities involve some kind of problem solving. It can be said that whatever activity a human being or machine do for achieving a specified objective comes under problem solving. To make it clearer, let us see some other examples. Example1: If you are watching a news channel on your TV and you want to change it to a sports channel, you need to do something i.e. move to that channel by pressing that channel number on your remote. This is a kind of problem solving. Example 2: One Monday morning, a student is ready to go to school but yet he/she has not picked up those books and copies which are required as per timetable. So here picking up books and copies as per timetable is a kind of problem solving. Example 3: If someone asks to you, what is time now? So seeing time in your watch and telling him is also a kind of problem solving. Example 4: Some students in a class plan to go on picnic and decide to share the expenses among them. So calculating total expenses and the amount an individual have to give for picnic is also a kind of problem solving. A typical programming task can be divided into two phases: Problem solving phase  produce an ordered sequence of steps that describe solution of problem  this sequence of steps is called an algorithm Implementation phase  implement the program in some programming language Fundamentals of Algorithms Algorithm can be defined as: “A sequence of activities to be processed for getting desired output from a given input.” Department of Computer Science Page 2 Fundamentals of Algorithms and Flowcharts 2020 Webopedia defines an algorithm as: “A formula or set of steps for solving a particular problem. To be an algorithm, a set of rules must be unambiguous and have a clear stopping point”. There may be more than one way to solve a problem, so there may be more than one algorithm for a problem. Now, if we take definition of algorithm as: “A sequence of activities to be processed for getting desired output from a given input.” Then we can say that: 1. Getting specified output is essential after algorithm is executed. 2. One will get output only if algorithm stops after finite time. 3. Activities in an algorithm to be clearly defined in other words for it to be unambiguous. Before writing an algorithm for a problem, one should find out what is/are the inputs to the algorithm and what is/are expected output after running the algorithm. Rules for making Algorithms: 1) Each algorithm will be logically enclosed by two statements: “START” and “STOP”. 2) To accept data from user, the INPUT or READ statements are to be used. 3) To display any user message or the content in a variable, PRINT statement will be used. The message will be enclosed in quotes. (“”). While writing algorithms we will use following symbol for different operations: Relational Operators: „>‟ for Greater than „=‟ for Greater than equal to Department of Computer Science Page 3 Fundamentals of Algorithms and Flowcharts 2020 „

Use Quizgecko on...
Browser
Browser