Data Structures & Algorithms

Akshay Kadam
4 min readNov 26, 2022

--

Data Structures & Algorithms

1. What are Data Structures?

Assume a developer is working on project, which has tons of data from social networking site (Facebook, LinkedIn, Twitter etc.) which developer has to analyse. The first step he/she might do is classifying those data as per images, videos or audio. Further, this data can be again classified into sub categories. Like images can be classified based on image types (jpeg, png, gif etc.)

During this scenario, what developer is doing is he/she is structuring this data into different categories by which he/she can work on specific set of data (say JPEG) in a certain way.

In short, developer is structuring this data such that, it could be easily accessible. Similarly, Data Structures is a way of structuring / classifying data as per users requirement.

If a user wants to store contact number (which consists of all numbers) he might use a specific data type like integer, to save this data.

Likewise, if user wants to store customer name, address (which usually contains string characters) he/she might use a different data type like string / character, by which end-user can perform many operation relevant to string data type.

2. Types of Data Structures

There are different types of data structures across various programming languages. But each of these programming language has a certain set of data types present by default.

Integers

Character / String

Boolean

Apart from the above listed data types, there can be also advanced data types which have evolved targetting to many use cases like arrays, dictionary, sets etc.

These data types have been evolved to cater to specific use case.

3. What are Algorithms?

Algorithm can be simplified as a certain set of steps / protocols that a user follows to achieve an objective.

Ex. When I get up in the morning (on a weekday), first thing that I do is clearing out my morning chores. After this, I travel to my office using commute, then work. After this, I travel back to my home using commute and then I spend a quality time with my family / friends.

In the above example, we are following a certain set of protocols / steps to complete our tasks on a weekday. Likewise, for a weekend, my protocols / steps will be different, wherein I invest my time towards my personal growth.

Unknowingly, I have developed an algorithm for myself to complete my task.

Similarly, we do have various algorithms in computer science domain. Simplest of them being used for sorting, finding maximum number etc.

These algorithms / steps should be clear / precise. Further, there are few conditions that should be met to make sure that an Algorithm is fit:

Able to provide accurate and precise output

Although we say that, there are certain types of rules that defines as an algorithm, we should be also make sure if that algorith (set of rules) is actually providing me with required output with accuracy and precision. If we do not meet required accuracy, it makes no sense to use that algorithm

Able to execute with optimised resource in required time

If using a certain algorithm gives accurate and precise result, should it be accepted? A Big YES.

But what if, using that algorithm, user is getting result at huge cost of time & resources? Should it be accepted? A Big NO.

We need to make sure that our algorithm (even though providing accurate results time and again) is it actually worthy of the time / resources which would be invested. Its like there is an algorithm which performs subtraction and it takes more than an hour to give results. This surely is not an algorithm that anyone would prefer. So here, we need to improve that algorithm to make sure that we get desired accurate results with optimal usage of resources and minimum possible time.

Why Data Structures & Algorithms an important concept?

Scenario 1

Assume, there is a guy called Sheldon who wants to go on a trip to Europe and he has 10,000$ in his bank account. The first thing Sheldon will do is plan the trip, draw out expenses for travelling, food expenses etc. After this, Sheldon will see if there is a way that this expense can be further minimised (by not giving up on trip comfort) by looking onto different tours and travels. Thereby, Sheldon made sure that his trip expense is withing his reach and also made sure to optimise those expense.

Scenario 2

A developer has huge data which he needs to process on a computer. He would have to process that data carefully making sure that, his computer will handle this data efficiently and will not crash as his computer is just a Corei5 (8GB RAM / 512 GB SSD)

Comparison

So, if we compare those 2 scenarios:

The amount that Sheldon has in his account is comparable to the PC configuration that a developer has. These resources are limited and user needs to optimise (expense / algorithm) such that their task would be completed in that alloted resources.

Also, Sheldon optimising his plan to reduce expense can be comparable to the developer who is optimising his algorithm so that required task is achieved with minimal resources

Similarly, in this era of data where you have tons of data around the world, companies are trying to optimise this data in every possible optimised way. For this, developers rely on concepts of data structures and algorithms.

This is the main reason why companies prefer a talented developer who has strong foothold in the concepts of data structures and algorithms.

--

--