How To Choose Right Data Structure
How To Choose Right Data Structure
The data structure is a particular way of organizing data in a computer. The developer
must choose the appropriate data structure for better performance. If the developer
chooses a bad data structure, the system does not perform well.
Linked List
The linked list is a data structure that links each node to the next node. The developer
can use the linked list in the following use cases.
When the developer needs constant time for insertion and deletion.
When the data dynamically grows.
Do not access random elements from the linked list.
Insert the element in any position of the list.
Stack
The stack is a last-in, first-out data structure. The developer can use the stack in the
following use cases.
Queue
The queue is a first in, first-out (FIFO) data structure. The developer can use Queue in
the following use cases.
Binary Tree
A binary tree is a tree data structure in which each node has at most two child nodes.
The developer can use Binary Tree in the following use cases.
Heap
A heap is a specialized tree-based abstract data type that satisfies the heap property.
The developer can use Heap in the following use cases.
Hashing
Hash table is a data structure used to implement an associative array, a structure that
can map keys to values. The developer can use a Hash table in the following use
cases.
Graph
The graph is an abstract data type that is meant to implement the graph and directed
graph concepts from mathematics. The developer can use Graph in the following use
cases.
Red-Black Tree
Red–black tree is a binary search tree with an extra bit of data per node, its color, which
can be either red or black. The developer can use Red-Black Tree in the following use
cases.
Java TreeMap and C++ map implemented using Red Block Tree.
Computational Geometry Data structures.
Scheduler applications.
Array
The array is a data structure to store the same type of elements continuously. The
developer can use an array in the following use cases.
Matrix
Matrix is a data structure that stores the data using rows and columns. The developer
can use Matrix in the following use cases.
B-Tree
B-tree is a tree data structure that keeps data sorted and allows searches, sequential
access, insertions, and deletions in logarithmic time. The developer can use B-Tree in
the following use cases.
File systems.
Database operations.
Splay Tree
A splay tree is a self-adjusting binary search tree with the additional property that
recently accessed elements are quick to access again. The developer can use Splay
Tree in the following use cases.
AVL Tree
AVL tree, the shape of the tree is constrained at all times such that the tree shape is
balanced. The height of the tree never exceeds O(log n). The developer can use AVL
Tree in the following use cases.
When the developer wants to control the tree height outside -1 to 1 range.
Fast looking element.
Trie
A Trie (digital tree and sometimes radix tree or prefix tree), is an ordered tree data
structure that is used to store a dynamic set or associative array where the keys are
usually strings. The developer can use Trie in the following use cases.