Posts

Showing posts with the label algorithm

Algorithm

me ami belong to computer stream , often hear my teachers talking about taking important lectures(that i somehow n accidentally happen to skip) on algorithms , so here i am filling up on those missed lectures ;) so getting back to the  TOPIC what's an algorithm ??? Lets say an algorithm is  any well-defined computational procedure that takes some value, or set of values, as input and produces some value, or set of values, as output. so its just like those maths sums that we've been solving all our lives,  those are just fool-proof steps that run around in a loop while the computer does the calculations..... for example:- say a linear search .... basically its the most basic and the simplest of all.... just to  summarize :- we go through the values one-at-a-time in a linear way (be it ascending or descending-but mostly ascending) say example we need to find number 6  from a given set of numbers(let the numbers be in an array) [8,1,4...

Rules for writing an algorithm

Qualities of a good algorithm Inputs and outputs should be defined precisely. Each steps in algorithm should be clear and unambiguous. Algorithm should be most effective among many different ways to solve a problem. An algorithm shouldn't have computer code. Instead, the algorithm should be written in such a way that, it can be used in similar programming languages. Write an algorithm to add two numbers entered by user. Step 1 : Start Step 2 : Declare variables num1 , num2 and sum . Step 3 : Read values num1 and num2 . Step 4 : Add num1 and num2 and assign the result to sum . sum ← num1 + num2 Step 5 : Display sum Step 6 : Stop