Question: Q02. What does the following code fragment print when N is 43? Stack stack = new Stack (); while (N > 0) { stack.push(N %
Q02. What does the following code fragment print when N is 43?
Stack
N = N/2; } for (int d : stack) StdOut.print(d); StdOut.println();
a. 101010 b. 001011 c. 101000 d. 101111 e. 101011
Q03. The order of time complexity of enqueueing an element into a priority queue (with n elements):
a. is independent of the particular implementation b. is O(1) for any implementation using ordered arrays c. is always O(nlogn) d. is always the same as the order of complexity of the dequeue operation e. none of the above
Q04. Suppose x is a linkedlist node and not the last node on the list. What is the effect of the following code fragment?
x.next = x.next.next;
a. Deletes from the list the node immediately preceding x. b. Deletes from the list the node immediately following x. c. Deletes from the list the node following the node following x. d. Deletes from the list the node immediately following the node preceding x. e. Has no effect: neither deletes nor adds a node to the linked list.
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
