Anyone who has written even a few lines of computer code comes to realize that programming largely revolves around data. Computer programs are all about receiving, manipulating, and returning data. Whether it’s a simple program that calculates the sum of two numbers, or enterprise software that runs entire companies, the software runs on data. Most of the time I seem to notice that beginners in programming ask the question; "Is it necessary to learn Data structure & Algorithms?". Well, today I'll be showing you why the study of Data structure & Algorithms is important on your journey as a Programmer.
Table of Contents
Programming Is About Data
Data is a broad term that refers to all types of information, down to the most basic numbers and strings. In the simple but classic “Hello World!” program, the string "Hello World!" is a piece of data. In fact, even the most complex pieces of data usually break down into a bunch of numbers and strings.
Data structure refers to a way of organizing and collecting data to perform data operations effectively. This ensures the organization of data in such a way that its performance is enhanced and complexity is minimized.
Algorithms are Like Preparing a Bowl of Cereals
Although the word algorithm sounds like something complex, it really isn’t. An algorithm is simply a particular process for solving a problem. For example, the process for preparing a bowl of cereal can be called an algorithm. The cerealpreparation algorithm follows these four steps (for me, at least):
- Grab a bowl
- Pour cereal into the bowl
- Pour milk into the bowl
- Dip a spoon into the bowl.
When applied to computing, an algorithm refers to a process for going about a particular operation(in our case making the bowl of cereals). It's possible to go about an operation in more than one way, that is to say, there are multiple algorithms that can achieve a particular operation, back to our cereal bowl making another person's process would be:
- Grab a bowl
- Pour cereal into the bowl
- Add water to the cereal
- Pour milk into the bowl
- Add sugar to the bowl
- Dip a spoon in the bowl
Having said that there are different ways/processes of achieving particular operations, we must also consider the implications of such ways/processes (in programming, the type of algorithm chosen would determine whether our codes run fast or slow, or even crash)in the case of the cereal step 2 makes the cereal sweeter than it normally would. An understanding of algorithm helps you to weigh the pros and cons of using such algorithms on a particular set of operations
NOTE: if you were to take a traditional college course on algorithms, you’d probably be introduced to Big O from a mathematical perspective. Big O is originally a concept from mathematics, and therefore it’s often described in mathematical terms. For example, one way of describing Big O is that it describes the upper bound of the growth rate of a function, or that if a function g(x) grows no faster than a function f(x), then g is said to be a member of O(f). Depending on your mathematics background, that either makes sense or doesn’t help very much.
Importance Of Learning Data Structures & Algorithms
- To find the best solution: In software development, there are an infinite number of ways to solve a particular problem. Often the inefficient solutions appear to be more tempting in the beginning. But late you may end up with a less scalable and slow-working solution. To save from ending up in a mess, Data structures and Algorithms let you create software efficiently which performs well in all worst cases.
- Write Clear and Optimized Code: Optimized code refers to hardware-friendly code that effectively uses memory and CPU. A source code that uses incorrect data structure becomes complex in long run. Consider this example, a developer uses a stack if the array is the most suitable data structure. The solution will become complicated and unable to handle the data in the long run. On the other hand, optimized code will create a highly scalable solution.
- Get Placed in Top Tech Giants: Knowledge of Data structures and algorithms plays a major role in the hiring process of FAANG companies. People often wonder why these tech giants emphasize the knowledge of DSA. It is because of the following reasons:
They need professionals who can choose the right algorithms to save the company's resources like servers, computation power, and money. Knowledge of how one data structure is different from another will help the developers to make the right choice of data structure to solve a problem that is the requirement of each tech giant. This concludes that DSA plays a major role to help you stand apart from the crowd and get hired by top tech giants.
EndNote
Data structures and algorithms are much more than abstract concepts. Mastering them enables you to write more efficient code that runs faster, which is particularly important for today’s web and mobile apps. If you last saw an algorithm in a university course or at a job interview, you’re missing out on the raw power algorithms can provide.
The problem with most resources on these subjects is that they’re...well...obtuse.Most texts go heavy on the math jargon, and if you’re not a mathematician, it’s really difficult to grasp what on Earth is going on. Even books that claim to make algorithms “easy” assume that the reader has an advanced math degree. Because of this, too many people shy away from these concepts, feeling that they’re simply not “smart” enough to understand them.
The truth, however, is that everything about data structures and algorithms boils down to common sense. Mathematical notation itself is simply a particular language, and everything in math can also be explained with common-sense terminology.
Once you understand these concepts, you will be equipped to write code that is efficient, fast, and elegant. You will be able to weigh the pros and cons of various code alternatives and be able to make educated decisions as to which code is best for the given situation.
