# Data Structures

This category contains all the posts related to data structures. For e.g.: Hash Tables, Linked Lists, Trees, Graphs, Heaps, Tries etc..

## Balanced Search Trees – AVL Tree

Introduction When we talk about balanced search trees, we specifically are talking about two things. A search trees. A height balanced tree. Here in this post we will consider a Binary Search Tree and will try to equip with features to self balance itself upon modifications. Before starting up with the logic and code part we need to understand the motive behind this kind of data structure and more precisely we need to understand the need of such a complex scenario. Apart from that we also need to understand what it means to be termed as balanced. What does balancing means? We sa...

## Finding loop in Linked List

Problem Statement You are given a singly linked list which may or may not contain a loop. The task at hand is to find if the loop exists.  Here is a diagrammatic representation of a loop in a singly linked list. [caption id="attachment_3617" align="aligncenter" width="688"] Finding loop in LinkedList[/caption] It is pretty clear that there is a loop which starts at the node 3 and there are 10 nodes which make the loop. In this case we need to print a YES. If it had been a singly linked list without the node 12 connecting to node 3, we would have printed a NO. Approach to Finding loop i...

## Cloning Linked List having Next and Random Pointer

Introduction This question was asked by a colleague, although it seems to be simple at first but with given restrictions like running time and space limitations, it becomes tricky. You need to be good with Linked Lists to crack the right solution. Here we try to define the problem in more detail. Given a Linked List where each node contains two pointers next and random. The next pointer points to the immediate next node and the random pointer points to any random node in the linked list. Clone the linked list and return the head of the clone. There are definitely certain conditions impos...