c++
Write pseudocode that merges two sorted lists into a new third sorted list by using only ADT sorted list operations.
Answer: The pseudocode has been explained with neat comments
//function returns list
list mergeTwoSortedLists(listA, listB){
resList; //3rd list
l1 = lenght of listA
l2 = lenght of listB
while(i<l1 && j<l2){
if(listA[i] < listB[i]{
resList[k] = listA[i];
i++; K++;
}
else{
resList[k] = listB[i];
j++; K++;
}
}
// if listA contains more elements than listB
while(i<l1){
resList[k] = listA[i];
i++; K++;
}
// if listB contains more elements than listA
while(i<l2){
resList[k] = listB[i];
j++; K++;
}
return resList;
}
c++ Write pseudocode that merges two sorted lists into a new third sorted list by using...
Data Structure C++ Write pseudocode that merges two sorted lists into a new third sorted list by using only ADT sorted list operations.
(20 points) ) Write a Python program which
merges two sorted singly linked lists and return it as a new list.
The new list should be made by splicing together the nodes of the
first two lists.
Example:
Example: Input: 1->2- >4, 1->3->4 Output: 1->1->2->3 ->4->4
Given two sorted lists, L1 and L2, write a procedure to computeL1 ∪ L2 using only the basic list operations.
Chapter 4 describes the ADT Sorted List using an array implementation with a maximum of 25 items. The pseudocode for the ADT Sorted List Operations are provided on page 210. Use this information to create an ADT for handling a collection of Person objects, where each object will contain a Social Insurance Number (validate this), a first name, a last name, a gender and a data of birth. This implementation should prevent duplicate entries – that is, the Social Insurance...
Problem #1: (15 points) You have two sorted lists of integers, L, and L2. You know the lengths of each list, L1 has length N, and L2 has length N2 (a) Design an efficient algorithm (only pseudocode) to output a sorted list L L2 (the intersection of L and L2). (b) If you know that N2> Ni. What is the running time complexity of your algorithm? Justify Important Note For this problem, you don't need to submit any implementation in...
C++ Santa Claus allegedly keeps lists of those who are naughty and those who are nice. On the naughty list are the names of those who will get coal in their stockings. On the nice list are those who will receive gifts. Each object in this list contains a name (a string) and a list of that person’s gifts (an instance of an ADT list). Design an ADT for the objects in the nice list. Specify each ADT operation by...
9. When we have two sorted lists of numbers in non-descending order, and we need to merge them into one sorted list, we can simply compare the first two elements of the lists, extract the smaller one and attach it to the end of the new list, and repeat until one of the two original lists become empty, then we attach the remaining numbers to the end of the new list and it's done. This takes linear time. Now, try...
When we have two sorted lists of numbers in non-descending order, and we need to merge them into one sorted list, we can simply compare the first two elements of the lists, extract the smaller one and attach it to the end of the new list, and repeat until one of the two original lists become empty, then we attach the remaining numbers to the end of the new list and it's done. This takes linear time. Now, try to...
With the main function please
using the single linked list code written in the class or in the lab, write and test the follow function: Merge() 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.