Please write out your step You may use a table which include

Please write out your step. You may use a table which includes processes and variables. Don\'t just give the final anwer.

1. How many computations are there for Algorithm 1. Algorithm 1. Assignment statement for a stack machine integer n 40 p1: push n q1: push n q2: push #1 p2: push #1 p3: add q3 add p4 pop n q4 pop n

Solution

We know push and pop operations in stack take 1 computation. Following table gives the stack information for process p:

so, p will take 4 computations.

Similarly, q will take 4 computations.

In addition to p and q, there is one assignment as well.

So, overall it will take 9 computations.

Hope it helps. Do give your feedback.

pop
add i.e., n=n+1
push 1
push n
Please write out your step. You may use a table which includes processes and variables. Don\'t just give the final anwer. 1. How many computations are there for

Get Help Now

Submit a Take Down Notice

Tutor
Tutor: Dr Jack
Most rated tutor on our site