1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
rewona [7]
4 years ago
7

Give an O(log m + log n)-time algorithm that takes two sorted lists of sizes m and n, respectively, as input and returns the ith

smallest element in the union of the two lists. Justify your algorithm and analyze its running time.
Computers and Technology
1 answer:
olga2289 [7]4 years ago
7 0

Binary search is used similarly. K'th element is found in more productive way.

<u>Explanation:</u>

arr1 and arr2 are the middle elements which are compared, let us compute as mid1 and mid2. Let us predict arr1 [mid1] k, the elements are not needed after mid2 elements.  arr2 are set as last element for arr2 [mid2].  New sub problems are defined. When one array is half the size.

C++ code for the algorithm.

#include <iostream>

using namespace std;    

int kth(int *arr1, int *arr2, int *end1, int *end2, int k)

{

if (arr1 == end1)

return arr2[k];

if (arr2 == end2)

return arr1[k];

int mid1 = (end1 - arr1) / 2;

int mid2 = (end2 - arr2) / 2;

if (mid1 + mid2 < k)

{

if (arr1[mid1] > arr2[mid2])

return kth(arr1, arr2 + mid2 + 1, end1, end2,

k - mid2 - 1);

else

return kth(arr1 + mid1 + 1, arr2, end1, end2,

k - mid1 - 1);

}

else

{

if (arr1[mid1] > arr2[mid2])

return kth(arr1, arr2, arr1 + mid1, end2, k);

else

return kth(arr1, arr2, end1, arr2 + mid2, k);

}    

int main()

{

int arr1[5] = {2, 3, 6, 7, 9};

int arr2[4] = {1, 4, 8, 10};    

int k = 5;

cout << kth(arr1, arr2, arr1 + 5, arr2 + 4, k - 1);

return 0;

}

You might be interested in
______ are single numbers or values, which may include integers, floating-point decimals, or strings of characters.
marysya [2.9K]

Scalar Values are single numbers or values, which may include integers, floating-point decimals, or strings of characters.

A(n) array is a group of scalar or individual values that are stored in one entity.

A(n) user-defined type is a data type that is assigned a true or false value by a programmer.

A(n) abstract data type is a data type that can be assigned multiple values.

4 0
3 years ago
. What are the typical parts of a Change Request Document?
photoshop1234 [79]

Answer:

 Change request is the type of document which basically contain the adjustment of the system by call and the change request is the essential and important part in the process of change management.

Change request must be declarative as, it state that what should be accomplish, but forget about the change that should be completed. The main elements or parts of the change request are:

  • Customer ID
  • Abstract change
  • The deadline change type

The importance of the change request document is that it is used in various type of SDLC and project management system. It is basically originate from the system request from the users.

3 0
3 years ago
What did Richard Maddox invent? Why was this important?
DerKrebs [107]

Answer:

richard maddox created the first 35mm camera

Explanation:

Grade 10

4 0
4 years ago
Read 2 more answers
What is one problem you should keep in mind when researching information on the Internet?
shepuryov [24]
The answer is A due to the internet being a plethora of information being accessed by anyone and everyone with internet access. Any person of no background to certain information could claim mastery to the field and sway his/her audience to ways possible. Ensuring that the source of the information being read is from credible and reputable companies. You can do this by ensuring the information is from newspapers with names known all over the world or there are also sourced footnotes from the author where they could have cited some information from other articles. 
5 0
3 years ago
Read 2 more answers
What is the difference between auto fill and fill handle ?​
lidiya [134]

Answer:

  • Auto fill a software function that automatically completes data (like the data that has been entered previously) without the user needing to type it in full.

  • The Fill Handle is a feature in Excel that fills the data automatically with a specific pattern in your spreadsheet cell.

hope u liked the answer :)

7 0
3 years ago
Other questions:
  • Which of the following commands uses correct syntax for matching the patterns bunk or bank at the end of a line of text?
    5·1 answer
  • Which of the following is NOT a group on the Slide Master tab?
    6·1 answer
  • Which is the most important reason you should properly cite information that you obtain from an Internet search? Question 2 opti
    8·1 answer
  • The destination ip address is 164.109.27.233 subnet mask of 255.255.192.0 network address is
    12·1 answer
  • What happens when you double-click a column border??
    12·1 answer
  • import java.util.Scanner; public class StudentScores { public static void main (String [] args) { Scanner scnr = new Scanner(Sys
    5·1 answer
  • )In a graph represented by adjacency matrix u can find all the neighbours of a given vertices in ____Operations
    6·1 answer
  • A market-product strategy that requires no change in the basic product but instead seeks new buyers is known as ______
    11·1 answer
  • 9) Which date is assigned the serial number of 1?
    10·2 answers
  • The Home editions of Windows 7 do not include the Local Security Policy or Print Management.
    15·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!