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
Sir i want to know all the basic knowledge of turbo c.

A palindrome is a string that reads the same from both the ends. Given a string S convert it to a palindrome by doing character replacement. Your task is to convert S to palindrome

Problems With Multiple Inheritance The following example presents a problem with multiple inheritance. class Aclass  {   public :  void put()

Prepare a MT4 EA to clone MT4 Trades to a Binary Options Platform Project Description: I want an EA that clones MT4 Trades to Globaltrader365, GT Options and if possible othe

write a program to find area of curve y=f(x) between x and x=b,integrate between the limits a and b using c     #include float start_point, /* GL

Define the System Oriented Data Files? System-oriented data files are further closely related to the computer's operating system than Stream- oriented data files and they are s

Project Description: I want a simple program that will spoof my hardware id. I should be able to prepare the id to spoof to in the program and press "random" button to spoof to

The question description: You are required to make a C++ program to conduct timber component (beam and column) structural design according to EC5 (all the relevant design codes

Illustrate the Function Definition? The C code that explains what a function does is called the function definition. A function definition has the following form Type fun

Refactoring Project Description: TASK 1 - DESIGN ALGORITHM You are required to design a suitable solution algorithm by using structured chart, pseudocode or flowchart. Thi