please send answer Q3 for part c i please send proper answer Y}{ x - Y > 0}Y +Y div 2ii. {x is even}X + X +1X + 2 * X{x is odd}X + 2 * Yiii. {x = Y}{x = Y}Y + 2 * X(c) A palindromic number...



please send answer Q3 for part c i



please send proper answer


3. (a) Explain the notation {Pre} Code {Post}. Explain in your answer the difference<br>between total and partial correctness.<br>(b) Which of the following statements are true? In each case you should justify your<br>argument informally.<br>X + X* 2<br>i. {x > Y}<br>{ x - Y > 0}<br>Y +Y div 2<br>ii. {x is even}<br>X + X +1<br>X + 2 * X<br>{x is odd}<br>X + 2 * Y<br>iii. {x = Y}<br>{x = Y}<br>Y + 2 * X<br>(c) A palindromic number is a number that is the same if read forwards or<br>backwards: 12321 and 641146 are examples. It is possible to represent a<br>number using an array of digits (numbers 0 - 9), for example: [1,9, 5, 2] could<br>represent 1952.<br>i. Using an appropriate iteration construct, write an algorithm as a procedure<br>that decides if an input array A[1...n] of digits is a palindromic number.<br>ii. Repeat question (i) but write your algorithm as a recursive procedure. Show<br>how your algorithm works by giving a trace of the computation with the array<br>[1, 2, 2, 1).<br>

Extracted text: 3. (a) Explain the notation {Pre} Code {Post}. Explain in your answer the difference between total and partial correctness. (b) Which of the following statements are true? In each case you should justify your argument informally. X + X* 2 i. {x > Y} { x - Y > 0} Y +Y div 2 ii. {x is even} X + X +1 X + 2 * X {x is odd} X + 2 * Y iii. {x = Y} {x = Y} Y + 2 * X (c) A palindromic number is a number that is the same if read forwards or backwards: 12321 and 641146 are examples. It is possible to represent a number using an array of digits (numbers 0 - 9), for example: [1,9, 5, 2] could represent 1952. i. Using an appropriate iteration construct, write an algorithm as a procedure that decides if an input array A[1...n] of digits is a palindromic number. ii. Repeat question (i) but write your algorithm as a recursive procedure. Show how your algorithm works by giving a trace of the computation with the array [1, 2, 2, 1).
Jun 10, 2022
SOLUTION.PDF

Get Answer To This Question

Related Questions & Answers

More Questions »

Submit New Assignment

Copy and Paste Your Assignment Here