Skip to content
Programmingoneonone
Programmingoneonone
  • Engineering Subjects
    • Internet of Things (IoT)
    • Digital Communication
    • Human Values
  • Programming Tutorials
    • C Programming
    • Data structures and Algorithms
    • 100+ Java Programs
    • 100+ C Programs
    • 100+ C++ Programs
  • Solutions
    • HackerRank
      • Algorithms Solutions
      • C solutions
      • C++ solutions
      • Java solutions
      • Python solutions
      • Data Structures Solutions
    • Leetcode Solutions
    • HackerEarth Solutions
  • Work with US
Programmingoneonone
Programmingoneonone

What is an Algorithm and a Data Structure?

YASH PAL, 15 April 20204 May 2026

Data structures and algorithms – As programmers, we always work on programs with millions of lines of code. And to develop a program, we need two important things –

  1. Represent data in an efficient way
  2. Develop a step-by-step process

To represent the data in an efficient way, we only need a data structure. And to develop a step-by-step process, we need an algorithm.

What is a data structure?

The data structure is nothing but a data representation method to represent data in a form. There are many data structures available right now, like arrays, linked lists, trees, heaps, stacks, queues, etc. Each data structure has its own way of implementation and its own characteristics. And we need to choose an efficient data structure to represent our data in the program. Because it makes a huge difference to choose the right data structure for our program.

How to choose the right data structure?

To choose the right data structure for our program, we need to learn about different data structures and their characteristics. Because it only comes with practice, and without the practice of data structure, we don’t predict which data structure perfectly represents our data. Especially, the characteristics of a specific data structure show where they are used and when we choose a specific data structure to work on.

Let’s understand with an example

If we can say we are working on a program, in that we are working with linear data. So, which data structure do we need to choose? So we definitely choose arrays or single linked lists because the array can represent linear data efficiently, and it’s also true for a single linked list.

But if we select the wrong data type, then it badly affects our code. And maybe it affects the complexity of our code. A programmer always works to reduce the complexity of code. And that’s why we are called programmers. So I think now you understand why we need to learn about data structures to develop the program.

How to develop a step-by-step procedure – To develop a step-by-step procedure for any problem, we need an algorithm. An algorithm is nothing but a step-by-step procedure that contains well-defined steps for performing a task.

To develop an algorithm, first we need to choose a data structure. Because after choosing a data structure, we work on that data structure to perform a specific task. like sorting data, searching for data, etc. Similarly, it’s true for the data structure. We use an algorithm for various operations on the data structure. Let’s take a brief introduction to the algorithm.

What is the algorithm?

As we know, an algorithm is nothing but a step-by-step procedure to solve any particular problem. 

Let’s take an example to understand what the algorithm is.

Let’s say you need a cup of tea, and by chance, you know how to make tea. So, how would you make tea? So the process that you follow to make a cup of tea is nothing but an algorithm to make tea. Similarly, in programming, to develop a program that can perform a specific task, we need an algorithm.

Let’s say you want to make a program in which you enter 10 input values, and in the output, you want to print all 10 values in ascending order. So, how would you do that? To perform that specific task, we need a step-by-step process that can take  10 different values as input and print these 10 values in ascending order.

What is an algorithm
What is an algorithm

But the problem is that to solve a particular problem, we have thousands of solutions. And for every solution, we have a specific algorithm. Among these algorithms, which one will we select? To select an algorithm, we need to consider a thing that is complexity. The algorithm that has the minimum complexity to solve a particular problem will be selected.

What is complexity?

The complexity of an algorithm is nothing but the running time that an algorithm needs to run and the space that an algorithm needs to store in memory.

Complexity has two types

  1. Time complexity
  2. Space complexity

Time complexity – The time complexity of an algorithm is nothing but the time that an algorithm needs to run to solve a particular task.

Let’s say we apply an algorithm to print 10 different numbers in ascending order. And that algorithm takes 0.33 seconds to run and print the output. So 0.33 seconds is the time complexity of that algorithm.

Space complexity – The space complexity of an algorithm is nothing but the memory space an algorithm needs to store the defined variables and values in memory.

Let’s take the above example to print 10 different numbers in ascending order. And that algorithm needs to take 30 bytes of memory space to store defined variables and values in memory. So 30 bytes is the space complexity of that algorithm.

How to select an algorithm – We always need to select an algorithm that has minimum time complexity and space complexity to perform a specific task.


Data Structures & Algorithms Tutorials for Beginners
Data Structures Tutorials Data Structures & Algorithms

Post navigation

Previous post
Next post

Programmingoneonone

We at Programmingoneonone, also known as Programming101 is a learning hub of programming and other related stuff. We provide free learning tutorials/articles related to programming and other technical stuff to people who are eager to learn about it.

Pages

  • About US
  • Contact US
  • Privacy Policy

Practice

  • Java
  • C++
  • C

Follow US

  • YouTube
  • LinkedIn
  • Facebook
  • Pinterest
  • Instagram
©2026 Programmingoneonone | WordPress Theme by SuperbThemes