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
create a program to populate the first array then the odd number is the second array and get the sum of the second array.

Rules of function: Inline function created without prototype it reduces the memory and it is used only for small function. Inline function cannot have recursion, static var

Produce data from fixed OCR areas scanned. Project Description: Project is to design software which can use character recognition only on certain areas of scanned puff's/ jpe

A: Using the extern "C" linkage specification around the C function declarations. Programmers must know about mangled function names and type-safe linkages. After that they must

Nested Classes Many a times, it becomes essential to have a class contain properties of two other classes. One way is to explain a class within another - that is a class with m

The Scope Resolution Operator( :: ) Global variables are explained outside any functions and thus can be used by all the functions defined thereafter. However, if a global vari

Create a Document that show information about albums. First create a paragraph or two about the purpose of the page and your interests in music: genres, styles, etc. Next have a

Develop G-code generating software Project Description: I'm presently using Slicer on a polymer jetting 3d printer. The toolpaths were thought out for FDM printers and thus a

What is Union? Intimately associated with the structure is the union which as well contains multiple members. Unlike a structure but the members of a union share the same stora

A: This will turn o_ "name mangling" for func so that one can connect to code compiled by a C compiler.