Question

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 dont need to submit any implementation in Java. Only the pseudocode of your algorithm is required.
0 0
Add a comment Improve this question Transcribed image text
Answer #1

2. utan bup thuat eamat b 3) uo 02

Add a comment
Know the answer?
Add Answer to:
Problem #1: (15 points) You have two sorted lists of integers, L, and L2. You know...
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
  • In need of help to solve this problem. Theory 1. Assume you are given two linear...

    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.

  • (a) Write a program in Java to implement a recursive search function int terSearch(int A[], int...

    (a) Write a program in Java to implement a recursive search function int terSearch(int A[], int l, int r, int x) that returns the location of x in a given sorted array of n integers A if x is present, otherwise -1. The terSearch search function, unlike the binary search, must consider two dividing points int d1 = l + (r - l)/3 int d2 = d1 + (r - l)/3 For the first call of your recursive search function...

  • Consider the following problem: Input: a list of n-1 integers and these integers are in the...

    Consider the following problem: Input: a list of n-1 integers and these integers are in the range of 1 to n. There are no duplicates in list. One of the integers from 1 to n is missing in the list. Output: find the missing integer Let the input array be [2, 4, 1, 6, 3, 7, 8]. Elements in this list are in the range of 1 to 8. There are no duplicates, and 5 is missing. Your algorithm needs...

  • 1. Please write a Divide-and-Conquer Java algorithm solving the following problem: Given an "almost sorted" array...

    1. Please write a Divide-and-Conquer Java algorithm solving the following problem: Given an "almost sorted" array of distinct integers, and an integer x, return the index of x in the array. If the element x is not present in the array, return -1. "Almost sorted" means the following. Assume you had a sorted array A[0…N], and then split it into two pieces A[0…M] and A[M+1…N], and move the second piece upfront to get the following: A[M+1]…A[N]A[0]…A[M]. Thus, the "almost sorted"...

  • Answer B java Problem 2 For each problem given below, do the following: 1. Create an...

    Answer B java Problem 2 For each problem given below, do the following: 1. Create an algorithm in pseudocode to solve the problem. 2.Identify the factors that would influence the running time of your algorithm. For example, if your algorithm is to search an array the factor that influences the running time is the array size. Assign names (such as n) to each factor. 3. Determine the number of operations in each step of the pseudocode. To do that, identify...

  • Problem 3 (15 points). Let G (V,E) be the following directed graph. a. 1. Draw the...

    Problem 3 (15 points). Let G (V,E) be the following directed graph. a. 1. Draw the reverse graph G of G. 2. Run DFS on G to obtain a post number for each vertex. Assume that in the adjacency list representation of G, vertices are stored alphabetically, and in the list for each vertex, its adjacent vertices are also sorted alphabetically. In other words, the DFS algorithm needs to examine all vertices alphabetically, and when it traverses the adjacent vertices...

  • (a) Your company participates in a competition and the fastest algorithm wins. You know of two...

    (a) Your company participates in a competition and the fastest algorithm wins. You know of two different algorithms that can solve the problem in the competition. • Algorithm I solves problems by dividing them into five subproblems of half the size, recursively solving each subproblem, and then combining the solutions in linear time. • Algorithm 2 solves problems of size n by dividing them into 16 subproblems of size n/4, recursively solving each subproblem, and then combining the solutions in...

  • 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...

  • Suppose you are given an array of n integers ai, az, ..., an. You need to...

    Suppose you are given an array of n integers ai, az, ..., an. You need to find out the length of its longest sub-array (not necessarily contiguous) such that all elements in the sub-array are sorted in non-decreasing order. For example, the length of longest sub-array for (5, 10, 9, 13, 12, 25, 19, 30) is 5 and one such sub-array is (5, 10, 13, 19, 303. Note you may have multiple solutions for this case. Use dynamic programming to...

  • Suppose you are given an array of n integers a1, a2, ..., an. You need to...

    Suppose you are given an array of n integers a1, a2, ..., an. You need to find out the length of its longest sub-array (not necessarily contiguous) such that all elements in the sub-array are sorted in non-decreasing order. For example, the length of longest sub-array for {5, 10, 9, 13, 12, 25, 19, 70} is 6 and one such sub-array is {5, 10, 13, 19, 70}. Note you may have multiple solutions for this case. Use dynamic programming to...

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