Deck 10: Algorithm Efficiency and Sorting

ملء الشاشة (f)
exit full mode
سؤال
A quadratic algorithm has the growth-rate function ______.

A)O(n²)
B)O(n³)
C)O(2ⁿ)
D)O(log2ⁿ)
استخدم زر المسافة أو
up arrow
down arrow
لقلب البطاقة.
سؤال
Which of the following can be used to compare two algorithms?

A)growth rates of the two algorithms
B)implementations of the two algorithms
C)test data used to test programs which implement the two algorithms
D)computers on which programs which implement the two algorithms are run
سؤال
Algorithm efficiency is typically a concern for ______.

A)small problems only
B)large problems only
C)medium sized problems only
D)problems of all sizes
سؤال
Assuming a linked list of n nodes,the code fragment: Node curr = head;
While (curr != null){
System.out.println(curr.getItem());
Curr.setNext(curr.getNext());
} // end while
Requires ______ comparisons.

A)n
B)n - 1
C)n + 1
D)1
سؤال
Which of the following growth-rate functions indicates a problem whose time requirement is independent of the size of the problem?

A)O(n)
B)O(log2ⁿ)
C)O(2ⁿ)
D)O(1)
سؤال
A linear algorithm has the growth-rate function ______.

A)O(log2ⁿ)
B)O(2ⁿ)
C)O(n)
D)O(1)
سؤال
Given the statement: Algorithm A requires time proportional to f(n)
Algorithm A is said to be ______.

A)in class f(n)
B)of degree f(n)
C)order f(n)
D)equivalent to f(n)
سؤال
Assuming a linked list of n nodes,the code fragment: Node curr = head;
While (curr != null){
System.out.println(curr.getItem());
Curr.setNext(curr.getNext());
} // end while
Requires ______ write operations.

A)n
B)n - 1
C)n + 1
D)1
سؤال
The value of which of the following growth-rate functions grows the fastest?

A)O(n)
B)O(n²)
C)O(1)
D)O(log2ⁿ)
سؤال
An algorithm's execution time is related to the number of ______ it requires.

A)parameters
B)test data sets
C)data fields
D)operations
سؤال
If a problem of size n requires time that is directly proportional to n,the problem is ______.

A)O(1)
B)O(n)
C)O(n²)
D)O(2ⁿ)
سؤال
Consider an algorithm that contains loops of the form: for (x = 1 through n ){
For (y = 1 through x){
For (z = 1 through 10){
Task T
} // end for
} // end for
} // end for
If task T requires t time units,the loop on y requires ______ time units.

A)10 * t
B)(10 * t)+ x
C)10 * t * x
D)t * x
سؤال
An exponential algorithm has the growth-rate function ______.

A)O(n²)
B)O(n³)
C)O(2ⁿ)
D)O(log2ⁿ)
سؤال
A growth-rate function of ______ implies a problem whose time requirement is constant.

A)1
B)n
C)2ⁿ
D)log2ⁿ
سؤال
The solution to the Towers of Hanoi problem with n disks requires 2ⁿ - 1 moves.If each move requires the same time m,the solution requires ______ time units.

A)2ⁿ - 1
B)(2ⁿ - 1)+ m
C)(2ⁿ - 1)/ m
D)(2ⁿ - 1)* m
سؤال
Algorithm analysis should be independent of all of the following EXCEPT ______.

A)the programming style used in the implementation of the algorithm
B)the computer used to run a program which implements an algorithm
C)the number of significant operations in an algorithm
D)the test data used to test a program which implements an algorithm
سؤال
The value of which of the following growth-rate functions grows the slowest?

A)O(n)
B)O(n²)
C)O(1)
D)O(log2ⁿ)
سؤال
Consider an algorithm that contains loops of the form: for (x = 1 through n ){
For (y = 1 through x){
For (z = 1 through 10){
Task T
} // end for
} // end for
} // end for
If task T requires t time units,the innermost loop on z requires ______ time units.

A)y
B)10
C)z * t
D)10 * t
سؤال
Assuming a linked list of n nodes,the code fragment: Node curr = head;
While (curr != null){
System.out.println(curr.getItem());
Curr.setNext(curr.getNext());
} // end while
Requires ______ assignments.

A)n
B)n - 1
C)n + 1
D)1
سؤال
Which of the following is NOT part of the human cost of developing a computer program?

A)the efficiency of a program
B)the readability of a program
C)the modifiability of a program
D)the maintainability a program
سؤال
A bubble sort requires at most ______ passes to sort an array of n items.

A)n/2
B)n - 2
C)n - 1
D)n
سؤال
For large arrays,the insertion sort is prohibitively inefficient.
سؤال
In the worst case,a binary search is ______.

A)O(n)
B)O(1)
C)O(log2ⁿ)
D)O(n²)
سؤال
The efficiency of the selection sort depends on the initial arrangement of the data.
سؤال
Given the fact that a selection sort of n items requires n²/2 + 5 * n/2 - 3 major operations,the selection sort is ______.

A)O(n)
B)O(1)
C)O(n²)
D)O(n²/2)
سؤال
In the best case,a sequential search is ______.

A)O(n)
B)O(1)
C)O(log2ⁿ)
D)O(n²)
سؤال
The quicksort is ______ in the worst case.

A)O(n²)
B)O(n³)
C)O(n * log2ⁿ)
D)O(log2ⁿ)
سؤال
Low-order terms can be ignored in an algorithm's growth-rate function.
سؤال
The values of the growth-rate function O(log2ⁿ)grow faster than the values of the growth-rate function O(n).
سؤال
The mergesort is a recursive sorting algorithm.
سؤال
The ______ compares adjacent items and exchanges them if they are out of order.

A)selection sort
B)binary search
C)bubble sort
D)quicksort
سؤال
Given the following array: 4 15 8 3 28 21
Which of the following represents the array after the second swap of the selection sort?

A)4 3 8 15 21 28
B)4 15 8 3 21 28
C)3 4 8 15 21 28
D)21 4 3 8 15 28
سؤال
According to the following statements:
Algorithm A requires time proportional to n
Algorithm B requires time proportional to n2
algorithm B's time requirement - as a function of the problem size n - increases at a slower rate than algorithm A's time requirement.
سؤال
The recursive binary search algorithm is a logarithmic algorithm.
سؤال
Each merge step of the mergesort requires ______ major operations.

A)3 * n - 1
B)4 * n - 1
C)(n - 1)/2
D)n - 1
سؤال
In the worst case,the insertion sort's comparison occurs ______ times.

A)n
B)n - 1
C)(n - 1)/ 2
D)n * (n - 1)/2
سؤال
To sort numeric data,the radix sort treats a number as a character string.
سؤال
The analysis of an algorithm must take into consideration the computer that will be used to run a program that implements the algorithm.
سؤال
An algorithm's time requirements can be derived as a function of the problem size.
سؤال
The selection sort is continued until ______ of the n items in an array have been swapped.

A)n/2
B)n - 2
C)n - 1
D)n
سؤال
How does the quicksort partition an array?
سؤال
Compare the efficiencies of the quicksort and the mergesort in the worst case.
سؤال
What is determined by worst-case analysis?
سؤال
What is an external sort?
سؤال
What is the sort key of a record?
سؤال
What is the drawback of the mergesort with respect to storage?
سؤال
What is measured by an algorithm's growth rate?
سؤال
Suppose we have three algorithms,and their orders are O(n²),O(2ⁿ)and O(log2 n).Arrange these orders in increasing magnitude.
سؤال
Consider the following nested loop.What is the order of the algorithm?
for (int i = 0;i < n;++i)
for (int j = i;j < n;++j)
for (int k = 1;k < 100;++k)
سؤال
What measurements are parts of a program's efficiency?
سؤال
When choosing between two algorithms,under what conditions can the efficiencies of the algorithms be ignored?
سؤال
What is a growth-rate function?
سؤال
Suppose we wish to sort an array of 3-digit integers using radix sort.We will make three passes over the elements of the array.What occurs during the first pass?
سؤال
What does the area analysis of algorithms focus on?
سؤال
What is an internal sort?
سؤال
List the three factors which can cloud the comparison of algorithms performed by implementing the algorithms in Java and running the programs.
سؤال
If an algorithm requires 2ⁿ³ + 17n² + 54n + 512 operations to perform,where n is the size of the input data,then we say the order of the algorithm is O(_____).
سؤال
Consider the following nested loop.What is the order of the algorithm?
for (int i = 0;i < n;++i)
for (j = 1;j < n;j *= 2)
سؤال
What is determined by average-case analysis?
سؤال
In the worst case,how many comparisons are required in the bubble sort?
فتح الحزمة
قم بالتسجيل لفتح البطاقات في هذه المجموعة!
Unlock Deck
Unlock Deck
1/60
auto play flashcards
العب
simple tutorial
ملء الشاشة (f)
exit full mode
Deck 10: Algorithm Efficiency and Sorting
1
A quadratic algorithm has the growth-rate function ______.

A)O(n²)
B)O(n³)
C)O(2ⁿ)
D)O(log2ⁿ)
A
2
Which of the following can be used to compare two algorithms?

A)growth rates of the two algorithms
B)implementations of the two algorithms
C)test data used to test programs which implement the two algorithms
D)computers on which programs which implement the two algorithms are run
A
3
Algorithm efficiency is typically a concern for ______.

A)small problems only
B)large problems only
C)medium sized problems only
D)problems of all sizes
B
4
Assuming a linked list of n nodes,the code fragment: Node curr = head;
While (curr != null){
System.out.println(curr.getItem());
Curr.setNext(curr.getNext());
} // end while
Requires ______ comparisons.

A)n
B)n - 1
C)n + 1
D)1
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 60 في هذه المجموعة.
فتح الحزمة
k this deck
5
Which of the following growth-rate functions indicates a problem whose time requirement is independent of the size of the problem?

A)O(n)
B)O(log2ⁿ)
C)O(2ⁿ)
D)O(1)
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 60 في هذه المجموعة.
فتح الحزمة
k this deck
6
A linear algorithm has the growth-rate function ______.

A)O(log2ⁿ)
B)O(2ⁿ)
C)O(n)
D)O(1)
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 60 في هذه المجموعة.
فتح الحزمة
k this deck
7
Given the statement: Algorithm A requires time proportional to f(n)
Algorithm A is said to be ______.

A)in class f(n)
B)of degree f(n)
C)order f(n)
D)equivalent to f(n)
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 60 في هذه المجموعة.
فتح الحزمة
k this deck
8
Assuming a linked list of n nodes,the code fragment: Node curr = head;
While (curr != null){
System.out.println(curr.getItem());
Curr.setNext(curr.getNext());
} // end while
Requires ______ write operations.

A)n
B)n - 1
C)n + 1
D)1
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 60 في هذه المجموعة.
فتح الحزمة
k this deck
9
The value of which of the following growth-rate functions grows the fastest?

A)O(n)
B)O(n²)
C)O(1)
D)O(log2ⁿ)
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 60 في هذه المجموعة.
فتح الحزمة
k this deck
10
An algorithm's execution time is related to the number of ______ it requires.

A)parameters
B)test data sets
C)data fields
D)operations
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 60 في هذه المجموعة.
فتح الحزمة
k this deck
11
If a problem of size n requires time that is directly proportional to n,the problem is ______.

A)O(1)
B)O(n)
C)O(n²)
D)O(2ⁿ)
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 60 في هذه المجموعة.
فتح الحزمة
k this deck
12
Consider an algorithm that contains loops of the form: for (x = 1 through n ){
For (y = 1 through x){
For (z = 1 through 10){
Task T
} // end for
} // end for
} // end for
If task T requires t time units,the loop on y requires ______ time units.

A)10 * t
B)(10 * t)+ x
C)10 * t * x
D)t * x
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 60 في هذه المجموعة.
فتح الحزمة
k this deck
13
An exponential algorithm has the growth-rate function ______.

A)O(n²)
B)O(n³)
C)O(2ⁿ)
D)O(log2ⁿ)
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 60 في هذه المجموعة.
فتح الحزمة
k this deck
14
A growth-rate function of ______ implies a problem whose time requirement is constant.

A)1
B)n
C)2ⁿ
D)log2ⁿ
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 60 في هذه المجموعة.
فتح الحزمة
k this deck
15
The solution to the Towers of Hanoi problem with n disks requires 2ⁿ - 1 moves.If each move requires the same time m,the solution requires ______ time units.

A)2ⁿ - 1
B)(2ⁿ - 1)+ m
C)(2ⁿ - 1)/ m
D)(2ⁿ - 1)* m
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 60 في هذه المجموعة.
فتح الحزمة
k this deck
16
Algorithm analysis should be independent of all of the following EXCEPT ______.

A)the programming style used in the implementation of the algorithm
B)the computer used to run a program which implements an algorithm
C)the number of significant operations in an algorithm
D)the test data used to test a program which implements an algorithm
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 60 في هذه المجموعة.
فتح الحزمة
k this deck
17
The value of which of the following growth-rate functions grows the slowest?

A)O(n)
B)O(n²)
C)O(1)
D)O(log2ⁿ)
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 60 في هذه المجموعة.
فتح الحزمة
k this deck
18
Consider an algorithm that contains loops of the form: for (x = 1 through n ){
For (y = 1 through x){
For (z = 1 through 10){
Task T
} // end for
} // end for
} // end for
If task T requires t time units,the innermost loop on z requires ______ time units.

A)y
B)10
C)z * t
D)10 * t
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 60 في هذه المجموعة.
فتح الحزمة
k this deck
19
Assuming a linked list of n nodes,the code fragment: Node curr = head;
While (curr != null){
System.out.println(curr.getItem());
Curr.setNext(curr.getNext());
} // end while
Requires ______ assignments.

A)n
B)n - 1
C)n + 1
D)1
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 60 في هذه المجموعة.
فتح الحزمة
k this deck
20
Which of the following is NOT part of the human cost of developing a computer program?

A)the efficiency of a program
B)the readability of a program
C)the modifiability of a program
D)the maintainability a program
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 60 في هذه المجموعة.
فتح الحزمة
k this deck
21
A bubble sort requires at most ______ passes to sort an array of n items.

A)n/2
B)n - 2
C)n - 1
D)n
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 60 في هذه المجموعة.
فتح الحزمة
k this deck
22
For large arrays,the insertion sort is prohibitively inefficient.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 60 في هذه المجموعة.
فتح الحزمة
k this deck
23
In the worst case,a binary search is ______.

A)O(n)
B)O(1)
C)O(log2ⁿ)
D)O(n²)
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 60 في هذه المجموعة.
فتح الحزمة
k this deck
24
The efficiency of the selection sort depends on the initial arrangement of the data.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 60 في هذه المجموعة.
فتح الحزمة
k this deck
25
Given the fact that a selection sort of n items requires n²/2 + 5 * n/2 - 3 major operations,the selection sort is ______.

A)O(n)
B)O(1)
C)O(n²)
D)O(n²/2)
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 60 في هذه المجموعة.
فتح الحزمة
k this deck
26
In the best case,a sequential search is ______.

A)O(n)
B)O(1)
C)O(log2ⁿ)
D)O(n²)
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 60 في هذه المجموعة.
فتح الحزمة
k this deck
27
The quicksort is ______ in the worst case.

A)O(n²)
B)O(n³)
C)O(n * log2ⁿ)
D)O(log2ⁿ)
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 60 في هذه المجموعة.
فتح الحزمة
k this deck
28
Low-order terms can be ignored in an algorithm's growth-rate function.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 60 في هذه المجموعة.
فتح الحزمة
k this deck
29
The values of the growth-rate function O(log2ⁿ)grow faster than the values of the growth-rate function O(n).
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 60 في هذه المجموعة.
فتح الحزمة
k this deck
30
The mergesort is a recursive sorting algorithm.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 60 في هذه المجموعة.
فتح الحزمة
k this deck
31
The ______ compares adjacent items and exchanges them if they are out of order.

A)selection sort
B)binary search
C)bubble sort
D)quicksort
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 60 في هذه المجموعة.
فتح الحزمة
k this deck
32
Given the following array: 4 15 8 3 28 21
Which of the following represents the array after the second swap of the selection sort?

A)4 3 8 15 21 28
B)4 15 8 3 21 28
C)3 4 8 15 21 28
D)21 4 3 8 15 28
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 60 في هذه المجموعة.
فتح الحزمة
k this deck
33
According to the following statements:
Algorithm A requires time proportional to n
Algorithm B requires time proportional to n2
algorithm B's time requirement - as a function of the problem size n - increases at a slower rate than algorithm A's time requirement.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 60 في هذه المجموعة.
فتح الحزمة
k this deck
34
The recursive binary search algorithm is a logarithmic algorithm.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 60 في هذه المجموعة.
فتح الحزمة
k this deck
35
Each merge step of the mergesort requires ______ major operations.

A)3 * n - 1
B)4 * n - 1
C)(n - 1)/2
D)n - 1
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 60 في هذه المجموعة.
فتح الحزمة
k this deck
36
In the worst case,the insertion sort's comparison occurs ______ times.

A)n
B)n - 1
C)(n - 1)/ 2
D)n * (n - 1)/2
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 60 في هذه المجموعة.
فتح الحزمة
k this deck
37
To sort numeric data,the radix sort treats a number as a character string.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 60 في هذه المجموعة.
فتح الحزمة
k this deck
38
The analysis of an algorithm must take into consideration the computer that will be used to run a program that implements the algorithm.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 60 في هذه المجموعة.
فتح الحزمة
k this deck
39
An algorithm's time requirements can be derived as a function of the problem size.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 60 في هذه المجموعة.
فتح الحزمة
k this deck
40
The selection sort is continued until ______ of the n items in an array have been swapped.

A)n/2
B)n - 2
C)n - 1
D)n
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 60 في هذه المجموعة.
فتح الحزمة
k this deck
41
How does the quicksort partition an array?
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 60 في هذه المجموعة.
فتح الحزمة
k this deck
42
Compare the efficiencies of the quicksort and the mergesort in the worst case.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 60 في هذه المجموعة.
فتح الحزمة
k this deck
43
What is determined by worst-case analysis?
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 60 في هذه المجموعة.
فتح الحزمة
k this deck
44
What is an external sort?
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 60 في هذه المجموعة.
فتح الحزمة
k this deck
45
What is the sort key of a record?
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 60 في هذه المجموعة.
فتح الحزمة
k this deck
46
What is the drawback of the mergesort with respect to storage?
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 60 في هذه المجموعة.
فتح الحزمة
k this deck
47
What is measured by an algorithm's growth rate?
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 60 في هذه المجموعة.
فتح الحزمة
k this deck
48
Suppose we have three algorithms,and their orders are O(n²),O(2ⁿ)and O(log2 n).Arrange these orders in increasing magnitude.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 60 في هذه المجموعة.
فتح الحزمة
k this deck
49
Consider the following nested loop.What is the order of the algorithm?
for (int i = 0;i < n;++i)
for (int j = i;j < n;++j)
for (int k = 1;k < 100;++k)
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 60 في هذه المجموعة.
فتح الحزمة
k this deck
50
What measurements are parts of a program's efficiency?
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 60 في هذه المجموعة.
فتح الحزمة
k this deck
51
When choosing between two algorithms,under what conditions can the efficiencies of the algorithms be ignored?
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 60 في هذه المجموعة.
فتح الحزمة
k this deck
52
What is a growth-rate function?
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 60 في هذه المجموعة.
فتح الحزمة
k this deck
53
Suppose we wish to sort an array of 3-digit integers using radix sort.We will make three passes over the elements of the array.What occurs during the first pass?
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 60 في هذه المجموعة.
فتح الحزمة
k this deck
54
What does the area analysis of algorithms focus on?
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 60 في هذه المجموعة.
فتح الحزمة
k this deck
55
What is an internal sort?
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 60 في هذه المجموعة.
فتح الحزمة
k this deck
56
List the three factors which can cloud the comparison of algorithms performed by implementing the algorithms in Java and running the programs.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 60 في هذه المجموعة.
فتح الحزمة
k this deck
57
If an algorithm requires 2ⁿ³ + 17n² + 54n + 512 operations to perform,where n is the size of the input data,then we say the order of the algorithm is O(_____).
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 60 في هذه المجموعة.
فتح الحزمة
k this deck
58
Consider the following nested loop.What is the order of the algorithm?
for (int i = 0;i < n;++i)
for (j = 1;j < n;j *= 2)
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 60 في هذه المجموعة.
فتح الحزمة
k this deck
59
What is determined by average-case analysis?
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 60 في هذه المجموعة.
فتح الحزمة
k this deck
60
In the worst case,how many comparisons are required in the bubble sort?
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 60 في هذه المجموعة.
فتح الحزمة
k this deck
locked card icon
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 60 في هذه المجموعة.