Category Archives: Linked Lists

Linked List problems

The Great Tree-List Recursion Problem.

Asked by Varun Bhatia. Question: Write a recursive function treeToList(Node root) that takes an ordered binary tree and rearranges the internal pointers to make a circular doubly linked list out of the tree nodes.

Function to check if a singly linked list is palindrome

Given a singly linked list of characters, write a function that returns true if the given list is palindrome, else false. METHOD 1 (Use a Stack) A simple solution is to use a stack of list nodes. This mainly involves three steps. 1) Traverse the given list from head to tail and push every visited… Read More »

Find the middle of a given linked list in C and Java

Given a singly linked list, find middle of the linked list. For example, if given linked list is 1->2->3->4->5 then output should be 3. If there are even nodes, then there would be two middle nodes, we need to print second middle element. For example, if given linked list is 1->2->3->4->5->6 then output should be… Read More »