The pseudocode of Figure 6.16 illustrates the basic push() and pop() operations of an array-based stack. Assuming that this algorithm could be used in a concurrent environment, answer the following...


The pseudocode of Figure 6.16 illustrates the basic push() and pop() operations of an<br>array-based stack. Assuming that this algorithm could be used in a concurrent environment, answer the following<br>questions:<br>a. What data have a race condition?<br>b. How could the race condition be fixed?<br>push(item) {<br>if (top < SIZE) {<br>stack (top]<br>top++;<br>}<br>else<br>= item;<br>ERROR<br>}<br>pop () {<br>if (!is.empty()) {<br>top--;<br>return stack[top];<br>else<br>ERROR<br>}<br>is.empty() {<br>if (top 0)<br>return true;<br>else<br>return false;<br>}<br>Figure 6.16 Array-based stack for Exercise 6.12.<br>

Extracted text: The pseudocode of Figure 6.16 illustrates the basic push() and pop() operations of an array-based stack. Assuming that this algorithm could be used in a concurrent environment, answer the following questions: a. What data have a race condition? b. How could the race condition be fixed? push(item) { if (top < size)="" {="" stack="" (top]="" top++;="" }="" else="item;" error="" }="" pop="" ()="" {="" if="" (!is.empty())="" {="" top--;="" return="" stack[top];="" else="" error="" }="" is.empty()="" {="" if="" (top="" 0)="" return="" true;="" else="" return="" false;="" }="" figure="" 6.16="" array-based="" stack="" for="" exercise="">

Jun 08, 2022
SOLUTION.PDF

Get Answer To This Question

Related Questions & Answers

More Questions »

Submit New Assignment

Copy and Paste Your Assignment Here