Question

Design an Algorithm that tests whether or not 2 input lists of size n have at...

Design an Algorithm that tests whether or not 2 input lists of size n have at least 1 element in common. Give formulas for B(n) and W(n) for your algorithm.

0 0
Add a comment Improve this question Transcribed image text
Answer #1

******************************************************************************************
Please Upvote the answer as it matters to me a lot :)
*****************************************************************************************
As HOMEWORKLIB RULES expert answering guidelines,Experts are supposed to answer only certain number of questions/sub-parts in a post.Please raise the remaining as a new question as HOMEWORKLIB RULES guidelines.
******************************************************************************************

Common(A,B)
x= A.size
  
for i =1 to x do
for j=1 to x do
if A[i] =B[j]
return true
return false
Time complexity = O(n2)
Spcae complexity = O(1)

Add a comment
Know the answer?
Add Answer to:
Design an Algorithm that tests whether or not 2 input lists of size n have at...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • (1) Describe (in words) an algorithm that checks if two given lists are disjoint, meaning that...

    (1) Describe (in words) an algorithm that checks if two given lists are disjoint, meaning that they have no element in common. (2) Then write the pseudo-code for your algorithm by calling it dis- joint(0,..., An, bi, ...., bm : elements) (note that the lists can have different size).

  • 5. (570/470 bonus) Design an algorithm whose input is a list of n points, (xu, )...

    5. (570/470 bonus) Design an algorithm whose input is a list of n points, (xu, ) for isks n. Your algorithm should run in O(n) time and determine whether or not the convex hull of these n points is a triangle. Also explain why your algorithm runs in O(n) time.

  • 1. Design an algorithm to find all the non-common elements in two sorted lists of numbers....

    1. Design an algorithm to find all the non-common elements in two sorted lists of numbers. What is the maximum number of comparisons your algorithm makes if the lengths of the two given lists are m and n, ?respectively 2. Estimate how many times faster it will be to find ged(98765, 56789) by Euclid's algorithm compared with the algorithm based on checking consecutive integers from min{m, n} down to gcd(m, n). 3. For each of the following functions, indicate how...

  • What if there are k sorted linked lists. Please design an algorithm to combine the k...

    What if there are k sorted linked lists. Please design an algorithm to combine the k linked lists. Input: 1 +4 1 +3 2 +6 +5, +4, Output: 1 +1 +2 +3 +4+4 +5 +6. Implement pseudo code for function Merge-K(1) where l is [l1, l2, ..., lk]. 11 to lk are linked lists.

  • (25pts) You are given two sorted lists of size m and n. Give an O(log m...

    (25pts) You are given two sorted lists of size m and n. Give an O(log m log n) time algorithm for computing the k-th smallest element in the union of the two lists Note that the only way you can access these values is through queries to the databases. Ina single query, you can specify a value k to one of the two databases, and the chosen database will return the k-th smallest value that it contains. Since queries are...

  • Design an O(n) algorithm that determines whether or not there is a majority in a list...

    Design an O(n) algorithm that determines whether or not there is a majority in a list of elements. For example, [3,2,1] is NO and [3,1,3] is YES. I want an answer that doesn't require the use of dictionaries/hash maps. It cannot be "Moore's voting algorithm" or a variation of it. The algorithm also can not use linear sorting algorithms because the input can not be assumed to satisfy the required conditions for any of the linear sorting algorithms my professor...

  • help in design of algorithm answers with steps for study guide (2 points) Why shouldn't we...

    help in design of algorithm answers with steps for study guide (2 points) Why shouldn't we measure time efficiency based on the number of seconds or milliseconds it takes the algorithm 1. to run? is the number of times the most important operation of the (2 points) The 2. algorithm occ Ccurs (3 points) Find the binary representation of the following numbers: 3. BINARY REPRESENTATION (in bits) NUMBER 777 14 684,739 4. (8 points) Write the input size metric and...

  • 2. Design a deterministic algorithm to solve the following problem. input: A directed acyclic graph G...

    2. Design a deterministic algorithm to solve the following problem. input: A directed acyclic graph G = (V, E) stored using adjacency lists. output: A Hamiltonian path, if such a path exists. Otherwise, return NONE. Your algorithm must take O(|V| + |E|) time. You must describe your algorithm in plain English (no pseudocode) and you must explain why the running time of your algorithm is O(|V| + |E|). Maximum half a page

  • Problem 1: Let W(n) be the number of times "whatsup" is printed by Algorithm WHATSUP (see below) ...

    Problem 1: Let W(n) be the number of times "whatsup" is printed by Algorithm WHATSUP (see below) on input n. Determine the asymptotic value of W(n). Algorithm WHATSUP (n: integer) fori1 to 2n do for j 1 to (i+1)2 do print("whatsup") Your solution must consist of the following steps: (a) First express W(n) using summation notation Σ (b) Next, give a closed-form formula for W(n). (A "closed-form formula" should be a simple arithmetio expression without any summation symbols.) (c) Finally,...

  • 3. (20 pts.) You are given two sorted lists of numbers with size m and n....

    3. (20 pts.) You are given two sorted lists of numbers with size m and n. Give an O(logn+ logm) time algorithm for computing the k-th smallest element in the union of the two lists. 4. (20 pts.) Solve the following recurrence relations and give a bound for each of them. CMPSC 465, Fall 2019, HW 2 (a) T(n) = 117(n/5)+13n!.3 (b) T(n) = 2T (n/4)+nlogn (c) T(n) = 5T (n/3) +log-n (d) T(n) = T(n/2) +1.5" (e) T(n) =...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT