Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

4. Let A and B be two arrays, each storing n different integer values. The goal is to design an algorithm that returns true if

image text in transcribedimage text in transcribed

4. Let A and B be two arrays, each storing n different integer values. The goal is to design an algorithm that returns true if A and B have no common values, and it returns false otherwise. For example, if the algorithm receives as input below arrays A and B the algorithm must return true as no value in A is also in B; however if the algorithm receives as input arrays A and B it must return false as the values 3 and 4 in A' also appear in B. 6 0 8 1 7 5 1 2 3 4 3 0 9 1 4 2 0 3 2 4 8 0 3 1 1 4 2 3 ' 6 4 B i. (4 marks) Write pseudocode for an algorithm as described above. You cannot use a hashmap or any other additional data structures. You cannot sort the arrays. ii. Prove that your algorithm is correct: a. (1 mark) Show that the algorithm terminates. b. (2 marks) Show that the algorithm always produces the correct answer. iii. (1 mark) Explain what the worst case for the algorithm is. iv. (3 marks) Compute the time complexity of the algorithm in the worst case. You must give the order of the time complexity using "big-Oh notation and you must explain how you computed the time complexity

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Select Healthcare Classification Systems And Databases

Authors: Katherine S. Rowell, Ann Cutrell

1st Edition

0615909760, 978-0615909769

More Books

Students also viewed these Databases questions