Computers and Technology
16.01.2022 03:24
259
384
5
Solved by an expert

Give a recurrence relation for w(h) that counts the number of possible height balanced

Give a recurrence relation for w(h) that counts the number of possible height balanced trees of height h, where the height of left and right children can differ by up to 2
Show Answers
Robyn1234
Robyn1234
4,4(19 marks)

#include <bits/stdc++.h>

using namespace std;

bool isPalindrome(string str)

{

   char a,b;

int length = str.length();

for (int i = 0; i < length / 2; i++)

{

   a=tolower(str[i]);//Converting both first characters to lowercase..

   b=tolower(str[length-1-i]);

   if (b != a )

return false;

}

return true;

   

}

int main() {

   string t1;

   cin>>t1;

   if(isPalindrome(t1))

   cout<<"The string is Palindrome"<<endl;

   else

   cout<<"The string is not Palindrome"<<endl;

return 0;

}

Output:-

Enter the string

madam

The string is Palindrome

Enter the string

abba

The string is Palindrome

Enter the string

22

The string is Palindrome

Enter the string

67876

The string is Palindrome

Enter the string

444244

The string is not Palindrome

Explanation:

To ignore the cases of uppercase and lower case i have converted every character to lowercase then checking each character.You can convert to uppercase also that will also work.

Popular Questions about the subject: Computers and Technology

Which of the following is a step in paraphrasing? skim the original information...
Computers and Technology
11.10.2022 12:18
Sending 10 pictures of your recent vacation, to everyone in your email...
Computers and Technology
17.11.2022 17:25
Codehs 2.5.8 more operations i need the assignment is let’s look at a...
Computers and Technology
01.02.2023 03:58
who ever answers correctly and gives explanation will get branliest answer...
Computers and Technology
12.10.2020 03:39
who ever gives the answer and explains will get brainless answers and...
Computers and Technology
22.01.2021 11:55
Which of the following statements is true of a time management plan?...
Computers and Technology
23.05.2021 21:22
List the digits 0-9 that have rotational symmetry and state the angle...
Computers and Technology
24.08.2022 15:08
Student(ssn, name, major, bdate) course(course#, cname, dept) enroll(ssn,...
Computers and Technology
21.07.2022 20:46
Browsing the web is one of the most common activities performed by individuals...
Computers and Technology
14.11.2020 14:37
Why do interest inventories compare your interests with the interests...
Computers and Technology
12.05.2022 05:50

New questions by subject

Select all the expressions that are equivalent to -3/4...
Mathematics
10.06.2021 20:28
A librarian sorts 500 books at a constant rate. After 4 days, the librarian...
Mathematics
30.03.2022 13:14
The table shows the cost of ride tickets at the fair. What is the unit...
Mathematics
22.01.2022 18:48
What is the role of convection in producing the rain shadow effect?...
Biology
27.10.2020 11:12
#
#
#
#
# #

We expand our knowledge with many expert answers