Zusammenfassung der Ressource
Frage 1
Frage
How many times is the following cout statement executed within this loop?
int counter = 0;
for(int k=0; k<5; k++)
{
cout << "counter: " << counter << endl;
}
Frage 2
Frage
What is the big O for printing in a linked list.
Frage 3
Frage
How long does it take to excute for n items in for loop?
Frage 4
Frage
Program execution times are susceptible to the hardware, tricks , data, etc.
Frage 5
Frage
for ( int i = 0; i < 4; i++)
for( int x = 0; x <3 ; x++)
cout << "hi"<< endl;
how many times will the cout statement execute?
Frage 6
Frage
How many times would the cout operation be done in this loop?
for(int i = 0; i < n; i++){
for(int j = 0; j < n; j++){
for(int k = 0; k < 5; k++){
cout << "o hai.";
Antworten
-
5*n*n times
-
none of the above
Frage 7
Frage
How many time is the cout statement executed in the following for loop?
int counter = 0;
for( int k = 0; k < 5; k++){
cout << "counter: " << counter << endl;
}
Frage 8
Frage
When measuring algorithm efficiency, the program is susceptible to ____
Antworten
-
a. hardware
-
b. data
-
c. tricks
-
d. all of the above
-
e. none of the above
-
f. a,b,c, and more
Frage 9
Frage
When you are calculating the number of loops that a nested for loop runs through, you should:
Frage 10
Frage
How do you measure the efficiency of algorithms?
Antworten
-
A) you can't, not enough information
-
B) Focus on algorithm, not program
-
C) none
Frage 11
Frage
What is algorithm analysis measuring?
Antworten
-
A. the efficiency of algorithms
-
B. the number of lines of code
-
C. how often the program will enter an infinite loop
-
D. how much memory leakage there is
Frage 12
Frage
How many steps does the following take to execute if there's n items in a list?
Node* curr = m_head; // 1 assignment
while( curr !=NULL)
{ //n + 1 comparisons
cout << curr->next; // n calls to operator<<
curr = curr->next; // n assignments
}
Total: (n + 1) * assignment_time = (n + 1) * comparison_time + n write_time
Antworten
-
A. 6 steps
-
B. 5 steps
-
C. 4 steps
-
D. 3 steps
Frage 13
Frage
What is the big O for this segment of code:
long factorial(int n){
if(n <= 1)
return 1;
else
return n * factorial(n - 1);
}
Frage 14
Frage
Program execution times are susceptible to hardware, tricks, data.
Frage 15
Frage
How many itterations would a quadruply-nested for loop with base itterations 7 and all others itterating at n itterate?