Page 1 of 1

Q2 (2%): Consider this code fragment for function funOne: public static long funOne(int N) { long sum = 0; for (int i=1;

Posted: Thu May 05, 2022 12:51 pm
by answerhappygod
Q2 2 Consider This Code Fragment For Function Funone Public Static Long Funone Int N Long Sum 0 For Int I 1 1
Q2 2 Consider This Code Fragment For Function Funone Public Static Long Funone Int N Long Sum 0 For Int I 1 1 (88.63 KiB) Viewed 30 times
Q2 (2%): Consider this code fragment for function funOne: public static long funOne(int N) { long sum = 0; for (int i=1; i<=N; i*=2) { for (int k=0; k<5; k++) { sum = sum + i*k; } } return sum; } For N a positive integer, what is a good "Big Oh" worst case execution time of function funOne ? Q3 (2%): Consider this code fragment for function bar: public static long bar (long K) { if (K == 2) return 2; answer: return bar( bar(K-1) ); } For K a positive integer >= 2, what is a good "Big Oh" worst case execution time of function bar ? 1 answer:
For Q4 and Q5, consider the di-graph to the right: Also consider these sequences of nodes a) CBKTAHP MGE b) CBHGTPEAMK c) KPCETABGM H d) TGEPKAM HBC e) CKPEGTAMHB f) none of these Q4 (2%): Which sequence is a depth-first search? H Q5 (2%): Which sequence is a breadth-first search? M Q6 (1%): Which of the following is the best high-level description of the blockchain (such as used to implement Bitcoin)? a) Skip list that uses hashing instead of coin flips b) Balanced binary search tree with hashes as node values c) Hash map of data blocks that uses chaining for collisions d) Linked-implementation stack with hash values as links e) Doubly linked list with hash values as links f) Minimum binary heap of hashes as priorities Answer: E T B