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)
Written for
- Institution
- University of South Africa
- Course
- COS2611 - Programming Data Structures
Document information
- Uploaded on
- October 10, 2021
- Number of pages
- 10
- Written in
- 2021/2022
- Type
- Exam (elaborations)
- Contains
- Questions & answers
Subjects
-
cos2611
-
mayjune 2020 cos2611 programming data structures