Mena Sargios
Quiz por , criado more than 1 year ago

Algorithms and Data Structures | Test 3 Review | CSCI-3110-002 MTSU

20
0
0
Mena Sargios
Criado por Mena Sargios mais de 7 anos atrás
Fechar

6. Algorithm Intro

Questão 1 de 15

1

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;
}

Selecione uma das seguintes:

  • 5 times

  • 4 times

Explicação

Questão 2 de 15

1

What is the big O for printing in a linked list.

Selecione uma das seguintes:

  • O(N)

  • none of the above

Explicação

Questão 3 de 15

1

How long does it take to excute for n items in for loop?

Selecione uma das seguintes:

  • A.n+1

  • B.n+2

  • C.n+3

  • D.n

Explicação

Questão 4 de 15

1

Program execution times are susceptible to the hardware, tricks , data, etc.

Selecione uma das opções:

  • VERDADEIRO
  • FALSO

Explicação

Questão 5 de 15

1

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?

Selecione uma das seguintes:

  • A)15

  • B)10

  • C)12

  • D)11

Explicação

Questão 6 de 15

1

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.";

Selecione uma das seguintes:

  • 5*n*n times

  • none of the above

Explicação

Questão 7 de 15

1

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;
}

Selecione uma das seguintes:

  • A) 4

  • B) 0

  • C) 5

  • D) 6

Explicação

Questão 8 de 15

1

When measuring algorithm efficiency, the program is susceptible to ____

Selecione uma das seguintes:

  • a. hardware

  • b. data

  • c. tricks

  • d. all of the above

  • e. none of the above

  • f. a,b,c, and more

Explicação

Questão 9 de 15

1

When you are calculating the number of loops that a nested for loop runs through, you should:

Selecione uma das seguintes:

  • A. Multiply the number of loops together

  • B. Count the number of loops that the first for loop runs through

  • C. Make a guess

  • D. None of the above

Explicação

Questão 10 de 15

1

How do you measure the efficiency of algorithms?

Selecione uma das seguintes:

  • A) you can't, not enough information

  • B) Focus on algorithm, not program

  • C) none

Explicação

Questão 11 de 15

1

What is algorithm analysis measuring?

Selecione uma das seguintes:

  • 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

Explicação

Questão 12 de 15

1

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

Selecione uma das seguintes:

  • A. 6 steps

  • B. 5 steps

  • C. 4 steps

  • D. 3 steps

Explicação

Questão 13 de 15

1

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);

}

Selecione uma das seguintes:

  • O(N)

  • none of the above

Explicação

Questão 14 de 15

1

Program execution times are susceptible to hardware, tricks, data.

Selecione uma das opções:

  • VERDADEIRO
  • FALSO

Explicação

Questão 15 de 15

1

How many itterations would a quadruply-nested for loop with base itterations 7 and all others itterating at n itterate?

Selecione uma das seguintes:

  • 7*n^3

  • none of the above

Explicação