Question

In need of help to solve this problem.

Theory 1. Assume you are given two linear lists LI and L2 with nl, n2 elements, respectively. Consider the problem of determining whether any element of L is an element of L2 (not value, element!) (a) Derive a lower bound for this problem. (b) Design an algorithm for this problem. Derive its time complexity. It should be as close to your lower bound as possible.

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

(a) Lower bound must be O(n1 + n2) as you need to see each element at least once.

(b)

Find(e1) { // where e1 is an element in L1

for each element E in L2 do

hash = HashFunction(E);

HashTable[hash] = E;

done

hash = HashFunction(e1);

if (HashTable[hash] == e1)

printf "element found"

else

print "element not found"

return

}

Add a comment
Know the answer?
Add Answer to:
In need of help to solve this problem. Theory 1. Assume you are given two linear...
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
  • Assume you are given two linear lists of size n each; consider the problem of determining...

    Assume you are given two linear lists of size n each; consider the problem of determining whether any element of one list is an element of the other (not value, element). Derive a lower bound for this problem and design an algorithm for this problem. Derive its time complexity. It should be as close the lower bound as possible. My work so far: //Copy list n1 into n3 int n3[n]; for(int I = 0; I < n; i++)n3[i] = n1[i];...

  • Problem #1: (15 points) You have two sorted lists of integers, L, and L2. You know...

    Problem #1: (15 points) You have two sorted lists of integers, L, and L2. You know the lengths of each list, L1 has length N, and L2 has length N2 (a) Design an efficient algorithm (only pseudocode) to output a sorted list L L2 (the intersection of L and L2). (b) If you know that N2> Ni. What is the running time complexity of your algorithm? Justify Important Note For this problem, you don't need to submit any implementation in...

  • You have two sorted lists of integers, L1 and L2. You know the lengths of each...

    You have two sorted lists of integers, L1 and L2. You know the lengths of each list, L1 has length N1 and L2 has length N2. (a) Design an efficient algorithm (only pseudocode) to output a sorted list L1 ∩ L2 (the intersection of L1 and L2). (b) If you know that N2 > N1. What is the running time complexity of your algorithm? Justify. Important Note: For this problem, you don’t need to submit any implementation in Java. Only...

  • 1)Given two lists L1 and L2, create a new list L3 consisting of the first element...

    1)Given two lists L1 and L2, create a new list L3 consisting of the first element of L1 and the last element of L2. For example, if L1=[1,2,3] and L2=["a","b","c"], L3 should be [1,"c"] 2)given a string s, create a new string odd_letters that contains only the odd letters of s (two ways to solve this problem are to use slicing, or a while or for loop), i.e. starting at the first letter or the zeroth index: if s="banana", odd_letters...

  • 1. [5 marks Show the following hold using the definition of Big Oh: a) 2 mark...

    1. [5 marks Show the following hold using the definition of Big Oh: a) 2 mark 1729 is O(1) b) 3 marks 2n2-4n -3 is O(n2) 2. [3 marks] Using the definition of Big-Oh, prove that 2n2(n 1) is not O(n2) 3. 6 marks Let f(n),g(n), h(n) be complexity functions. Using the definition of Big-Oh, prove the following two claims a) 3 marks Let k be a positive real constant and f(n) is O(g(n)), then k f(n) is O(g(n)) b)...

  • problem 2 can use Det-Selection(A, p, q, r) as a sub-routine (i.e, you don't need to...

    problem 2 can use Det-Selection(A, p, q, r) as a sub-routine (i.e, you don't need to write its pseudo-code). To sort an array A, you will then call Det-QuickSort(A, 1, n). You also need to provide the worst case time complexity analysis of your algorithm. 2. (20 points) Given a set of n distinct numbers, we wish to find the k largest in sorted order using a comparison-based algorithm. Give an algorithm that implements each of the following methods, and...

  • Problem 4.2. Please only do 4.2, I only need help with 4.2 Only 4.2 please ....

    Problem 4.2. Please only do 4.2, I only need help with 4.2 Only 4.2 please . OVERFITTING 4.4 Problems pict the monomials of order i, фі(x-a". As you increase correspond to the intuitive notion of increasing complexity? Prob Problem 4.2 Consider the feature transform z = Lo(2), L1(x), L2(zr and the linear model h(x) w'z. For the hypothesis with w [1,-1, 1 what is h(z) explicitly as a function of z? What is its degree? Problem 4.3 The Legendre Polynomials...

  • Hey I just need help on Problem 4 for the system (b-f) from Problem 2. Please...

    Hey I just need help on Problem 4 for the system (b-f) from Problem 2. Please explain steps by steps so I can understand properly, thanks EE306 Hwi Problem 1 A discrete-time signal (efnl) is shown in the figure below. Sketch and label carefally euch of the following signals. (a) (n-1).(oa-3) (d) (xinl) (Imm pulie Rerans e Problem 2 Plot the impulse response of each of the following systems. Make sure to specify the amplitude value of every sample. Use...

  • X=0 x = 1/2 x= L u U2 Uz (a) Trial solution for a 1-D quadratic...

    X=0 x = 1/2 x= L u U2 Uz (a) Trial solution for a 1-D quadratic elastic bar element can be written as follows: ū(x) = [N]{u} where, [N] = [N1 N2 N3] and {u} u2 13 1 and Ni L2 L2 [N] and {u} are known as interpolation function matrix and nodal displacement, respectively. (272 – 3L + L´), N= = (22- La), Ns = 12 (2=– LE) Derive the expression for element stiffness matrix, (Kelem) and element force...

  • Suppose we are given two sorted arrays (nondecreasing from index 1 to index n) X[1] ·...

    Suppose we are given two sorted arrays (nondecreasing from index 1 to index n) X[1] · · · X[n] and Y [1] · · · Y [n] of integers. For simplicity, assume that n is a power of 2. Problem is to design an algorithm that determines if there is a number p in X and a number q in Y such that p + q is zero. If such numbers exist, the algorithm returns true; otherwise, it returns false....

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