Geek Culture
Published in

Geek Culture

Applications of Data Structures

A data structure is a way of organizing data in a way so that the data becomes accessible effortlessly and quickly.

Photo by Shahadat Rahman on Unsplash

Data Structure is a collection of values; the values have relationships among them, and they can have functions applied to them. Each function is unique and specialized for its own thing. They are key components in building powerful algorithms, make the code cleaner and easier to understand.

Before we talk about applications of Data Structures, we need to understand the concept of Abstract Data Types. It is an abstraction of data structure. It provides the interface to which a data structure must stick to. This data type is called “Abstract” as it is just a theoretical concept, and every programming language has different ways of implementing these concepts.

Array: a fixed-length container which contains n elements that have a range from [0, n-1] e.g.: if an array contains 5 elements, the range will be [0, 5–1] (n=5) => [0,4]. This range is also known as indexable range. Indexable means that each slot of an array can be reference with a number called index key (it is zero based). This indexing allows random access to any element of the array. Static Arrays are finite in size, that is, the programmer defines the length of the array. High-level programming languages have the concept of Dynamic Arrays in which the array grows/resizes and allows adding more elements to it.

Applications of Array:

i. Contacts of a mobile phone

ii. Storing data in a tabular format

iii. Storage of matrices and binary tree elements of fixed count

iv. Building block element of other data structures such as heaps, vectors and more

v. Online ticket booking system — if a user wants to book a seat in C-4, the array becomes seat[C][4] or seat[3][4]

Stack: a linear data structure which has a predefined capacity. It follows the Last in First Out (LIFO) order or First in Last Out (FILO) order. Every time an element is added by using the Push operation, it goes on top of the stack and the element can either be removed from top of the stack with the help of Pop operation.

Applications of Stack:

i. UNDO and REDO functions in a text editor

ii. Virtual Machines

iii. Expression Conversion (Infix to Postfix and vice versa)

iv. Reversal of a string

v. Back/Forward button in browsers and file browsers

Singly Linked List: collection of objects called nodes that are stored in a random manner in the memory. A node consists of two parts, one being the data stored at that specific address and the other being a pointer which contains the address of the next node in the memory. The last node of this type of a list contains a pointer to NULL.

Applications of Singly Linked List:

i. Prevent collision between data in a hash map

ii. UNDO, REDO or DELETE operations in a notepad

iii. Photo viewer to look at photos continuously in a slide show

iv. If one wants to add a bogie, they can either take a new bogie to add at the last or in between two bogies.

v. The next track feature of a music player

Doubly Linked List: a complex type of linked list in which a node contains a pointer to the previous as well as the next node in the sequence.

Applications of Doubly Linked List:

i. Represent deck of cards in games

ii. Used to represent various states of a game

iii. UNDO or REDO function

iv. Used by browsers to implement backward and forward navigation of the visited web pages

v. The next track and previous track feature of a music player

Circular Linked List: the last node of the list contains a pointer to the first node of the list. We can have circular singly linked list as well as circular doubly linked list.

Applications of Circular Linked List:

i. All the running applications in an Operating System are kept in a circular linked list and the Operating System gives a fixed time slot to all for running. The Operating System iterates the list over and over again until all the applications get completed

ii. In Role Based Multiplayer games, all the players are kept in a circular linked list and the pointer keeps moving forward as a player’s chance ends

iii. Snake game in mobile phones, where head of the list is the snake’s head and tail of the list is the snake’s tail

iv. The repeat feature in a music player wherein a user will continuously listen to the playlist on repeat that is, when the songs of the playlist get over, the first song is played

Graphs: a non-linear data structure which consists of nodes and edges. They are used to represent networks. The network includes paths in a city, a telephone network or a circuit network.

Applications of Graphs:

i. Resource utilization and availability in an organization

ii. Interconnections in Social Media and other Network Based platforms

iii. Ecommerce applications where user preferences are set

iv. Shortest path from Point A to Point B can be found with the help of certain algorithms

Queues: a linear structure which follows a particular order in which the operations have to be performed. The order of a queue is First in First Out i.e., a person who gets in queue first will get served first.

Applications of Queues:

i. Processing requests on a single shared resource such as a printer, CPU task scheduling

ii. In a call center, queues are used to hold people calling them in an order until a service representative is free

iii. Handling of interrupts in a real-time system

iv. Priority queues used in file downloading operation of a browser

Trees: a non-linear data structure that represents hierarchical data. It is a hierarchical structure as elements present inside this tree are arranged in multiple levels. The top most node is known as a Root Node and every node underneath this node is known as Child Node.

Applications of Trees:

i. In computer systems, directory and file systems

ii. Implementation of navigation structure of a website

iii. Decision making in video games

iv. Path Finding Algorithms which are then implemented in Artificial Intelligence, Robotics and Video Games

This article was written by my colleagues —

Amber Upadhyay, Kedar Trivedi and Ashwin Sapariya and Rohan Pandav (me) as a project given to us by our teaching faculty of Data Structures and Algorithms.

--

--

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