Answer:
Following are the code block in the Java Programming Language.
//define recursive function
public static long exponentiation(long x, int n) {
//check the integer variable is equal to the 0.
if (x == 0) {
//then, return 1
return 1;
}
//Otherwise, set else
else {
//set long data type variable
long q = exponentiation(x, n/2);
q *= q;
//check if the remainder is 1
if (n % 2 == 1) {
q *= x;
}
//return the variable
return q;
}
}
Explanation:
<u>Following are the description of the code block</u>.
- Firstly, we define the long data type recursive function.
- Then, set the if conditional statement and return the value 1.
- Otherwise, set the long data type variable 'q' that sore the output of the recursive function.
- Set the if conditional statement and check that the remainder is 1 and return the variable 'q'.
Answer:
b.used is 2, b.data[0] is 4, b.data[1] is 6
Explanation:
bag b;
b.insert(5); // b has 5
b.insert(4); // b has 5,4
b.insert(6); // b has 5,4,6
b.erase_one(5); // now 5 is removed , b has 4,6
so no:of elements b.used is 2
b[0]=4;
b[1]=6;
Answer:
I am going to use the Python programming language to answer this. The source code is given below:
print("Enter your tweet here")
user_tweet = input()
decoded_tweet = user_tweet.replace('TTYL', 'talk to you later')
print("This is the decoded tweet: ")
print(decoded_tweet)
Explanation:
In the program the replace() module was used to replace 'TTYL' with 'talk to you later.'
Attached is the screenshot of the output.