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
i am using otlv4 for database connecttvity, while i try to get all tables list from current database using query "$SQLTables" no output is displayed though programe compiles coretl

Constructors By definition, a constructor function of some class is a member function that automatically gets implemented whenever an instance of the class to which the constru

Project Description: Online game development Online Live Baccarat Game is needed - client program. - server program(IOCP or ect..). - web program(ASP or PHP or etc..

A: No. If they're utilized properly, they increase encapsulation. You frequently require splitting a class in half while the two halves will have distinct numbers of instances o

F u nction overloading: Functions can be defined with same name.  Depending upon the type of argument passed the function will perform.  This is known function overloading

Define Some Features of Automatic Variables in C program? The features of automatic variables are like as Storage - memory Default initial value - an unpredictable value,

Create a .cpp program that verifies the strength of a password that a user is entering is strong (complex/secure) enough. In the main area of the program, prompt the user to enter

Default Value Functions,  When declaring a function we can specify a default value for each parameter. This value will be used if that parameter is left blank when calling to the f

(RationalNumber Class) A rational number is a number that can be represented as the quotient of two integers. For example, 1/3, 5/7, 7/2, and so forth are rational numbers (By 2/1

A: A dangling pointer arises while you use the address of an object after its lifetime is end. It may occur in situations such as returning addresses of automatic variables from a