Linked List
Linked list is one of data structures where the elements aren't place next to each other in the memory, but rather the element is pointing to the next one. The linked list is used to easily add or remove an element inside a list without reallocating or reorganize the list because the elements aren't stored contiguously inside the memory.
Types of Linked List
Circular Single Linked List
In circular single linked list, there is a pointer placed inside the element that point to the next one. At the last element of the list, the pointer is pointing at the first element of the list. Null value can't be stored in this list.
Doubly Linked List
Representation of Single Linked List |
In doubly linked list, there are 2 pointer placed inside the element that are pointing to the next or previous element. NULL value can be stored in this list.
The code to create Double Linked List:
Representation of Double Linked List |
The code to create Double Linked List:
Circular Double Linked List
Circular double linked list are the combination between circular single linked list and doubly linked list. There are 2 pointer inside the element except the head element that only have one, the pointers are pointing to the next and previous element. The "next" pointer in the last element isn't pointing at the head element, but it's pointing to the element where the head element is pointing at.
Hashing Table
Hashing Table is a data structure which stores data in an associative manner. In hashing table the data are stored in an array format, where each value has it's own unique index value. Hashing is a technique to convert a range of key values into a range of indexes of an array. An example of hashing in real life is, each student in a university is given their own unique student ID that contain their own information.
The code to get the hash index :
The code to get the hash index :
Binary Tree
Binary tree is a data structure where each node can only have at most 2 children node that can be referred as left child and right child. Binary tree have important terms like, Root - the node at the top of the tree, Path - refers to the sequence of nodes along the edges of a tree, Parent - any node that have child node, Leaf - node which does not have any child node, and more.
The initial code for creating the binary tree :