Question: Consider the following program, which we will refer to as s: while(n > 1){ } if (even (n)) then{n=n/2} else{n 3n+1} Assume that even

Consider the following program, which we will refer to as s: while(n

Consider the following program, which we will refer to as s: while(n > 1){ } if (even (n)) then{n=n/2} else{n 3n+1} Assume that even (n) returns true if n is even and false otherwise. a) Show the steps of evaluation to evaluate s with the state = {n = 5} until it reaches skip. You can define shorthands, e.g., let b be the body of the while loop, and use notations like 2 to skip boring steps. Do not skip over any steps that perform state updates. You don't need to show work for the evaluation of expressions (e.g., below we realize that (n> 1) = T and (even(n)), but don't show that). The first couple steps are shown as an example. > (s, {n = 5}) (b; s, {n = 5}} (n=3n+1;s, {n = 5}) b) What is M(s, )? You don't need to show work.

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock

a Here are the steps to evaluate the program s with the initial state o n 5 until it reaches skip s ... View full answer

blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!