C++ Programming:
Write a function that takes in a C++-style string s (from #include ), as well as an integer n, and then returns true if any substring of length n in s repeats itself, and false otherwise. For example, if s is "toe-to-toe" and n is 3, then the function would return true since "toe" occurs twice within s. However, if n were 4, the function would return false. As a second example, if s is "singing" and n is 2, then the function would return true since, e.g., "in" appears more than once (as does "ng"). In this problem you may use any of the C++ string member functions.


code:
#include <iostream>
//for string operstions
#include <string>
//includiing the namespace standard
using namespace std;
//function for calculating the substring
int ssc(const string& givenst, const string& stsub)
{
if (stsub.length() == 0) return 0;
int cnt = 0;
int n =2;
for (size_t offset = givenst.find(stsub); offset !=
string::npos;
offset = givenst.find(stsub, offset +
stsub.length()))
{
cnt++;
}
if(cnt==n)
{
return 1;
}
else
{
return 0;
}
}
int main()
{
int l,m;
l=ssc("TOE-TO-TOE", "TOE");
m= ssc("SINGING", "ING");
if(l==1)
{
cout<< "TRUE \n";
}
else
{
cout<<"FALSE \n";
}
if(m==1)
{
cout<< "TRUE \n";
}
else
{
cout<<"FALSE \n";
}
return 0;
}
C++ Programming: Write a function that takes in a C++-style string s (from #include ), as...
C++ programming language Write a program that contains following function: A function that receives a string of character, the function return true if the string contains letter c or C, otherwise, return false.
Write a function is_mirror(s) that takes as input a string s and returns True if s is a mirrored string (i.e., a string that could have been produced by your mirror function) and False otherwise. Examples: >>> is_mirror('baconnocab') result: True >>> is_mirror('baconnoca') result: False Warning Your function should return a boolean value – either True or False, without any quotes around them. If you see quotes around the result when you make the calls above from the console, you must...
Python Programming Assignment: Write a function to take a string S that returns True if the letters are in ascending order and False otherwise. To do this go over each letter and check that it is less than the letter that precedes it. Then write a function main that gets one input from the user, then if passing that input to the function above returns True, then show "String is in order", otherwise show " String is unordered".
Q1)(20p)Write a static member function called
removeLongestRepeatingSegment that takes a String argument. The
method will return a new String by removing the logest segment that
contains consequtively repeating characters.
public static void main(String []args){
String s=”1111222223333311111111444455552222”;
String res= removeLongestRepeatingSegment(s); will return
“11112222233333444455552222”
}
public static String removeLongestRepeatingSegment(String
s){
---------------
Q2)15p)Given a list of objects stored (in ascending order) in a
sorted linked list, implement member method which performs search
as efficiently as possible for an object based on a key....
Write a function check palindrome, which takes a string x as argument and which returns True if x is a palindrome, and False otherwise. A palindrome is a word that reads the same backwards as forwards (like for example “racecar”). Your function should be recursive (i.e. call itself) and proceed as follows. 1. If x is a string of length 0 or 1 return True. 2. If the rst and the last letter of x are di erent, return False....
Python Programming Assignment: Write a function to take a string S that returns True if the letters are in ascending order and False otherwise. To do this go over each letter and check that it is less than the letter that precedes it.
Python3: Write the function longestSubpalindrome(s), that takes a string s and returns the longest palindrome that occurs as consecutive characters (not just letters, but any characters) in s. so longestSubpalindrome("ab-4-be!!!") returns "b-4-b".If there is a tie, return the lexicographically larger value -- in Python, a string s1 is lexicographically greater than a string s2 if (s1 > s2). So: longestSubpalindrome("abcbce") returns "cbc", since ("cbc" > "bcb"). Note that unlike the previous functions, this function is case-sensitive (so "A" is not...
This is for C Programming Write a function that checks whether a given string is a palindrome or not, recursively. Palindrome is a word, phrase, or sequence that reads the same backward as forward. You may not modify the functions signatures, that is, adding any new parameters or changing the data type of the parameters in any way. You may not use square brackets and any type of loops in your solutions. For example: isPalindrome("abcba", ...) -> true isPalindrome("abcb1", ...)...
Using the programming language Java or C++, Write a function that takes an integer as input. Return true if this integer is a palindrome integer; false otherwise;
Haskell Functional Programming Language: Write a function nestedParens that takes a string argument and returns true if it is a nesting of zero or more pairs of parentheses, e.g. "((()))" should return True ; "()()" or "(()))" should return False . Use recursion for this problem. nestedParens :: String -> Bool