COM SCI 32 Lecture Notes - Lecture 8: Linear Search, Binary Search Algorithm, Time Complexity

155 views2 pages

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.

Get access

Grade+20% off
$8 USD/m$10 USD/m
Billed $96 USD annually
Grade+
Homework Help
Study Guides
Textbook Solutions
Class Notes
Textbook Notes
Booster Class
40 Verified Answers
Class+
$8 USD/m
Billed $96 USD annually
Class+
Homework Help
Study Guides
Textbook Solutions
Class Notes
Textbook Notes
Booster Class
30 Verified Answers

Related Documents

Related Questions