COM SCI 32 Lecture Notes - Lecture 8: Linear Search, Binary Search Algorithm, Time Complexity
Document Summary
For (i=0 ; i < n*n*n ; i++) sum += i; } O(log n): logarithmic complexity for ( int k = 0; k < q; k++ ) cout << muahahaha! ; else. Binary search in a sorted list of items cout << burp! ; } } While loop, decrementing condition (k>1) by half (k = k/2) O(n * log n) for (int i=0 ; i < n ; i++) { int k = n; while (k > 1) sum++; k = k/2; } O(n^2*q) void bar( int n, int q ) { for (int i=0 ; i < n*n ; i++) for (int j = 0; j < q; j++) cout << i love cs! ; If the pairs are in no particular order in the outer vector, the answer would be o(c + log s). The pairs are in no particular order in the outer vector.