6. Algorithm Intro

Descripción

Algorithms and Data Structures | Test 3 Review | CSCI-3110-002 MTSU
Mena Sargios
Test por Mena Sargios, actualizado hace más de 1 año
Mena Sargios
Creado por Mena Sargios hace alrededor de 8 años
24
0

Resumen del Recurso

Pregunta 1

Pregunta
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; }
Respuesta
  • 5 times
  • 4 times

Pregunta 2

Pregunta
What is the big O for printing in a linked list.
Respuesta
  • O(N)
  • none of the above

Pregunta 3

Pregunta
How long does it take to excute for n items in for loop?
Respuesta
  • A.n+1
  • B.n+2
  • C.n+3
  • D.n

Pregunta 4

Pregunta
Program execution times are susceptible to the hardware, tricks , data, etc.
Respuesta
  • True
  • False

Pregunta 5

Pregunta
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?
Respuesta
  • A)15
  • B)10
  • C)12
  • D)11

Pregunta 6

Pregunta
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.";
Respuesta
  • 5*n*n times
  • none of the above

Pregunta 7

Pregunta
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; }
Respuesta
  • A) 4
  • B) 0
  • C) 5
  • D) 6

Pregunta 8

Pregunta
When measuring algorithm efficiency, the program is susceptible to ____
Respuesta
  • a. hardware
  • b. data
  • c. tricks
  • d. all of the above
  • e. none of the above
  • f. a,b,c, and more

Pregunta 9

Pregunta
When you are calculating the number of loops that a nested for loop runs through, you should:
Respuesta
  • 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

Pregunta 10

Pregunta
How do you measure the efficiency of algorithms?
Respuesta
  • A) you can't, not enough information
  • B) Focus on algorithm, not program
  • C) none

Pregunta 11

Pregunta
What is algorithm analysis measuring?
Respuesta
  • 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

Pregunta 12

Pregunta
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
Respuesta
  • A. 6 steps
  • B. 5 steps
  • C. 4 steps
  • D. 3 steps

Pregunta 13

Pregunta
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); }
Respuesta
  • O(N)
  • none of the above

Pregunta 14

Pregunta
Program execution times are susceptible to hardware, tricks, data.
Respuesta
  • True
  • False

Pregunta 15

Pregunta
How many itterations would a quadruply-nested for loop with base itterations 7 and all others itterating at n itterate?
Respuesta
  • 7*n^3
  • none of the above
Mostrar resumen completo Ocultar resumen completo

Similar

2. Red Black Tree
Mena Sargios
12. Graph Traversal
Mena Sargios
5. B-Tree
Mena Sargios
7. Algorithm Growth Rate
Mena Sargios
3. 2-3 Tree
Mena Sargios
16. Greedy Algorithm (Huffman code)
Mena Sargios
4. 2-3-4 Tree
Mena Sargios
10. Hashing Collision
Mena Sargios
1. Trees Splay Trees
Mena Sargios
14. Graph Shrtest Path
Mena Sargios
15. Graph Spanning Tree
Mena Sargios