Computer Science, asked by hameedalthaf19, 7 hours ago

Design an algorithm to find all the common elements in two sorted lists of numbers. For example, for the lists 2, 5, 5, 5 and 2, 2, 3, 5, 5, 7, the output should be 2, 5, 5. What is the maximum number of comparisons your algorithm makes if the lengths of the two given lists are m and n, respectively?

Answers

Answered by CrazyKanav
0

Answer:

Explanation:

Step 1 : Start

Step 2: Take the 2 lists as input

Step 3: Make an empty list

Step 4: Loop through 1st list, and 2nd list

Step 5: If the current item is equal to the 2nd current item

Step 6: If yes, then append the item to the empty list

Step 7: Else, continue

Step 8: After the loop, display the list

Step 9 : Stop

Similar questions
Geography, 7 months ago