Quick Code
Published in

Quick Code

Let’s Answer #1

Let’s answer: What is a data structure?

Together let’s demystify Data structures

Photo by Blake Connally on Unsplash

What is a data structure?

In simple words

Data structures are the ways in which you can store data inside your runtime memory for efficient usage of data.

For example: Let's say you are given a list of 10 numbers and you are asked to arrange the list of 10 numbers in ascending order. The input in the format of one number each line. Below mentioned are some of the approaches.

Approach 1:
Store each number in a different integer and manually compare the values.
This will be done in constant time complexity, if you are able to write the code because there are 3628800 or 10 factorial if conditions to be coded. This is not practically possible.
Approach 2:
Store the list of numbers in an array.
This will estalish a link between all the numbers and we will be able to rearrange the numbers in ascending order. The worst time complexity could be O(n^2)and can be optimized to O(nlog n). There are various algorithm for sorting the numbers. Some of them are Bubble Sort, Seletion Sort, Merge Sort, quick Sort and many more. This is one of the most popular ways of solving the problem.
Approach 3:
Storing the elements in a Binary Search Tree.
Another less popular way of sorting numbers is to store the integers in a binary search tree and traverse the tree in a pre-order manner. The worst time complexity is O(n^2).

Why data structures are important?

Data structures are important because it increases the

  • Efficiency: Using proper data structures will enable the programmers to write code that consumes less time and less space, thus is memory friendly.
  • Reusability: Using standard data structures enable the developers to create libraries specific for Data Structures and thus enable the programmers to abstract the basic operations which are performed over various Data structures.

Basic operations on data structures

There are 6 basic operations that can be performed on any data structure. They are:

  • Search: Finding an element inside the data structure.
  • Sort: Rearranging all the elements in an ascending or descending order.
  • Traverse: Printing all the elements in a particular manner.
  • Insertion: Inserting an element in a data structure at any Position.
  • Deletion: Deleting any element from the data structure.
  • Update: Updating any element from the data structure.

Types of Data Structures

Broadly there are two types of data structures:

  • Linear data structures
  • Non-Linear data structures

Linear data structures

Those data structures that store the data in a linear manner i.e one after another or simply in one dimensional way are called Linear data structures.

They are again of two types:

  • Static: Data structures whose size cannot be changed once declared. Example: Array.
  • Dynamic: Data structures whose size can change even after the declaration. Example: Linked List.

Non-Linear data structures

Those data structures that store the data in a multi-dimensional way are called Non-linear data structures.

They are again of 2 types:

  • Graphs
  • Hash Tables
A diagram to explain the types of Data Structures. Picture from: GeeksForGeeks.com

Each data structure mentioned in the article again has various subtypes.

Each data structure will be covered in-depth in a different article along with practice problems and common algorithms.

Stay tuned for more such articles and if you want articles on a particular topic, do drop me a mail.

--

--

--

Find the best tutorials and courses for the web, mobile, chatbot, AR/VR development, database management, data science, web design and cryptocurrency. Practice in JavaScript, Java, Python, R, Android, Swift, Objective-C, React, Node Js, Ember, C++, SQL & more.

Recommended from Medium

AnyChart Joins Qlik Technology Program and Adds 36 Charts Types in Just-Launched Extensions

Data Stories for U.S. Election 2020

Devising A Predictive Maintenance Model For The Study Of Turbofan Engines- A Dive Into Machine…

Quality Control Fastq File

4 Forgotten Excel Tricks For PPC

WHAT

Week 1 @ Metis Singapore Data Science Bootcamp — Project 1: Exploratory Data Analysis (EDA) on the…

The Sweet Spot of Plotly

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Aman Agarwal

Aman Agarwal

Exploring

More from Medium

21. Merge Two Sorted Lists — LeetCode(Python)

Dynamic Programming On Grids

[LeetCode] (Easy)168. Excel Sheet Column Title

Breadth-first search