Important Data Structures In CS

Data Structures (DS) are a particular way of storing and organizing data that can be accessed and modified easily. It is a very important subject for a CS student, because all of the CS depends on it.
To become a good Computer Science engineer, we need to master our data structures.
Here I present some of the data structures that have many real world applications and are used almost everywhere in computer science. So let's get started.

1. Arrays

arrays

Arrays are a way to store our data in a linear manner.
They store our data in contiguous memory, so once defined we can randomly access any member of our array using indices.
For example, if we want to store the marks of 25 students in our class we can create an array for it.
In most programming languages arrays are 0-indexed i.e, first element of array is access by index '0'.

  • Advantages of arrays 1. Random Access of elements in O(1)
    2. Cache Friendly
  • Disadvantages of arrays
    1. Deletion and insertion operations are very costly.

Know more here

2. Binary Tree Data Structure

binary-tree

It is another data structure to store our data in hierarchal manner.
Binary Tree has a root node as its first node and can have up to 2 children.
Children of a node are referred by its left and right pointers.
In binary tree every node can have up to two children, but there are many extensions to it like ternary tree (with up to 3 children) and k-tree (up to k children per node, k can be any natural number).
Nodes in binary tree which don't have any children are called leaf nodes.

Real World Applications of Binary Tree
1. Many routing algorithms in Computer Networks use binary trees
2. SQL also stores our data in tree format.

Main reasons to use a tree data structure are:
1. To store our data in orderly hierarchal manner
2. Better insertions and deletions than arrays.

Reference: here

3. Graph Data Structure

graph

Another way to store our data in memory is Graphs.
When a set of vertices (V) is connected by a set of edges (E), than it is called a graph.
It is the most important DS and has many real world uses like
1. Representing a road/railway network
2. Friends on social networking sites are represented as graphs
3. Recommendations on e-commerce websites are made using graphs.

Seeing vast real world applications of graphs, you can tell how important of a data structure it is.
Graphs can be represented in many ways but the two most common representation of graphs are
1. Adjacency List
2. Adjacency Matrix

To know more about graphs, refer here


There are many more important and useful data structures, but I think this is a good place to start

AUTHOR

READ NEXT

Boostlog is an online community for developers
who want to share ideas and grow each other.

Delete an article

Deleted articles are gone forever. Are you sure?