A simple explanation of algorithms and data structures from a guy who is learning about them.
Why blog about algorithms and data structures?
I don’t know a whole lot about algorithms. In fact I don’t know a whole lot about data structures either. I have been doing some reading on the internet, trying to learn some more about these two foundational topics in computer science. Then I had an idea.
Although I have not been blogging for very long, I have found that blogging is an excellent way for me to solidify concepts in my mind. In order for me to be able to write about a subject, I first have to understand a subject. So, if I want to learn more about algorithms and data structures, then maybe I should start blogging about it!
So for the foreseeable future I am going to exclusively blog about algorithms and data structures. This post will provide a simple explanation on algorithms and data structures. Then my posts will focus on specific algorithms and data structures and I will do my best to explain them. Sounds like a good time to me!
What is an algorithm?
An algorithm is a set of instructions that are followed, step by step, to achieve some sort of desired output. Technically recipes are algorithms, and DIY instructions you found on the internet are technically algorithms too.
In the world of computing, algorithms are able to provide computers with instructions that tell the computer what exactly it should do to complete a task.
How do algorithms work?
The best way to think about algorithms is in terms of input and output. Most modern computers are capable of receiving lots of different possible inputs. For many of these potential inputs, the computer will have particular algorithms that it can use to transform the input into an output.
At a basic level, a search engine can be considered an algorithm. It takes a search query as an input and then searches a database for data that is relevant to the query. The results of the search are then outputted to the user.
What is a data structure?
Data structures are what a computer uses to store and retrieve data. Data structures can be designed in different ways. These designs are constructed based on considerations like the data type and how the data will be accessed. There are four different forms of data structures:
- Linear
- Tree
- Hash
- Graphs
Depending on the circumstances it may make sense for a computer to use one data structure over another. It all depends on the use case. Similarly the type of data structure that is being used will ultimately decide what algorithm is used.
Well there you go! If you didn’t know about algorithms and data structures then I hope that you do now. Future posts will go into much more detail, rest assured. Looking forward to sharing what I know about algorithms and data structures in the posts to come!