You are browsing the archive for linked list.

Insert into a Cyclic Sorted List

August 12, 2011 in linked list

Given a node from a cyclic linked list which has been sorted, write a function to insert a value into the list such that it remains a cyclic sorted list. The given node can be any single node in the list.

Read the rest of this entry →

Convert Binary Search Tree (BST) to Sorted Doubly-Linked List

November 29, 2010 in binary tree, linked list

Convert a BST to a sorted circular doubly-linked list in-place. Think of the left and right pointers as synonymous to the previous and next pointers in a doubly-linked list.

Read the rest of this entry →

Convert Sorted List to Balanced Binary Search Tree (BST)

November 27, 2010 in binary tree, linked list

Given a singly linked list where elements are sorted in ascending order, convert it to a height balanced BST.

Read the rest of this entry →

Detecting a Loop in a Singly Linked List

September 11, 2010 in linked list

Given a singly linked list, find if there exist a loop.

Read the rest of this entry →

Splitting Linked List

September 11, 2010 in linked list

Given a list, split it into two sublists — one for the front half, and one for the back half. If the number of elements is odd, the extra element should go in the front list. So FrontBackSplit() on the list {2, 3, 5, 7, 11} should yield the two lists {2, 3, 5} and {7, 11}.

Read the rest of this entry →