Question

x) What does the following recursive function do, in general?          bool credit (char a[],...

x) What does the following recursive function do, in general?

  

      bool credit (char a[], int L, int H)

     {

         if (H <= L)

            return true;

         else return (a[L] == a[H] && credit(a, L + 1, H - 1));

      }

0 0
Add a comment Improve this question Transcribed image text
Answer #1

Answer:

credit function recursively checks to see if the char array/string 'a' is a palindrome or not.
if it's a palindrome, it returns true.
if it's not a palindrome, it returns false.
Add a comment
Know the answer?
Add Answer to:
x) What does the following recursive function do, in general?          bool credit (char a[],...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • In C++, create a recursive bool function which determines if a string is symmetrical or not....

    In C++, create a recursive bool function which determines if a string is symmetrical or not. A symmetrical string can be read the same front to back (ex. kayak). Function Blueprint --------------------- bool isSymmetrical(string s) if (s is the empty string or s is of length 1) return true else if (s's first and last characters are the same letter)   return isSymmetrical (s minus its first and last characters) else return false

  • Please rewrite this function using recursive function #include using namespace std; struct Node { char ch;...

    Please rewrite this function using recursive function #include using namespace std; struct Node { char ch; Node* next; }; class LinkedList { Node* head; public: LinkedList(); ~LinkedList(); void add(char ch); bool find(char ch); bool del(char ch); friend std::ostream& operator<<(std::ostream& out, LinkedList& list); }; LinkedList::LinkedList() { head = NULL; } LinkedList::~LinkedList() { Node* cur = head, * tmp; while (cur != NULL) { tmp = cur->next; delete cur; cur = tmp; } } void LinkedList::add(char ch) { Node* cur = head,...

  • *Program is in C* Write a recursive function to compute a^b for integers a and b....

    *Program is in C* Write a recursive function to compute a^b for integers a and b. For the recursive use the following equality a^b = a^b - 1 * a and a^0 = 1. What does the following recursive function do? int mystery(int a, int b) {if (b == 1) return (a); else return (a + mystery(a, b - 1));}

  • Here is a function that takes, and returns pointers: 2 int* select(bool which, int* a, int*...

    Here is a function that takes, and returns pointers: 2 int* select(bool which, int* a, int* b) { if(which == true) return a; else return b; } Using this function, suppose we have variables x, y: int x = ..., y = ...; int* p = select(x < y, &x, &y); if(p == &x) cout << "Yes"; else cout << "No"; What will this print if x = 5, y = 7? What will this print if x = 23, ...

  • 1. Determine what the following function calls return for recursive function func below.     (4 pts.)...

    1. Determine what the following function calls return for recursive function func below.     (4 pts.)               public static int func(int n)      {         if(n == 1)            return 2;         else            return 2 + func(n-1);                      (a) func(1) = ________        (b) func(4) = ________ 2. Does func above perform top down or bottom up computation? ____________ (2 pts.)

  • 3. Determine the general result (in terms of n) of the following recursive function (4 pts.)...

    3. Determine the general result (in terms of n) of the following recursive function (4 pts.)               public static void func2(int n)      {         if(n == 1)            System.out.println(“*”);         else         {            for (int i = 1; i <= n; i++)               System.out.print(“*”);            System.out.println();            func2(n-1);                      }               } 4. Does func2 above perform down or bottom up computation? ___________________ (2 pts.)

  • I am stuck on trying to get this recursive function's logic to make it work. //Write...

    I am stuck on trying to get this recursive function's logic to make it work. //Write a recursive function that returns true if the sequence of 0 < n integers in A is sorted in non-increasing order and false otherwise. iostream and cmath libraries only bool is_sorted(const int *A, unsigned int n){ if (n == 0) return false; if (A > A+1) return true; else return false; }

  • Add a recursive Boolean function called checkRecurse to class IntegerLinkedList to check if any two consecutive...

    Add a recursive Boolean function called checkRecurse to class IntegerLinkedList to check if any two consecutive integers in the linked list are equal (return true in this case, false otherwise). You may assume that the list is not empty. A recursion “helper” function is already included in class IntegerLinkedList. You only need to write the recursive function. For example, checkRecurseHelper() should return true for the linked list shown below. A main function (prob3.cpp) is given to you to add data...

  • int xyz( char[] X, char[] Y, int m, int n ) { int L[][] = new...

    int xyz( char[] X, char[] Y, int m, int n ) { int L[][] = new int[m+1] [n+1]; for (int i=0; i<=m; i++){ for (int j=0; j<=n; j++){ if (i == 0 Ilj == 0) L[i][j] = 0; else if (x[i-1] == Y[j-1]) L[i][j] = L[i-1][j-1] + 1; else L[i][j] max(L[i-1][j], L[i][j-1]); مه } ...//more code follows Given the code fragment above, select the best descriptive phrase from the list below. Bottom-up. Recursive. Top-down.

  • Question 11 (3 points) What does the following recursive method determine? public boolean question 16(int[]a, int[]...

    Question 11 (3 points) What does the following recursive method determine? public boolean question 16(int[]a, int[] b. intj) { if (j == 2.length) return false; else if ( == b.length) return true; else return question 16(2, b.j+1): 3 returns true if b contains less elements than a, false otherwise returns true if b contains more elements than a, false otherwise returns true if a and bare equal in size, false otherwise returns true if a's element value is larger than...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT