Looking for Problem Solving with Algorithms (2024/2025) test answers and solutions? Browse our comprehensive collection of verified answers for Problem Solving with Algorithms (2024/2025) at moodle.kent.ac.uk.
Get instant access to accurate answers and detailed explanations for your course questions. Our community-driven platform helps students succeed!
Consider an initially empty stack of English words. Let us consider the following operations (separated by semicolons) on the stack.
top; push if; top; push she; push puts; top; push it; pop; push it; top; push in; push her; pop; push her; top; push batter; push it; top; push will; pop; top; push will; top; push make; push her; top; push batter; top; push bitter;
From this point on, if we continue executing only the operation pop on the stack, we will get the output
"bitterbatterhermakewillitbatterherinitputssheif"
after which the stack will be empty. This would end the first phase of operations on the stack.
In the second phase, the following operations are executed on the stack.
top; push how; top; push can; top; pop; push is; top; push he; push she; top; pop; push ten; top; push hours; push days; push years; top; pop; top; pop; push straight; top; push he; top; push they; pop; push is; top; push are; pop; push a; push some; pop; push machine; top;
What will be the output henceforth, if we continue executing only the operation pop on the stack?
(Please ignore all outputs until this point. In your answer, please exclude all spaces, quotation marks or any additional character other than the words from the stack.)
Consider the following piece of code. (The numbers on the left margin denote line numbers.)
Consider an integer array defined as follows in java.
int [ ] n = new int [30];
Which of the following is true?
A graph G = (V, E) consists of a set V of vertices/nodes and a set E of edges. Which of the following is correct?
Consider an initially empty queue of English words. It allows four operations - enqueue, dequeue, head and tail. The operation enqueue adds its input to the rear of the queue. The dequeue operation removes the element at the front of the queue. The head and tail operations print the element at the front and rear of the queue data structure respectively. Let us consider the following operations (separated by semicolons) on the queue.
enqueue albert; head; enqueue einstein; tail; enqueue famously; enqueue said; head; enqueue it; enqueue is; dequeue; dequeue; tail; tail; enqueue not; enqueue so; enqueue very; enqueue important; enqueue for; head; enqueue a; head; enqueue person; head; enqueue to; enqueue learn; dequeue; enqueue facts; enqueue for; enqueue that; enqueue they; enqueue do; enqueue not; enqueue really; enqueue need; enqueue a; enqueue university; dequeue;
At this point, we keep doing the operation dequeue on the queue, to get the following output.
"itisnotsoveryimportantforapersontolearnfactsforthattheydonotreallyneedauniversity"
This is where the first phase ends and the queue is empty.
In the second phase, the following operations are conducted on the queue.
head; tail; enqueue Einstein; enqueue added; enqueue that; head; enqueue the; enqueue value; tail; enqueue of; enqueue education; dequeue; enqueue is; tail; enqueue not; enqueue in; enqueue the; enqueue learning; enqueue of; enqueue many; head; enqueue facts; enqueue but; enqueue the; head; enqueue training; dequeue; enqueue of; enqueue the; enqueue mind; enqueue to; tail; head; enqueue think; enqueue something; enqueue that; enqueue cannot; enqueue be; head; tail; enqueue learned; enqueue from; enqueue textbooks; head; dequeue; tail;
What will be the output henceforth, if we continue executing only the operation dequeue on the queue?
(Please ignore all outputs until this point. In your answer, please exclude all spaces, quotation marks or any additional character other than the words from the stack.)
Consider the following piece of code. (The numbers on the left margin denote line numbers.)
Consider the following piece of code. (The numbers on the left margin denote line numbers.)
Consider the following piece of code. (The numbers on the left margin denote line numbers.)
Consider the organisation of arrays and linked lists in the memory. Let there be N data elements in the data structure. Which of the following is true?
Consider an array implementation of a circular queue. Let the array be named Q and be of size N=10, and hence the indices range between 0 and 9, including both. Let the front of the queue be indexed by f and the rear be indexed by r. Initially, when the queue is empty, let f = r = N-1 = 9.
With every enqueue operation, we do r = r + 1 mod N and store the new element at index r of the array.
With every dequeue operation, we do f = f + 1 mod N and remove the element at position f.
What will be values of f, r, Q[f+1] and Q[r] after the following operations?
enqueue 4; enqueue 6; enqueue 2; dequeue; enqueue 3; enqueue 9; enqueue 5; dequeue;