May/June 2020 COS2611 Programming: Data Structures
Question 1 Program Analysis [10] For each of the following questions choose the correct alternative. Questions 1.1, 1.2 and 1.3 refer to the following code fragment. 1 for(int j = 10; j = n; j++ ) 2 for(int k = 1; k = n; k*=2 ) 3 sum++; 4 for(int p = n; p 1; p/=2 ) 5 for(int q = 0; q 500; q+=4 ) 6 sum--; 1.1. How many times is statement 3 executed? A. O(N) B. O(N2 ) C. O(N3 ) D. O(N log N) E. O(log N) 1.2. How many times is statement 6 executed? A. O(N) B. O(N2 ) C. O(N3 ) D. O(log N) E. O(N log N)
Información del documento
- Subido en
- 10 de octubre de 2021
- Número de páginas
- 10
- Escrito en
- 2021/2022
- Tipo
- Examen
- Contiene
- Preguntas y respuestas