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
Q2 (2%): Consider this code fragment for function funOne: public static long funOne(int N) { long sum = 0; for (int i=1;
-
answerhappygod
- Site Admin
- Posts: 899604
- Joined: Mon Aug 02, 2021 8:13 am
Q2 (2%): Consider this code fragment for function funOne: public static long funOne(int N) { long sum = 0; for (int i=1;
Join a community of subject matter experts. Register for FREE to view solutions, replies, and use search function. Request answer by replying!