Question

In: Computer Science

1. Given three arrays of N names each, describe an O(nlogn) algorithm to determine if there...

1. Given three arrays of N names each, describe an O(nlogn) algorithm

to determine if there is any name common to all three arrays, and if so, return the first such name.?

2. Given an input array with all equal values, compare the following sorting algorithm using big-O notation.

Running Time

Space Complexity

Merge Sort

Quick Sort

Heap Sort

Solutions

Expert Solution

The following algorithm takes O(NlogN) in sorting and O(N +N +N) in finding the intersection of three arrays. Thus the total running time is O(NlogN), taking the dominant term.

The solution for 2. part is below: Note: the answers depend heavily on the implementation of the sorting algorithms.  


Related Solutions

Triplicates. Given three lists of N names each, devise a linearithmic algorithm to determine if there...
Triplicates. Given three lists of N names each, devise a linearithmic algorithm to determine if there is any name common to all three lists, and if so, return the first such name
Design an O(nlogn) algorithm that takes two arrays A and B (not necessarily sorted) of size...
Design an O(nlogn) algorithm that takes two arrays A and B (not necessarily sorted) of size n of real numbers and a value v. The algorithm returns i and j if there exist i and j such that A[i] + B[j] = v and no otherwise. Describe your algorithm in English and give its time analysis.
Given an array A of n integers, describe an O(n log n) algorithm to decide if...
Given an array A of n integers, describe an O(n log n) algorithm to decide if the elements of A are all distinct. Why does your algorithm run in O(n log n) time?
Design an O(n log n) algorithm that takes two arrays A and B (not necessarily sorted)...
Design an O(n log n) algorithm that takes two arrays A and B (not necessarily sorted) of size n of real numbers and a value v. The algorithm returns i and j if there exist i and j such that A[i] + B[j] = v and no otherwise. Describe your algorithm in English and give its time analysis.
Q1. A. What is the complexity of partition process in quick sort? O(1) O(logN) O(N) O(NlogN)...
Q1. A. What is the complexity of partition process in quick sort? O(1) O(logN) O(N) O(NlogN) B. Evaluate the following postfix expression. 2 3 4 + * C. In an array representation of heap, what are the parent node of a node a[10]? a[9] a[11] a[5] a[20] There is no easy way to access parent node in such representation. D. In an array representation of heap, what are the children nodes (if any) of a node a[10]? a[11] and a[12]...
Describe an O(n)-time algorithm that checks if brackets in a given arithmetic expression is properly placed,...
Describe an O(n)-time algorithm that checks if brackets in a given arithmetic expression is properly placed, i.e., all left brackets are matched with their right counterparts and there are no unmatched brackets between any pair of matched brackets. Note that there are generally more than one types of brackets and only those of the same type can match against each other. For simplicity, you can assume that all operands are represented as ‘a’ and addition, +, is the only available...
(Linear time algorithm for finding duplicates of two sorted arrays, 20pt) Devise a linear time O(m+n)...
(Linear time algorithm for finding duplicates of two sorted arrays, 20pt) Devise a linear time O(m+n) algorithm to find the duplicates between two sorted arrays (m, n are the sizes of two arrays). For instance, for inputs {1,3,5,7} and {1,2,3,4}, the correct outputs should be {1,3
Algorithm problem 4 [3.1-4] Is (2^(n+1))∈O(2^n)? Is (2^(2n))∈O(2^n)?
Algorithm problem 4 [3.1-4] Is (2^(n+1))∈O(2^n)? Is (2^(2n))∈O(2^n)?
Give an O(lg n)-time EREW algorithm that determines for each object in an n-object list whether...
Give an O(lg n)-time EREW algorithm that determines for each object in an n-object list whether it is the middle (n/2 th) object.
prove using limit lemma that n^2 > nlogn given some epsilon > 0
prove using limit lemma that n^2 > nlogn given some epsilon > 0
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT