Introduction to Data Structures in Computer Science

Introduction to Data Structures in Computer Science
Data Structures in Computer Science

Here, we introduce the concept of Data Structures.

What is a Data Structure?

A data structure is a way to store data and organize data in a computer so that it can be used efficiently.

A data structure is the most fundamental concept and building block concept in computer science.

Good knowledge of data structure is a must to design and develop efficient software systems.

We deal with data all the time, and how we organize and group our data together matters.

Let us understand it by taking some real-world examples.

English Dictionary

We are able to search the word quickly and efficiently in a language because the words in the dictionary are sorted.

What if the words in the dictionary are not sorted? It would be impractical and impossible to search for a word among millions of words.

So dictionary is sorted as a sorted list of words.

Library

Imagine there is a central library in the city and it contains more than 10,000 different books and to find a book it will be difficult for us unless it is organized based on categories.

For this use-case, we can use Stack or linked list data structure to organize the entire library by adding new books, removing them, and adding another set of shelves containing multiple books directly with another one.

City Map

The structure and the geometry of the routes are organized and guide you exactly with each way out with street signs and stops. This map data is a form go these geometries on a two-dimensional plane.

So map data need to be structured so that we have scales and directions and we are effectively able to search for a landmark and get routes from one place to another.

Facebook Application

On Facebook, we connect to a person and we get to see his connections directly. This is implemented using an Undirected Graph DS

Twitter Application

Same as above, Directed Graph DS is used in Twitter to build connections and followers.

Daily cash in and cash out a statement of a business

We also called a cash book in accounts, it makes the most sense to organize and store the data in the tabular schema. It is very easy to aggregate data and extract information if the data is organized in columns and tables.

So different real-time use-cases demand different sorts of storing or arranging data.

Computers work with all kinds of data, such as texts, images, videos, relational data, and pretty much any kind of data.

So how we store data in computers matters because computers deal with really really large data even with the computational power of machines and if we do not use the right kind of structures or the right kind of logical structures then our software systems will not be efficient.

There are different data structures available in software languages and are categorized into two types.

Linear and Non-Linear Data Structures

Linear DS

A DS is said to be linear if its elements form a sequence or a linear list.

Example: Array, LinkedList, Stacks, and Queues.

Non-Linear DS

A DS is said to be non-linear if the traversal of nodes is nonlinear in nature.

Example: Graph, Tree, Heap, etc.

Here are some of the operations that can be performed on different Data Structures

  • Insertion - insert a new item.
  • Deletion - delete an entry from collections.
  • Traversal - access etc data item exactly once so it can be processed.
  • Searching - find out the location of the data item if exists.
  • Sorting - sort in ascending/descending order.