Effective use of Algorithm and Flowchart in Software Engineering

What is Algorithm?

An algorithm is procedure consisting of a finite set of unambiguous rules (instructions) which specify a finite sequence of operations that provides the solution to a problem, or to a specific class of problems for any allowable set of input quantities (if there are inputs). In other word, an algorithm is a step-by-step procedure to solve a given problem.

Or, in simple an algorithm can also be defined as “a process that performs some sequence of operations in order to solve a given problem”. Algorithms are used for calculation, data processing, and many other fields.

In Computing, Algorithms are necessary for each and every tasks it performs, it’s because every procedures need to be done in a semantic manner, with greater efficiency.  A good algorithm is like using the right tool in the workshop. It does the job with the right amount of effort. Using the wrong algorithm or one that is not clearly defined is like trying to cut a piece of plywood with a pair of scissors: although the job may get done, you have to wonder how effective you were in completing it.

An algorithm applies on every work we do and every single decision we make, it’s our mind where everything is set on as algorithms and we don’t have to rewrite those things.

Properties of Algorithm

Finiteness: An algorithm must always terminate after a finite number of steps. It means after every step one reach closer to solution of the problem and after a finite number of steps algorithm reaches to an end point.

Definiteness: Each step of an algorithm must be precisely defined. It is done by well thought actions to be performed at each step of the algorithm. Also the actions are defined unambiguously for each activity in the algorithm.

Input: Any operation you perform need some beginning value/quantities associated with different activities in the operation. So the value/quantities are given to the algorithm before it begins.

Output: One always expects output/result (expected value/quantities) in terms of output from an algorithm. The result may be obtained at different stages of the algorithm. If some result is from the intermediate stage of the operation then it is known as intermediate result and result obtained at the end of algorithm is known as end result. The output is expected value/quantities always have a specified relation to the inputs.

Effectiveness: Algorithms to be developed/written using basic operations. Actually operations should be basic, so that even they can in principle be done exactly and in a finite amount of time by a person, by using paper and pencil only.

Properties of Algorithms, defines how algorithms are prepared, what elements would be necessary for a algorithm to be a good one. But, really what are the reasons behind preparation of algorithms, why are they necessary to be written.

Reasons behind using Algorithm

Efficiency: Certain types of problems, like sorting, occur often in computing. Efficient algorithms must be used to solve such problems considering the time and cost factor involved in each algorithm.

Abstraction: Algorithms provide a level of abstraction in solving problems because many seemingly complicated problems can be distilled into simpler ones for which well-known algorithms exist. Once we see a more complicated problem in a simpler light, we can think of the simpler problem as just an abstraction of the more complicated one. For example, imagine trying to find the shortest way to route a packet between two gateways in an internet. Once we realize that this problem is just a variation of the more general shortest path problem, we can solve it using the generalized approach.

Reusability: Algorithms are often reusable in many different situations. Since many well-known algorithms are the generalizations of more complicated ones, and since many complicated problems can be distilled into simpler ones, an efficient means of solving certain simpler problems potentially lets us solve many complicated problems.

Expressing Algorithms; in which language is algorithm written use actually?

Algorithms can be expressed in many different notations, including natural languages, pseudocode, flowcharts and programming languages. Natural language expressions of algorithms tend to be verbose and ambiguous, and are rarely used for complex or technical algorithms.

Pseudocode and flowcharts are structured ways to express algorithms that avoid many ambiguities common in natural language statements, while remaining independent of a particular implementation language. Programming languages are primarily intended for expressing algorithms in a form that can be executed by a computer, but are often used to define or document algorithms.

Consider an example for finding the largest number in an unsorted list of numbers.

Algorithm using natural language statements:

  1. Assume the first item is largest.
  2. Look at each of the remaining items in the list and if it is larger than the largest item so far, make a note of it.
  3. The last noted item is the largest item in the list when the process is complete.

Algorithm using pseudocode:

largest = L0

for each item in the list (Length(L) _ 1), do

if the item _ largest, then

largest = the item

return largest

Advantages of Using Algorithms

The use of algorithms provides a number of benefits. One of these benefits is in the development of the procedure itself, which involves identification of the processes, major decision points, and variables necessary to solve the problem. Developing an algorithm allows and even forces examination of the solution process in a rational manner. Identification of the processes and decision points reduces the task into a series of smaller steps of more manageable size. Problems that would be difficult or impossible to solve in entirety can be approached as a series of small, solvable sub-problems.

Some useful example of algorithms

Convert temperature Fahrenheit to Celsius

Inputs to the algorithm

Temperature in Fahrenheit

Expected output

Temperature in Celsius

Algorithm

Step 1: Start

Step 2: Read Temperature in Fahrenheit F

Step 3: C 5/9*(F32)

Step 4: Print Temperature in Celsius: C

Step 5: Stop

Ravi has to attend at least 70% of Practical Classes for C programming to be eligible to appear in the examination. There are total 50 Practical Classes for C programming. He has attended 20 out of 30 classes held so far. Find at least how many more classes to be attended by Ravi to be eligible for appearing in Practical Examination

Inputs to the algorithm

  1. Percentage of Attendance Required
  2. Total Number of Classes
  3. Number of Classes held so far
  4. Number of classes attended so far by Ravi

Expected output

Number of classes to be attended to become eligible for appearing in examination

Algorithm

Step 1: Start

Step 2: Read Total Number of Classes C 7

Step 3: Read Percentage Required P

Step 4: Read Classes already attended Ca

Step 5: Total Classes to be attended Ct C*P/100

Step 6: More Classes to be attended CmCtCa

Step 7: Print Cm

Step 8: Stop
About Flowchart in Nextpage

Pages: 1 2