Browsing the topic Linked Lists
Given a Doubly Linked List which has data members sorted in ascending order. Construct a Balanced Binary Search Tree which has same data members as the given Doubly Linked List. The tree must be constructed in-place (No new node should be allocated for tree conversion)
Read More »Given a Singly Linked List which has data members sorted in ascending order. Construct a Balanced Binary Search Tree which has same data members as the given Linked List.
Read More »Given a Singly Linked List, write a function to delete a given node. Your function must follow following constraints:
Read More »How to write C functions that modify head pointer of a Linked List?
8 Comments | Filed under Linked ListsConsider simple representation (without any dummy node) of Linked List. Functions that operate on such Linked lists can be divided in two categories:
Read More »Given two numbers represented by two lists, write a function that returns sum list. The sum list is list representation of addition of two input numbers.
Read More »XOR Linked List – A Memory Efficient Doubly Linked List | Set 1
10 Comments | Filed under Linked ListsAn ordinary Doubly Linked List requires space for two address fields to store the addresses of previous and next nodes.
Read More »Write a function detectAndRemoveLoop() that checks whether a given Linked List contains loop and if loop is present then removes the loop and returns true.
Read More »Given a Linked List of integers, write a function to modify the linked list such that all even numbers appear before all the odd numbers in the modified linked list.
Read More »Given a singly linked list, remove all the nodes which have a greater value on right side.
Read More »Given a linked list, write a function to reverse every alternate k nodes (where k is an input to the function) in an efficient way. Give the complexity of your algorithm.
Read More »Difficulty Level: Rookie Write a C function to insert a new value in a sorted Circular Linked List (CLL). For example, if the input CLL is following.
Read More »Difficulty Level: Rookie Both Arrays and Linked List can be used to store linear data of similar types, but they both have some advantages and disadvantages over each other.
Read More »Given a linked list, write a function to reverse every k nodes (where k is an input to the function).
Read More »Merge sort is often preferred for sorting a linked list. The slow random-access performance of a linked list makes some other algorithms (such as quicksort) perform poorly, and others (such as heapsort) completely impossible.
Read More »Two Linked Lists are identical when they have same data and arrangement of data is also same. For example Linked lists a (1->2->3) and b(1->2->3) are identical.
Read More »Write a SortedMerge() function that takes two lists, each of which is sorted in increasing order, and merges the two together into one list which is in increasing order. SortedMerge() should return the new list.
Read More »Write a function AlternatingSplit() that takes one list and divides up its nodes to make two smaller lists ‘a’ and ‘b’. The sublists should be made from alternating elements in the original list. So if the original list is 0->1->0->1->0->1 then one sublist should be 0->0->0 and the other should be 1->1->1.
Read More »Given a Singly Linked List, starting from the second node delete all alternate nodes of it. For example, if the given linked list is 1->2->3->4->5 then your function should convert it to 1->3->5, and if the given linked list is 1->2->3->4 then convert it to 1->3.
Read More »Given two lists sorted in increasing order, create and return a new list representing the intersection of the two lists. The new list should be made with its own memory — the original lists should not be changed.
Read More »Write a function to delete a given node in a doubly linked list.
Read More »Given a singly linked list, write a function to swap elements pairwise. For example, if the linked list is 1->2->3->4->5 then the function should change it to 2->1->4->3->5, and if the linked list is 1->2->3->4->5->6 then the function should change it to 2->1->4->3->6->5.
Read More »Write a C function that moves last element to front in a given Singly Linked List. For example, if the given Linked List is 1->2->3->4->5, then the function should change the list to 5->1->2->3->4.
Read More »Assume the structure of a Linked List node is as follows.
Read More »Asked by Bharani
Read More »Write a C function to reverse a given Doubly Linked List See below diagrams for example.
Read More »