Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Question 6 ( 3 0 . 0 marks ) Given two unsorted arrays A and B . Array A consists of n numbers of integers

Question 6(30.0 marks)
Given two unsorted arrays A and B. Array A consists of n numbers of integers and array B consists of m numbers of integers. The integers in array B are distinct and they are in the range 1cdotsn. The problem is to output the B[i]th smallest number in array A, for 1im, and mn. For example, let A=[7,3,8,21,5,11] and B=[3,5,1], then the output is 3,7,11 because the sorted array of the elements in array A is 3,5,7,8,11,21 and the first (1st) smallest element of array A is 3, the 3rd smallest element of array A is 7, and the 5th smallest element of array A is 11.
Write two Java, C++, or Python programs to implement the following algorithms:
a) Algorithm 1. Sort array A and Array B and produce the required output.
(10 marks)
b) Write a. report on the analysis of your implementation for Algorithm 1, using the Time or space complexity in terms of function f(n). How much time (number of operations) does Algorithm 1 take?
c) Algorithm 2. Sort array A but do not sort array B. Produce the required output.
d) Write a report on the analysis of your implementation for Algorithm 1, using Time or space complexity in terms of function f(n) How much time (number of operations) does Algorithm 2 take?
Pls give me explanations as well when u
image text in transcribed

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

The Manga Guide To Databases

Authors: Mana Takahashi, Shoko Azuma, Co Ltd Trend

1st Edition

1593271905, 978-1593271909

More Books

Students also viewed these Databases questions