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]
3 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]3 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
Which of the following is productivity strategy for collaboration?
mixer [17]

Which of the following is a productivity strategy for collaboration?

  • A. Saving focused work for a time of day when you feel most creative.
  • B. Employing the 80/20 rule to prioritize tasks.
  • C. Posting files to a web-based shared site.
  • D. Using white noise to block distractions in the office.

<u>Answer:</u>

Posting files to a web-based shared site is a productivity strategy for collaboration.

  • C. Posting files to a web-based shared site.

<u>Explanation:</u>

Collaborative software or groupware is application programming intended to help individuals taking a shot at a typical errand to achieve their objectives. This permits individual to impart thoughts and their abilities to different individuals with the goal that the assignment can be done both proficiently and adequately.

Joint effort stages ordinarily incorporate an email customer, Web conferencing, internet based life sharing, video capacities, report sharing abilities, texting and that's just the beginning. Endeavor joint effort stages are intended to be introduced on-premises or conveyed by means of the Web as cloud-based administrations.

8 0
3 years ago
Sorry to bother you guys but for some reason it wont let me comment. How can i fix this?
Step2247 [10]

Explanation:

I would just say close the app and come back in after

7 0
3 years ago
Read 2 more answers
What are two types of organizational structures designed to help an organization achieve its goals and objectives?
Fittoniya [83]

The answer is entrepreneurial and bureaucratic. Organizations that are large and small can achieve higher sales and other profit by properly matching their needs with the structure they use to operate.   the structure of an organization can help or hinder its progress toward accomplishing these goals and This are specific set up of organizations and ways to accomplish different goals. 

4 0
3 years ago
Read 2 more answers
3.
gulaghasi [49]

Explanation:

the process of displaying the information from the table is called query

<h2>hey friend </h2><h2>your answer is here </h2><h2>I hope it will be helpful you </h2><h2>please mark as brainiest answer </h2><h2>thank you </h2>
7 0
3 years ago
Universal containers wants to rollout new product bundles with several pricing options. Pricing options include product-price bu
ololo11 [35]

Answer:

a) Custom AppExchange-app for product-pricing

Explanation:

We can find a solution in AppExchange for this product-pricing, surfing in the option, we could get solutions like BoonPlus, and easy pricing Opportunity, this App has a free trial.

With this option is easy to choose a book price, add new products, select pricing rule, we can get an order's product, and calculate pricing, just we must download the app and install it.

6 0
3 years ago
Other questions:
  • _______ view focuses on the text and content of a document, without much information on the page layout.
    7·1 answer
  • How can you ensure you don't go over your budget?
    8·1 answer
  • The _____ is a blinking vertical line that indicates where the next typed character will appear. scroll box sheet tab insertion
    7·1 answer
  • A snapshot is most similar to which type of backup scheme
    8·1 answer
  • Which of the following is not true about VOIP?
    9·1 answer
  • What is intellectual property rights law ?​
    8·1 answer
  • Icon view, list view, and details view are all common views provided by which kind of program?
    12·2 answers
  • Which tool allows users to share code and also serves as a social networking
    10·1 answer
  • Which are print settings that can be modified in word 2019 choose two answers​
    8·1 answer
  • 5. Nadia wants to calculate the total interest, which is the total amount of the payments minus the loan amount. In cell F6, ent
    8·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!