Algorithms and Data Structures

Algorithms and Data Structures are two important and core concepts frequently used in programming. Hence, It is very important to have a good understanding of every general purpose algorithms and data structures in use today.

This chapter will introduce you to what they are and help you build the base for the future.


Programming is about making a computer to do what you want it to do.

In order to do that, as a programmer you will be writing a computer program to get that job done. You will provide the computer with step by step instructions to reach that goal. The computer then executes the instructions in the same manner that you provided it. That basic
technique of getting the job done can be summarized as an algorithm.

In general terms,

An algorithm is a sequence of clearly defined instructions for solving a problem.

Lets understand the term in a more simpler way…

Imagine that you are in your friends house, 30 minutes walk from home. Now, you want to reach home before your parents do, who will be back from work in about 25 minutes. There are possibly 3 best ways that you can choose from:
Friends bike algorithm
  1. Ask your friend to give you a ride
  2. Get in the bike
  3. Reach home in about 4 minutes
  4. Promise to buy him a beer next time
Grab a taxi algorithm
  1. Get to the taxi stand
  2. Find a taxi
  3. Get in the taxi
  4. Reach home in about 7 minutes
  5. Pay the taxi guy
The bus algorithm
  1. Go to the bus stand
  2. Wait for the bus
  3. Get in the bus
  4. Get off near your street in about 14 minutes
  5. Walk 2 minutes to reach home

Even though there were multiple options to choose from, the best one was to choose your friends bike. If we take a look back to the options you had, we will notice a few things :

  • Each had a finite number of steps
  • All three had the same goal (to take you home)
  • Each had its own cost
  • Each had its own travel time

Algorithms in programming world are similar to these 3 options. In case of programming, there might be even more options.

In the programming world, Algorithm would look something like this.

Problem : Design an algorithm to multiply two numbers and display the result.

Solution :

    Step 1 : START
    Step 2 : Declare three integers a,b & c
    Step 3 : Define values of a & b
    Step 4 : Multiple values of a & b
    Step 5 : Store the output of step 4 to c
    Step 6 : Print the result c
    Step 7 : STOP

Some of the most common algorithm categories in terms of data structure are –

  • Search – to search for items in a data structure
  • Sorting – to sort a list of items in a certain order
  • Insertion – to insert an item in a data structure
  • Update – to update an existing item in a data structure
  • Delete – to delete an existing item from a data structure

Data Structures

Data Structure is a way of storing and organizing data in a specialized format for a specific purpose such that it can later be accessed and worked with.

Some of the common operations performed in a data structure are insertion, deletion, sorting, searching, traversing etc.

Generally, accessing, maintaining and manipulating data stored in a data structure is done my using various algorithms. That is one of the reasons why Algorithm and Data Structures are so closely related.

All programming languages make use of data structures to store data. Some of the most common ones are array, stack, queue, list and dictionary.

Choosing a data structure to store data largely depends on the amount of data that needs to be stored and the frequency of the operation that needs to be performed on it.

Friendly Advise

You must have a deep understanding of different kinds of algorithms and data structures in use today if you wish to become a good programmer. Because most of the time, you will be dealing with all kinds of data from text files, API`s and databases.

There are tons of resources and tutorials online to teach you all about these two concepts. You don`t need to master them all at once, but at least be familiar with how they work and where they are generally used.

Lets move on to next topic and get familiar with the paradigms and concepts that defines various programming languages.

You may also like...

Leave a Reply

Your email address will not be published.