Skip to main content

Command Palette

Search for a command to run...

A Brief Overview of Data Structures.

Get a quick glimpse of commonly used data structures ranging from Arrays to Trees & Graphs.

Published
7 min read
A Brief Overview of Data Structures.

Data Structures and Algorithms are closely related to improving the thinking process of a student who is a Computer Science enthusiast. The way of thinking is modified right from the simple basics, all the way up to more complex possibilities. This makes Data Structures and Algorithms pose as one of the most essential core subjects that shape a student into a true Computer Scientist.

In this article, we will be discussing in brief about various important data structures and their applications.

1. Array:

An array is a collection of similar elements, each of which is addressed by a given index number. These indices mostly start from 0(zero) in a multitude of programming languages and go up to (n – 1), where ‘n’ is the number of elements in the array.

Image Reference: (GeeksForGeeks)

Application:

  • Serves as a backbone for the implementation of other data structures.

  • The leaderboard of a game can be organized easily by using arrays to store the scores and sort them in ascending order to determine the position of each participant.

  • Matrices, which are implemented using 2D arrays, are used in image processing.

2. String:

Strings are often defined as an array of characters. Here, the characters are the similar elements which are organized in a contiguous collection. Languages like C strictly consider strings as an array of characters and all of the array operations can be performed on the strings. However, another set of programming languages treats it as a different object, distinguishing between 'Strings' and 'Character Arrays'. For such programming languages, strings are immutable.

Image Reference: (GeeksForGeeks)

Applications:

  • Strings can be used as a spam detection system. The idea of string matching is used by all spam filters to locate and eliminate spam.

  • Systems for detecting intrusions can make use of strings. String matching methods are used to find packets that contain intrusion-related phrases.

  • Strings can be utilized in numerous search engine methods. The vast majority of information on the internet is presented as textual data. Web search engines sort this information, and string-matching algorithms are employed to categorize the data.

3. Linked List:

A linked list, unlike an array, does not store data in contiguous memory. Each Node of a singly Linked List consists of a data and address space. Where the information is stored in the data space while the address space saves the address of the next node in the Linked List. All of the nodes starting from the Head node to the End or Tail node are thus linked in such a manner. The major advantage of using a Linked List over an array is the dynamic allocation of memory. There are various other types of Linked Lists such as doubly, circular and circular doubly linked lists.

Image Reference: (GeeksForGeeks)

Application:

  • Linked Lists help in connecting the sequence of images in an image viewer, previous and next web page URLs in a session and songs in a playlist.

  • The contact details are saved in alphabetical order on mobile phones by making use of a Linked List's functionalities.

  • When documents are modified, the changes are saved as nodes of doubly Linked Lists. This further establishes the logic for the working of undo and redo options.

4. Stack:

A Stack is a linear data structure and it can be easily implemented with the help of Arrays. The functioning is such that elements inserted early are the last to leave while the recently entered elements can leave first. This is termed LIFO(Last in First Out) or FILO(First In Last Out) nature. The element that has entered the most recently is known as the 'Top' of the stack. The two common operations of the Stack that involve the insertion and removal of elements are 'Push' and 'Pop' respectively. The Stack is one of the easily understood data structures due to a variety of real-life examples present in everyday life.

Image Reference: (GeeksForGeeks)

Application:

  • Real-life applications of Stack are not necessarily software-based, a few simple ones can be the stack of books, files, and CDs/DVDs.

  • Similar to Linked Lists, Stacks also support the undo and redo operations in text editors.

  • Web Browser histories, Call logs, E-mails, and Google photos in any gallery are also stored in the form of a stack.

  • Allocation of memory by an operating system while executing a process.

5. Queue:

A Queue is a linear data structure that is open from both ends, unlike a stack that has only one opening. These two ends are known as front and rear ends. Elements can be inserted into the queue from the rear end while the same elements can be removed from the front end. The Queue data structure thus follows the principle of FIFO(First In First Out), which means that the elements can be removed from the queue in the same order that they were entered. The operation for insertion in a queue is known as 'Enqueue' while the one for removal is called 'Dequeue'. Different types of queues are circular, input/output restricted, double-ended and priority queues.

Image Reference: (GeeksForGeeks)

Application:

  • Real-life queue applications that are not software-based include ATM Booth Line and Ticket Counter Line.

  • Queues are also used by computer systems to keep track of and maintain keystrokes made by the keyboard.

  • CPU Task Scheduling done by the operating systems also involves the use of queues.

6. Tree:

The Tree is a non-linear data structure that is used to store and retrieve data efficiently. It consists of nodes organized and linked to each other hierarchically. These nodes are assigned levels based on their position in the hierarchy. The tree originates from a Root Node and then goes on to increase its depth of levels as per requirement. The nodes originating from other nodes are called Child nodes while the ones from which they originate are known as Parent nodes. Each Parent node can have multiple number of Children nodes. The nodes at the last level (having no children) are called Leaf nodes. The connecting branches between the nodes are known as Edges. Trees are generally implemented using recursion. The various types of trees include Generic, Binary, Ternary, Binary Search, Ternary Search, AVL, Red Black, B and B+ Trees.

Image Reference: (GeeksForGeeks)

Application:

  • Trees are used for the organization of files and navigation amidst those files in various file systems.

  • Database Indexing involves the use of B-Tree and other similar tree structures to make searching for data easy and efficient.

  • In compiler design, a syntax tree is used to represent the structure of a program.

  • Data Compression and Encoding are generally made possible with the help of the tree data structure. Huffman Encoding uses Binary Trees to compress data and minimize the storage requirement.

7. Graph:

Graphs are non-linear data structures that have many elements similar to the Tree data structure. The nodes in a Graph are referred to as Vertices and these Vertices are linked to each other with the help of Edges. The differentiating feature for Graphs is that it can contain Cycles. In Graphs, there is not necessarily a hierarchy as a node can be connected to any other node irrespective of its level. Thus, Graphs represent a network connection of nodes. These can either be directed (Edges have directions from node to node) or undirected (no direction assigned).

Image Reference: (GeeksForGeeks)

Application:

  • Graphs are often used for real-time data analytics that help in identifying trends and sentiments which prove useful in marketing and customer service.

  • The data collected by sensors in Autonomous Vehicles is analyzed using Graphs to make the system understand the real-time environment. In this way, these vehicles can travel efficiently and safely.

  • The smooth operation of networks is ensured with the help of Graphs. They help network administrators to identify potential bottlenecks and points of congestion.

  • Large Scale IoT deployments, generate vast amounts of data for analysis. These deployments ensure the smooth management and accurate analysis of such data with the help of Graphs.

After going through the above information, one will have a basic understanding of some of the most important data structures and how they are used according to their characteristics in various real-life situations. These Data Structures are often modified to suit the requirements while solving problems. In many situations, a collection of different types of data structures work together for the system to run efficiently.