Why do we need Arrays? Consider the problem of storing 10 integers. The naive way to store these integers would be to create 10 different integers variables and store 1 integer in each of them. This would be a viable solution but manipulating these variables would be a task in itself and we would have […]
Data Structure and Algorithms are the building blocks of computer programming. A well-defined data structure helps us in keeping our data organized. Some of the commonly used data structures are List, Queue, Stack, Tree etc.
The algorithms provide different ways to achieve a task on these data structures. Some of the common algorithms are in the area of sorting and searching elements in the data structure.
Linked List Insert Methods Linked List insert methods allow us to insert a Node at a specific place. There are three insert methods based on the position where the new node is inserted. addLast addFirst addAt 1. addLast As the name suggests, the new node is appended at the last position of the Linked list. […]
Linked List and Array are probably the most basic data structures, but their use can often be confusing. The use of the appropriate data structure can often result in an easier and more efficient code. Linked List vs Array is also a popular interview question in data structures. Linked List vs Array This article will […]
A linked list is a linear data structure that contains a sequence of elements such that each element has reference to the next element in the sequence. Each element in the linked list is called “Node”. Each Node contains a data element and a Node next which points to the next node in the linked […]
What is a Linked List? A linked list is a linear data structure used for storing collections of data Successive elements are connected by pointers The last element points to NULL Each element is a separate object and is called a Node Each node in a linked list comprises of two parts Data Reference to […]
A Linked List is a simple but fascinating data structure that can be used to store linearly connected non-contiguous data. We are often encountered with interesting manipulative problems using a linked list as they require out-of-the-box thinking with the limited properties of the Singly Linked List. In this article, we will be discussing the problem […]
In this tutorial, we’ll be discussing and implementing the Huffman Coding Algorithm in Java. Huffman Coding The Huffman Coding Algorithm was discovered by David A. Huffman in the 1950s. The purpose of the Algorithm is lossless data compression. This algorithm is commonly used in JPEG Compression. Now traditionally to encode/decode a string, we can use […]
In this tutorial, we’ll be discussing the Binary Search Tree Data Structure. We’ll be implementing the functions to search, insert and remove values from a Binary Search Tree. We’ll implement these operations recursively as well as iteratively. Binary Search Tree A Binary Search tree has the following property: All nodes should be such that the […]
In this tutorial, we’ll be discussing what’s Level Order Traversal. Also, we’ll be printing each level of the tree. We’ll use the two major approaches – Recursive and Iterative and see what’s the difference in time complexities between them. Level Order Traversal Level Order traversal is also known as Breadth-First Traversal since it traverses all […]
In this tutorial, we’ll be discussing a very popular algorithm which is used to detect whether a LinkedList has loops. It’s called Floyd’s Cycle-Finding Algorithm. LinkedList Loop Detection A loop exists in a LinkedList when no NULL is reached as we traverse throughout the LinkedList. So in order to detect whether a LinkedList has a […]