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

A singly-linked list is built with nodes, where each node has: node.next — pointing to the next node in the LinkedList. node.value — the data held in the node. For example, if our LinkedList represents people in line at a Railway ticket counter then node.value might be the person's name. A cycle occurs when a node’s next points back to a previous n...

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

FOLLOW US ON LinkedIn



Explore Tutu'rself