2) When evaluating an algorithm, which of the following most likely contributes to the efficiency of the algorithm?
a) The name of the input file
b) The number of primitive variables in the program
c) The number of arrays in the program
d) The number of loops in the process
e) All of these are likely to contribute to the efficiency of the algorithm
3) A loop body is controlled by the following statement:
for (int count = 2; count <= n; count *=2)
If the statements in the body of the loop are all O(1), what is the order of the loop?
4) In an ideal implementation of a stack, the operations push() is ______________________ .
c) O(n log n)
e) it depends on the operation
5) When a linked list is created initially, how many element(s) does it have?
e) however many the programmer specified when the linked list was instantiated.
6) Traversing a linked list is
a) the process of deleting the list
b) the process of visiting every node for some purpose
c) the process of removing every node, one at a time
d) the process of creating a new linked list with twice the capacity
e) none of the above
7) A(n) _____________________ is a list collection has elements that are not ordered by a characteristic of the elements.
a) ordered list
b) unordered list
c) indexed list
d) linked list
8) What is returned if you call find method in a linked list?
a) the element that was found
b) a true or false value indicating whether the element was found
c) an integer number
d) the element whose reference variable points to the element that was found
e) the top element of the linked list
9) The search operation of an unordered list collection is
b) O(log n)
d) O(n log n)
10) The delete operation of an unordered list collection is
b) O(log n)
d) O(n log n)
Part 2: True/False questions. Fill T or F in the table below.
Questions 1 2 3 4 5 6 7 8
1) If the growth function for an algorithm is expressed as polynomial terms, then the asymptotic complexity of the algorithm is determined by the term with the smallest exponent of the variable.
2) The asymptotic complexity, time complexity and order of an algorithm are the same concept.
3) All of the terms in a growth function(polynomial expression) contribute to the order of the function
4) An object can only contain one field that is a reference to another object of the same type.
5) Using the rear of the linked list as the top of the stack is the most efficient way to manage the stack.
6) It is possible to push an element to an empty stack.
7) An array and an indexed list are completely the same.
8) Time complexity is more important than space complexity when we design algorithms.
Part 3: answer the questions.
What is the order of the following growth functions?(Hint: consider when n is large.)
8n² + 10n + 10000000
3n + 100n⁴
7n log n
Sort the time complexities of question 1.( Hint: consider when n is large. Sort them from most efficient to least efficient. )
Determine the growth function and order of the following code fragment:
for (int count = 0; count < n*n; count ++)
for (int count2 = 0; count2 < n; count2 = count2 + 5)
These solutions may offer step-by-step problem-solving explanations or good writing examples that include modern styles of formatting and construction of bibliographies out of text citations and references. Students may use these solutions for personal skill-building and practice. Unethical use is strictly forbidden.Question 1: The answer is option D.
Question 2: The answer is option D.
Question 3: The answer is option A....
By purchasing this solution you'll be able to access the following files: