Algorithm Concept in VB.NET

A computational method is a method for solving a specific type of problem by means of a nite set of steps operating on inputs.
  • 3969

ALGORITHM

A computational method is a method for solving a specific type of problem by means of a nite set of steps operating on inputs, which are quantities given to it before execution of the steps begins or during executing, and producing one or more outputs, which have a specified relation to the inputs, its play an important role in mathematics: Ancient mathematical literature contains descriptions of algorithms for a variety of tasks.

In the modern internet world, man feels that just by entering what he wants to search into the computers he can get information as desired by him. He believes that, this is done by computer. A common man seldom understands that a man made procedure called search has done the entire job and the only support provided by the computer is the execution speed and organized storage of information.

CHARACTERISTICS OF AN ALGORITHM

Let us try to present the scenario of a man brushing his own shoes as an algorithm as follows:

Step 1. Take the brush
Step 2. Apply the polish
Step 3. Start brushing
Step 4. Stop

The definiteness and effectiveness of an instruction implies the successful termination of that instruction. However the above two may not be sufficient to guarantee the termination of the algorithm. Therefore, while designing an algorithm care should be taken to provide a proper termination for algorithm. Thus, every algorithm should have the following five characteristic feature.

  • Input

  • Output

  • Definiteness

  • Effectiveness

  • Termination

Therefore, an algorithm can be defined as a sequence of definite and effective instructions, which terminates with the production of correct output from the given input.

HOW TO DEVISE THE ALGORITHMS

The process of devising an algorithm is both an art and a science. This is one part that cannot be automated fully. Given a problem description, one have to think of converting this into a series of steps, which, when executed in a given sequence solve the problem. To do this, one has to be familiar with the problem domain and also the computer domains. This aspect may never be taught fully and most often, given a problem description, how a person proceeds to covert it into an algorithm becomes a matter of his "style" - no firm rules become applicable here.

For the purpose of clarity in understanding, let us consider the following example.

Problem: Finding the largest value among n>=1 numbers.

Input: the value of n and n numbers

Output: the largest value

Steps :

  1. Let the value of the first be the largest value denoted by BIG

  2. Let R denote the number of remaining numbers. R=n-1

  3. If R != 0 then it is implied that the list is still not exhausted. Therefore look the next number called NEW.

  4. Now R becomes R-1

  5. If NEW is greater than BIG then replace BIG by the value of NEW

  6. Repeat steps 3 to 5 until R becomes zero.

  7. Print BIG

  8. Stop

End of algorithm

HOW TO VALIDATE THE ALGORITHMS

Once an algorithm has been devised, it becomes necessary to show that it works. i.e it computes the correct answer to all possible, legal inputs. One simple way is to code it into a program. However, converting the algorithms into programs is a time consuming process. Hence, it is essential to be reasonably sure about the effectiveness of the algorithm before it is coded. This process, at the algorithm level, is called "validation". Several mathematical and other empirical methods of validation are available. Providing the validation of an algorithm is a fairly complex process and most often a complete theoretical validation, though desirable, may not be provided. Alternately, algorithm segments, which have been proved else where may be used and the overall working algorithm may be empirically validated for several test cases. Such methods, although suffice in most cases, may often lead to the presence of unidentified bugs or side effects later on.

HOW TO TEST THE ALGORITHMS

If there are more then one possible way of solving a problem, then one may think of more than one algorithm for the same problem. Hence, it is necessary to know in what domains these algorithms are applicable. Data domain is an important aspect to be known in the field of algorithms. Once we have more than one algorithm for a given problem, how do we choose the best among them? The solution is to devise some data sets and determine a performance profile for each of the algorithms. A best case data set can be obtained by having all distinct data in the set.

A control constructs present in the given below algorithms, A conditional statement has the following form :

                If < condition> then
                    Block 1
                Else
                    Block 2
                If end.

This pseudo code executes block1 if the condition is true otherwise block2 is executed.

2. The two types of loop structures are counter based and conditional based and they are as follows

                For variable = value1 to value2 do
                    Block
                For end

Here the block is executed for all the values of the variable from value 1 to value 2.

There are two types of conditional looping, while type and repeat type.

                While (condition) do
                    Block
                While end.

Here block gets executed as long as the condition is true.

                Repeat
                    Block
                Until<condition>

Here block is executed as long as condition is false. It may be observed that the block is executed at least once in repeat type.

Summary

In this article the concepts of algorithm are presented and the properties of the algorithm are also given.

Categories

More Articles

© 2020 DotNetHeaven. All rights reserved.