Data Structure C++
Write pseudocode that merges two sorted lists into a new third sorted list by using only ADT sorted list operations.
The pseudocode to merge two sorted list is given below:
function mergeTwoSortedArray(Integer firstArray[], Integer
secondArray[], mergeArray[])
declare integer variable i, j, k, n1, and n2
Set i to 0
Set j to 0
Set k to 0
Set n1 to the size of the first array
Set n2 to the size of the second array
while i<n1 AND j <n2
if firstArray[i] < secondArray[j]
mergeArray[k] = firstArray[i]
k = k+1
i = i+1
else
mergeArray[k] = secondArray[j]
k = k+1
j = j+1
End While
while i < n1
mergeArray[k] = firstArray[i]
k = k+1
i = i+1
End While
while j < n2
mergeArray[k] = secondArray[j]
k = k+1
j = j+1
End While
End Function
Data Structure C++ Write pseudocode that merges two sorted lists into a new third sorted list...
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 C++ function to compute L1 ∪ L2 using only the basic list operations.
Given two sorted lists, L1 and L2, write a procedure to computeL1 ∪ L2 using only the basic list operations.
You have two sorted lists of integers, L1 and L2. You know the lengths of each list, L1 has length N1 and L2 has length N2. (a) Design an efficient algorithm (only pseudocode) to output a sorted list L1 ∩ L2 (the intersection of L1 and L2). (b) If you know that N2 > N1. What is the running time complexity of your algorithm? Justify. Important Note: For this problem, you don’t need to submit any implementation in Java. Only...
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...
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...
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...