Today I’m answering questions that a lot of new people to Computer Science or maybe people who aren’t real familiar with Computer Science might be having the question today is what is an algorithm.
Now I’m getting that question a lot more frequently because a lot of news surrounding and using the term algorithm and a lot of cases people are not using correctly in the news. So what is an algorithm – well an algorithm is very simply a series of steps that we’re going to take in order to solve a problem.
That’s all an algorithm is.
An algorithm can be very very simple or quite complex depending upon what it’s trying to do. Let’s take for example the Pythagorean theorem and create an algorithm to solve that. That theorem is used to determine the length of a long side of a right triangle. Assuming you know the lengths of the two other side if I was to build an algorithm for it it would be quite simple. I take my first small side and I would square it I take my second small side and I’d square it add those two numbers together take the square root of that number, and that is my answer.
It’s a series just a couple of quick steps in order to solve that problem.
Where things get a lot more complicated is when I’m solving more and more complicated questions like should select applicant A or applicant B. I may use a computer tool to sort through all the information about these two individual applicants and determine which one should be admitted to grad school, or maybe which one should be given a job opportunity with a company. Now it has to look at a lot more pieces of information and has to make some intelligent guesses based upon that algorithm and it’s going to use weighting scores and different things like that.
That algorithm may be pages and pages long to explain what it does and even longer in computer code.
Now sometimes there’s more than one way to solve a given problem let’s say I had some set of data maybe a list of names I want to put them in order well I have more than one way to sort this data now which one I pick will depend on several factors.
Some are easy to code and they’re really easy to understand and that’d be like the bubble sort. But, it’s also really inefficient and it will take a long time in order to go through and sort that set of data. If I only have 10 elements it’s not that big a deal and maybe I use the bubble sort because it’s really fast to write and if I know I only have 10 elements the amount of time I’m gonna save is going to be very very small. But if I have a hundred million elements, now I have a lot of data and a bubble sort would be horrible so I’ll spend more time more complexity in writing the algorithm and the code and come up with something like a quick sort and that’s going to be much much faster for me and so the speed of writing the use of the computer programmer’s time versus the speed of writing and the use of computer time will depend upon which one I’ll pick sometimes my algorithms will use a lot of extra memory to be a little bit more efficient at runtime or maybe I’ll use less memory but take more time in programming because I’m at my memory limits but I have lots of processing power all these things really matter when we’re trying to pick which algorithm to use in a given circumstance.
So if you’re wondering what an algorithm is just remember it’s a series of steps to solve a problem how we solve it will depend upon a lot of outside factors. And that’s what we have to be good at.
What is an Algorithm was originally found on Access 2 Learn