If given program is executed, what will be output? Create Stack Queuequeue = new LinkedList; Create
Fantastic news! We've Found the answer you've been seeking!
Question:
If given program is executed, what will be output?
Create Stack Queuequeue =new LinkedList; Create LinkedList ll; int[]array = { 82, 99, 37, 20, 54 }; for (i = 0; i < array.length; i++) { int x = array[i]; if (i % 2 == 0) addLast (x) in ll; else push(x) on stack; } while ("stack is not empty" || "linked list is not empty") { if (stack is not empty) queue.enqueue(stack.pop()); if ("linked list is not empty") queue.enqueue(ll.removeLast()); if "queue is not empty") print("I am " + queue.getFront();} |
Output:
Related Book For
Posted Date: