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

Assignment Help:

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?

 


Related Discussions:- Give a formal expression of the specification

Explain the #undef directive, The #undef Directive This directive undef...

The #undef Directive This directive undefines a previously explained macro. For, example the following will give an error since PI is undefined.                 #define PI 3

Write a program that finds the minimum total number of she., Write a progra...

Write a program that finds the minimum total number of shelv, C/C++ Programming

Give example of the for loop, The for Loop For loop is the controlled f...

The for Loop For loop is the controlled form of loop. The general format of this : for( initialize ; test ; update)                  {                     statements;

Programing project, Hello, Do you have any idea for programming project to...

Hello, Do you have any idea for programming project to simulate a network attack (threat) mechanism or a defense mechanism. Can I get some suggestions for this. Please include th

Load catalogue from file, Implement a menu driven real estate catalogue sys...

Implement a menu driven real estate catalogue system that allows users to perform various catalogue maintenance and search tasks.  You are only allowed to use the C programming la

Make qtav videoplayer simple integrateable for application, Make QtAV Video...

Make QtAV Videoplayer simple integrateable for Qt Applications Project Description: I'm preparing an application for Windows and Mac using QtCreator. I want a videoplayer

Logic families and lsi devices, We have used logic symbols in the past, but...

We have used logic symbols in the past, but not really though about the actual real devices. Semiconductor companies have taken the logic symbols are manufactured them into logic f

STRING, getting a palindrome using minimum replacement

getting a palindrome using minimum replacement

Example of switch case statement, #include #include #include void* m...

#include #include #include void* memorycopy (void *des, const void *src, size_t count) {   size_t n = (count + 7) / 8;   char* destination = (char *) des;   char* source =

Write Your Message!

Captcha
Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd