Question

In: Physics

Suppose we have an array A that contains a prime numbers from 2 to 200 in...

Suppose we have an array A that contains a prime numbers from 2 to 200 in sorted order. How many items of the array A would the binary search algorithm have to examine before concluding that 60 is not in the array A?

  1. 30
  2. 200
  3. 100
  4. 6

2-

Suppose we have an array that contains 182 village name. These names are sorted alphabetically. How many names would binary search algorithm examine to locate a particular name in the array, in the worst case?

  1. No more than 182
  2. No more than 91
  3. No more than 8

3-

Suppose we have the following array A of numbers:

A= [55, 10, 27, 65, 29, 28, 2, 9, 16, 49, 39, 30, 43, 34, 46, 60]

After 3 recursive calls to the Mergesort algorithm, choose from the following answers which one illustrates the list to be sorted?

  1. [16, 49, 39, 30, 43, 34, 46, 60]
  2. [55,10]
  3. [55, 10, 27, 65]
  4. [55]

4-

Suppose we have an array B= [13, 16, 12, 14, 18, 9, 2, 15, 8, 11]

Choose from the following answers which one shows the contents of the array after the second partition using the quicksort algorithm (Hoare algorithm)?

  1. [13, 16, 12, 14, 18]
  2. [8, 2, 9, 12, 11]
  3. [8, 2, 9, 12, 11, 13, 18, 15, 16, 14]
  4. [8, 2, 9, 12, 11, 13]
  5. [8,2,9,12,11,13,18,15,14,16]

5-

Suppose we have an array B= [13, 16, 12, 14, 18, 9, 2, 15, 8, 11]

Choose from the following answers which one could be the first pivot element using the Hoare algorithm?

  1. 13
  2. 11
  3. 18

6-

Suppose we have an array B= [13, 16, 12, 14, 18, 9, 2, 15, 8, 11]

Choose from the following answers which one could be the first pivot element using Lomuto algorithm?

  1. 13
  2. 11
  3. 18

Solutions

Expert Solution


Related Solutions

Suppose that all the numbers in an array are located in an interval [0,12], and we...
Suppose that all the numbers in an array are located in an interval [0,12], and we need to find the largest element with accuracy ε = 0.8. How many iterations will you need if we use the quantum optimization algorithm? How many times do we need to apply Grover's algorithm? Trace the quantum optimization algorithm for the case when the actual largest element is a5 = 3.14
Write a python program to sum the prime numbers existing in an array . For instance...
Write a python program to sum the prime numbers existing in an array . For instance , if A = [4, 7, 12, 3, 9] the output should be 10
We have an array of numbers, and we start at index 0. At every point, we're...
We have an array of numbers, and we start at index 0. At every point, we're allowed to jump from index i to i+3, i+4, or stop where we are. We'd like to find the maximum possible sum of the numbers we visit. For example, for the array [14, 28, 79, -87, 29, 34, -7, 65, -11, 91, 32, 27, -5], the answer is 140. (starting at the 14, we jump 4 spots to 29, then 3 spots to 65,...
Consider this prime sieve in which an array of numbers of size N is created (i.e....
Consider this prime sieve in which an array of numbers of size N is created (i.e. int nums[10] = {2,3,4,5,6,7,8,9,10,11};) and initialized to contain counting numbers starting with 2. The sieve works by taking each number in the array, and “crossing out” (perhaps via a similar array of Booleans) multiples of that number. So beginning with 2, we would “cross out” 4, 6, 8, 10. Then repeat the process for 3, and so on. Numbers that are already “crossed out”...
2. Suppose we have the hypothesis test H0 : µ = 200 Ha : µ >...
2. Suppose we have the hypothesis test H0 : µ = 200 Ha : µ > 200 in which the random variable X is N(µ, 10000). Let the critical region C = {x : x ≥ c}. Find the values of n and c so that the significance level of this test is α = 0.03 and the power of µ = 220 is 0.96.
Find the biggest “*prime gap” (see definition) from the prime numbers between 1 and 1,000,000. *Prime...
Find the biggest “*prime gap” (see definition) from the prime numbers between 1 and 1,000,000. *Prime gap = the difference between two consecutive primes. The exercise can be completed manually or with a computer program. Whichever seems easiest.
5. (20%) Suppose we have an array int a [8] = {1, 2, 3, 5, 6};...
5. (20%) Suppose we have an array int a [8] = {1, 2, 3, 5, 6}; and we also have a linked list L of 5 entries 1 -> 2 -> 3 -> 5 -> 6, where 1 is the first in the linked list L, followed by 2 etc. We want to put a new item 4 between 3 and 5 in the array a and in the linked list L (a) Explain in plain English how you do...
Suppose the sample space of an experiment is the set of prime numbers. Is it possible...
Suppose the sample space of an experiment is the set of prime numbers. Is it possible for all outcomes to be equally likely? Why? Is it possible for all outcomes to have nonzero probability? Explain.
Given an array A of n distinct real numbers, we say that a pair of numbers...
Given an array A of n distinct real numbers, we say that a pair of numbers i, j ∈ {0, . . . , n−1} form an inversion of A if i < j and A[i] > A[j]. Let inv(A) = {(i, j) | i < j and A[i] > A[j]}. Answer the following: (a) How small can the number of inversions be? Give an example of an array of length n with the smallest possible number of inversions. (b)...
Given an array A of n distinct numbers, we say that a pair of numbers i,...
Given an array A of n distinct numbers, we say that a pair of numbers i, j ∈ {0, . . . , n − 1} form an inversion of A if i < j and A[i] > A[j]. Let inv(A) = {(i, j) | i < j and A[i] > A[j]}. Define the Inversion problem as follows: • Input: an array A consisting of distinct numbers. • Output: the number of inversions of A, i.e. |inv(A)|. Answer the following:...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT