Category Archives: Linked List

Delete last occurrence of an item from linked list

Given a liked list and a key to be deleted. Delete last occurrence of key from linked. The list may have duplicates. Examples: Input: 1->2->3->5->2->10, key = 2 Output: 1->2->3->5->10 We strongly recommend you to minimize your browser and try this yourself first The idea is to traverse the linked list from beginning to end.… Read More »



See Placement Course for placement preparation, GATE Corner for GATE CS Preparation and Quiz Corner for all Quizzes on GeeksQuiz.

LinkedList in java

In Java, LinkedList class implements the list interface. This class consists of the following methods : 1. boolean add(Object element) : It appends the element to the end of the list. 2. void add(int index, Object element): It inserts the element at the position ‘index’ in the list. 3. void addFirst(Object element) : It inserts… Read More »



See Placement Course for placement preparation, GATE Corner for GATE CS Preparation and Quiz Corner for all Quizzes on GeeksQuiz.

Insertion Sort for Singly Linked List

We have discussed Insertion Sort for arrays. In this article same for linked list is discussed. Below is simple insertion sort algorithm for linked list. 1) Create an empty sorted (or result) list 2) Traverse the given list, do following for every node. ……a) Insert current node in sorted way in sorted or result list.… Read More »



See Placement Course for placement preparation, GATE Corner for GATE CS Preparation and Quiz Corner for all Quizzes on GeeksQuiz.