Give a formal expression of the specification, C/C++ Programming

A function REPAT is specified below.

Function REPAT(c in Char, i in Int, s in mString) return in mString pre 1 ≤ i ≤ the length of s. post The returned value is a string identical to s except that the character at index position i has been replaced by the character c.

For example, if s is "court" then REPAT('N',4, s) will be "couNt". For a non-empty string, t, let A(t) be the set

A(t) = {j in Int: (1 ≤ j) ∧ (j ≤ t.length( ))}.

In giving the formal expressions required in parts (b) and (d) below, you can use: methods of the class mString; type functions of Char and Int; the set A(t) (for any non-empty string t), and the usual notation of logic.

(a) Suppose that t is the string "riyht". For this string t, write down t.length, and enumerate the set of integers A(t)

(b) Suppose that s and w are non-empty strings of type mSring, c is of type Char and i is an integer form the set A(w).

Express formally each of the predicates in (i) and (ii) below. (i) The character at index position i in the string w is c.

(ii) For every integer j in the set A(s), if j is not equal to i then the characters at position j in the strings s and w are the same.

(c) Suppose that s is the string "riyht",c is the character 'g', w is the string "rightHo" and i is 3.

For these values of s, c, w and i, what is the truth value of each of the predicates in part (b) above?


Posted Date: 3/7/2013 2:22:14 AM | Location : United States

Related Discussions:- Give a formal expression of the specification, Assignment Help, Ask Question on Give a formal expression of the specification, Get Answer, Expert's Help, Give a formal expression of the specification Discussions

Write discussion on Give a formal expression of the specification
Your posts are moderated
Related Questions
At a shop of marbles, packs of marbles are prepared. Packets are named A, B, C, D, E …….. All packets are kept in a VERTICAL SHELF in random order. Any numbers of packets with thes

A: you can exploit by overloading standard operators on a class, the intuition of the users of that class. This allow users program in the language of the problem domain instead of

how to make a program this struct items/product

Why many companies are switching their current business language to PHP? Where PHP basically used? PHP is rapidly gaining popularity and numerous companies are switching their

Write a program that finds the minimum total number of shelves, including the initial one required for this loading process.

decodes the sending smuggler string from the number format into plain text

make a marksheet of 2 student with 5 subject

Study the following table used to compute the tax payable by employees in certain organization   Gross Pay                                  Fewer than Three             Three

I have to make a program that allow the user input 10 numbers between 10 and 100 and if the number input is the same than the last number, should appear an error message. I have th

How are postfix and prefix versions of operator++ () differentiated? A: The postfix version of operator++ () contain a dummy parameter of type int. The prefix version does not c