Computer totally works on the instruction given by the user. It can’t perform a single task with itself. Sometime there is need to give instruction at the time of use or sometime we need to give pre instructions for the system functioning. Everything in the computer is pre-programmed (with system point of view) and some of the programming is done by programmer later on, as per need(with application point of view). To write a computer program, you have to tell the computer, step by step, exactly what you want it to do. The computer then “executes” the program, following each step technically, to accomplish the end task.
When you are telling the computer what to do, you also get to choose how it’s going to do it. That’s where computer algorithms come in. The algorithm is the basic technique used to get the task done. Let’s follow an example to have a clear concept of ALGORITHM.
Let’s say that you have a friend arriving at the Railway station, and your friend needs to get from the station to your house. Here are four different algorithms that you might give your friend for getting to your home:
The Cab algorithm:
- Go to the cab merchant.
- Book a Cab.
- Give the Cab merchant my address.
The call-me algorithm:
- When your TRAIN arrives, call ME
- Give me a hand signal when u see
The bus algorithm:
- Outside baggage claim, catch bus number 44.
- Transfer to bus 45 on Main Street.
- Get off on Elm street.
- Walk FOUR blocks east to my house.
All four of these algorithms accomplish exactly the same goal, but each algorithm does it in completely different way. Each algorithm also has a different cost and a different travel time. Taking a cab, for example, is probably the fastest way, but also the most expensive. Taking the bus is definitely less expensive, but a whole lot slower. You choose the algorithm based on the circumstances.
In computer programming, there are often many different ways — algorithms — to accomplish any given task. Each algorithm has merits and demerits in different situations. Sorting is one place where a lot of research has been done, because computers spend a lot of time sorting lists. Here are five different algorithms that are used in sorting:
- Bin sort
- Merge sort
- Bubble sort
- Shell sort
we will discuss this topic in more detail in upcoming blog ::