QuestionQuestion

1) A growth function that is O(n²) is ____________________
a) constant
b) logarithmic
c) linear
d) quadratic
e) exponential

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?
a) O(lgn)
b) O(1)
c) O(n)
d) O(n²)
e) O(2ⁿ)

4) In an ideal implementation of a stack, the operations push() is ______________________ .
a) O(n)
b) constant
c)   O(n log n)
d)   O(n²)
e)   it depends on the operation

5) When a linked list is created initially, how many element(s) does it have?
a) 0
b) 10
c) 100
d) 1000
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
e) array

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
a) O(1)
b) O(log n)
c) O(n²)
d) O(n log n)
e) O(n)

10) The delete operation of an unordered list collection is
a) O(1)
b) O(log n)
c) O(n²)
d) O(n log n)
e) O(n)

Part 2: True/False questions. Fill T or F in the table below.
Questions 1 2 3 4 5 6 7 8
Answers

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
4n¹.⁵+100

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)
{
System.out.println(count, count2);
                        sum=sum+count+count2;
}
}

Solution PreviewSolution Preview

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:
Solution.docx.

$18.45
for this solution

or FREE if you
register a new account!

PayPal, G Pay, ApplePay, Amazon Pay, and all major credit cards accepted.

Find A Tutor

View available Java Programming Tutors

Get College Homework Help.

Are you sure you don't want to upload any files?

Fast tutor response requires as much info as possible.

Decision:
Upload a file
Continue without uploading

SUBMIT YOUR HOMEWORK
We couldn't find that subject.
Please select the best match from the list below.

We'll send you an email right away. If it's not in your inbox, check your spam folder.

  • 1
  • 2
  • 3
Live Chats