Category Archives: Linked Lists

Linked List problems

Decimal Equivalent of Binary Linked List

Given a singly linked list of 0s and 1s find its decimal equivalent. Input : 0->0->0->1->1->0->0->1->0 Output : 50 Input : 1->0->0 Output : 4 Decimal Value of an empty linked list is considered as 0. Initialize result as 0. Traverse the linked list and for each node, multiply the result by 2 and add… Read More »

Merge K sorted linked lists

Given K sorted linked lists of size N each, merge them and print the sorted output. Example: Input: k = 3, n = 4 list1 = 1->3->5->7->NULL list2 = 2->4->6->8->NULL list3 = 0->9->10->11 Output: 0->1->2->3->4->5->6->7->8->9->10->11   Method 1 (Simple) A Simple Solution is to initialize result as first list. Now traverse all lists starting from… Read More »