Question

Which of the following statements is true? The best way to study algorithm efficiency is to...

  1. Which of the following statements is true?

    The best way to study algorithm efficiency is to see how many milliseconds it takes to execute a program
    All O(log n) sort algorithms will use the same number of CPU cycles to sort identical arrays
    Big O notation is not useful for estimating the specific number of CPU cycles an algorithm will require
    A program will take the same number of millseconds to execute an algorithm each time it is run for the same data

  2. We can use the assumption T(1) = 1 because

    We express complexity in relationship to 1 millisecond.
    Every algorithm performs exactly one operation when n is 1
    Since we are interested mostly in how the time required increases with n, we can arbitrarily call T(1) 1 unit of time without worrying about its actual value
    Most Java operators require 1 CPU cycle to execute

  3. (Use Excel for this one if you'd like)

    Suppose n = 35. Which of the following statements is true?

    n log n is greater than 200
    n squared is greater than 2000
    log n is greater than 6
    2 ^ n is greater than 30 billion

  4. Which of the following statements is true?

    You should choose an O(n log n) algorithm over an O(n ^ 2) algorithm
    You should choose an O(n log n) algorithm over an O(n) algorithm
    You should choose an O(n) algorithm over an O(1) algorithm
    You should choose an O(n log n) algorithm over an O(log n) algorithm

  5. (If you don't see how to do this question, see the lecture slide on summations.)

    1 + 2 + 3 + 4 + 5 + ... 30 =

    930
    465
    30
    -2147483648

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

Which of the following statements is true?

You should choose an O(n log n) algorithm over an O(n ^ 2) algorithm ---> TRUE

Explanation: For all values of n, an O(n log n) takes less time than O(n2) algorithm and is more efficient.


You should choose an O(n log n) algorithm over an O(n) algorithm ---> False

Explanation: For all values of n, an O(n log n) takes more time than O(n) algorithm and is less efficient.

You should choose an O(n) algorithm over an O(1) algorithm ---> FALSE

Explanation: For all values of n, an O(n) takes more time than O(1) algorithm and is less efficient.

You should choose an O(n log n) algorithm over an O(log n) algorithm ---> TRUE

Explanation: For all values of n, an O(n log n) takes more time than O(log n) algorithm and is less efficient.

1 + 2 + 3 + 4 + 5 + ... 30 = 30 * 31/2 (Since sum of first n natural numbers is n(n+1)/2)

= 465

NOTE: As per Chegg policy, I am allowed to answer only 4 questions (including sub-parts) on a single post. I have gone ahead and answered 5. Kindly post the remaining questions separately and I will try to answer them. Sorry for the inconvenience caused.

Add a comment
Know the answer?
Add Answer to:
Which of the following statements is true? The best way to study algorithm efficiency is to...
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
  • State if each of the statements is true or false. Assume that n is a positive...

    State if each of the statements is true or false. Assume that n is a positive integer. log(n!) always grows faster than n2. The greater the number of terms that are added in the expression for the running time of an algorithm, the higher the time complexity of the algorithm. log(n) always grows faster than n. log(log(n)) grows slower than log(n) when both log(log(n)) and log(n) are positive. log(kn) where k is a positive constant, is O(n).

  • Which of the following statements about the Merge Sort algorithm is True? Select one: Merge Sort...

    Which of the following statements about the Merge Sort algorithm is True? Select one: Merge Sort uses list concatenation to join sublists. Merge Sort runs in O(na) time. Merge Sort only works if the input list is in sorted order. O Merge Sort will take longer to sort a given list into descending order than into ascending order. None of the above, they are all False.

  • Algorithm 1: built-in sort The first algorithm you must implement is in builtin_sort, which must use...

    Algorithm 1: built-in sort The first algorithm you must implement is in builtin_sort, which must use the std::sort or qsort functions built into C++ to sort a vector of words. The function should sort the vector in-place, so it takes the vector as a non-const reference and returns void. This function may only need to be one line long. Both std::sort and qsort have time complexity O(n n). In addition, since these are widely-used library functions, developers have put a...

  • Algorithm Analysis: Study the following sorting algorithm.    SORT( A[1...n]) bound <- Length(A) -1 for i...

    Algorithm Analysis: Study the following sorting algorithm.    SORT( A[1...n]) bound <- Length(A) -1 for i <- 1 to Length(A) newbound <- 0 for j <- 0 to bound    if A[j] > A[j + 1]    swap( A[j], A[j + 1] ) newbound = j -1 bound <- newbound (a) Use the longer approach described in lecture 3 week 1 that we used in analyzing Insertion-Sort to compute the running time T(n) of the above SORT algorithm. You may...

  • 1.3 ​Which of the following is true about sorting functions?A.The most optimal partitioning policy for quicksort...

    1.3 ​Which of the following is true about sorting functions?A.The most optimal partitioning policy for quicksort on an array we know nothing about wouldbe selecting a random element in the array.B.The fastest possible comparison sort has a worst case no better than O(​n​ log ​n​).C.Heapsort is usually best when you need a stable sort.D.Sorting an already sorted array of size ​n​ with quicksort takes O(​n​ log ​n​) time.E.When sorting elements that are expensive to copy, it is generally best to...

  • 3. For each of the following situations, name the best sorting algorithm we studied. (For one...

    3. For each of the following situations, name the best sorting algorithm we studied. (For one or two questions, there may be more than one answer deserving full credit, but you only need to give one answer for each.) The array is mostly sorted already (a few elements are in the wrong place). (a) You need an O(n log n) sort even in the worst case and you cannot use any extra space except for a few local variables. (b)...

  • Please answer ASAP Thank You 1Consider an algorithm that requires the following number of operations (time...

    Please answer ASAP Thank You 1Consider an algorithm that requires the following number of operations (time units) for these input sizes (n). The algorithm is ___________ . Input size Operations 100 100,000 400 100,000 1600 100,000 Group of answer choices 1.O(n2) 2.O(n) 3.O(log n) 4.O(n3) 5.O(1) 2The below algorithm contains nested loops. for (int total = 1; total <= n; total++) { for (int samples = 0; samples < n; samples++) { for (int location = 1; location < 10;...

  • 1. Consider the Viterbi algorithm. Which of the following statements is/are true. if any? (i) It...

    1. Consider the Viterbi algorithm. Which of the following statements is/are true. if any? (i) It is an algorithmused for optimal thresholding (ii) It is an algorithm to find shortest paths in on a network (ii)It is an algorithm to detect lines in images (a) (i) (b) (ii) (c) (ii) (d) All of the above (e) None of the above 4. If we apply a binary opening to the same object twice using the same structuring element, the effect. if...

  • Short Answer. Respond to each of the following True or False statements. Explain your answers. a-...

    Short Answer. Respond to each of the following True or False statements. Explain your answers. a- The user of a LinkedList needs to understand how to work with Nodes. b- The user of an ArrayList needs to understand arrays. c- An OrderedList is an Abstract Data Type (ADT). d- A O(n2) sorting algorithm should never be used when there are O(n log n) sorting algorithms to choose from. e- An ArrayList will work anywhere a LinkedList would work.

  • Data Structures: For each of the following situations, name the best sorting algorithm we studied. (For...

    Data Structures: For each of the following situations, name the best sorting algorithm we studied. (For one or two questions, there may be more than one answer deserving full credit, but you only need to give one answer for each.) (a) The array is mostly sorted already (a few elements are in the wrong place). (b) You need an O(n log n) sort even in the worst case and you cannot use any extra space except for a few local...

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