Browsing the topic Linked Lists
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.
Write a removeDuplicates() function which takes a list and deletes any duplicate nodes from the list. The list is not sorted.
Read More »Write a removeDuplicates() function which takes a list sorted in non-decreasing order and deletes any duplicate nodes from the list. The list should only be traversed once.
Read More »Write a recursive function to print reverse of a Linked List
Leave a comment | Filed under Linked ListsNote that the question is only about printing the reverse. To reverse the list itself see this
Difficulty Level: Rookie
Read More »Write a function to get the intersection point of two Linked Lists.
16 Comments | Filed under Linked ListsThere are two singly linked lists in a system. By some programming error the end node of one of the linked list got linked into the second list, forming a inverted Y shaped list. Write a program to get the point where two linked list merge.
Read More »Given a linked list which is sorted, how will you insert in sorted way
4 Comments | Filed under Linked ListsAlgorithm:
Let input linked list is sorted in increasing order.
Asked by Varun Bhatia.
Read More »Asked by Varun Bhatia.
Read More »
