COMPUTER SCIENCE AND ENGINEERING
ALGORITHMS
Question
[CLICK ON ANY CHOICE TO KNOW THE RIGHT ANSWER]
|
|
Compare 2 and 4 and put 2 into a new list
|
|
Compare 2 and 1 and put 1 into a new list
|
|
Compare 1 and 6 and put 1 into a new list
|
|
Compare 9 and 4 and put 4 into a new list
|
Detailed explanation-1: -Implementation of the merge sort algorithm is a three-step procedure. Divide, conquer, and combine.
Detailed explanation-2: -(1) Create a new head pointer to an empty linked list. (2) Check the first value of both linked lists. (3) Whichever node from L1 or L2 is smaller, append it to the new list and move the pointer to the next node. (4) Continue this process until you reach the end of a linked list.
Detailed explanation-3: -Pseudo Code for Merging two Linked Lists: NULL) last->next = first; else last->next = second; if(first->data < second->data) third = last = first; first = first->next; last->next = NULL; else third = last = second; second = second->next; last->next = NULL; while(first !=
Detailed explanation-4: -You can use the Python map() function along with the functools.reduce() function to compare the data items of two lists. When you use them in combination, the map() function applies the given function to every element and the reduce() function ensures that it applies the function in a consecutive manner.