A linked list is a linear data structure where each element is known as a node. A node is consist of a pointer and an object. The pointer is pointing to the next node in the list and the object represent the value of the node. There is also a head which is pointing to the start of the Linked List. Following diagram is an example of a Linked List. A...

Read More

As we have already established that Linked Lists are data structures where each element is linked to the other and this linking makes it possible to trace through the data structure. So how would you find the length of a singly linked list? You can do it in two ways. Firstly by iterating through the data structure till the last element. And the sec...

Read More

Our LinkedList class looks something like this. It has a Node Class as a inner class which has a next reference to a Node and a integer value. It also has a head Node variable which can be used for various LinkedList operations. It also has a toString method which parses the LinkedList and returns a comma separated value. We will explore this class...

Read More

This one has been an interview favourite for quite some time now. The trick is to break the operation into smaller operations and extract the common logic. In such a case it makes sense to go till the last 2 nodes and begin the reversal there. We call the method with the node in question and its previous node so that when we identify that the node ...

Read More

Singly Linked Lists are a type of data structure. It is a type of list. In a singly linked list each node in the list stores the contents of the node and a pointer or reference to the next node in the list. It does not store any pointer or reference to the previous node. package com.tuturself.programs; public class SingleLinkedList { p...

Read More

Consider a Linked List is given to you. And you have to retain n elements and delete m elements till the end of the List. To understand the problem with more clarity consider the following example. Input: N = 1, M = 1 Linked List: 1 → 2 → 3 → 4 → 5 → 6 → 7 → 8 → 9 → 10 Here you have to retain 1 element and delete 1 element till the end of the Lin...

Read More

The difference between a regular LinkedList and a LinkedList with a Loop is that, There are two nodes in a LinkedList with a loop whose next pointers are the same. In a regular single LinkedList (without a loop) each node’s next pointer is unique. So the repeatation of next pointer in a LinkedList is actually indication of a loop. Following figure ...

Read More

There are two singly linked lists . By mistake the end node of one of the linked list got linked into the second list, and created a intersection between the 2 linked list. We need to write a program to get the point where two linked list merge. Consider the following figure where List1 and List2 merged in the node with value 99. Algorithm by marki...

Read More

Generally, LinkedList means a Singly LinkedList. This list consists of a number of nodes where each node has a next pointer to the following node. The link of the last node in the list is NULL, which indicates the end of the list. Following figure describes such a singly LinkedList. Following is the type declaration we are going to use for our exam...

Read More

In this article we are going to find the node in a singly LinkedList, where a Loop starts , if there is a loop exists in the LinkedList. The solution is a extension to the problem of finding the existence of a Loop in a linked list. Finding the loop in a linked list was solved using Floyd cycle detection algorithm in this article. It is highly reco...

Read More

FOLLOW US ON LinkedIn



Explore Tutu'rself