Palindromes Complete the function palindrome(String text). Return true if text is a palindrome; if the word is identical forward and backward. Otherwise, return false. Example:  palindrome(“racecar”) == true palindrome(“kayaks”) == false See main() for more examples. You can use text.charAt(i) to find the character at index i of text. Use recursion. palindrome() should call itself. No loops allowed. b. Complete the function nestedBrackets(String s). This function should find properly nested brackets within s. Return true if brackets are opened and closed correctly, and false otherwise.  Single pairs and nested pairs are valid. For example: z[z]z, [zz[zz]z], [z[[z]zzz]], zzzzz Incorrect pairings and multiple separate pairs are not valid. For example: zz[zz, ]zzz[, [zzz][z], [z[z][z]z] See main() for more examples. nestedBrackets() should call firstIndexOf() and lastIndexOf() to help you solve the problem. Use recursion. nestedBrackets() should call itself. No loops allowed inside this function. c. Collatz For this problem, trace the execution of your program on paper as part of your programming process. See the tracing template at the end of this document. Write whatever notes you feel are useful for solving the problem. You will upload an image and description of your tracing notes after completing the exercise. Complete the function collatz(int n, int len). Find the length of the Collatz sequence starting from some n > 0.  The numbers of the sequence are computed as follows: If n is even, the next number is n / 2 If n is odd, the next number is 3n+1 When n reaches 1, the sequence is over. For example: Start = 10 : Sequence: 10, 5, 16, 8, 4, 2, 1 Length: 7  Return the length of the sequence when n reaches 1. The sequence includes the starting number and the final 1. Use recursion. collatz() should call itself. No loops allowed.

Database System Concepts
7th Edition
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Chapter1: Introduction
Section: Chapter Questions
Problem 1PE
icon
Related questions
Question

1.

a.Palindromes

Complete the function palindrome(String text). Return true if text is a palindrome; if the word is identical forward and backward. Otherwise, return false.

Example: 

palindrome(“racecar”) == true

palindrome(“kayaks”) == false

See main() for more examples.

You can use text.charAt(i) to find the character at index i of text.

Use recursion. palindrome() should call itself. No loops allowed.

b.

Complete the function nestedBrackets(String s). This function should find properly nested brackets within s. Return true if brackets are opened and closed correctly, and false otherwise. 

Single pairs and nested pairs are valid. For example:

z[z]z, [zz[zz]z], [z[[z]zzz]], zzzzz

Incorrect pairings and multiple separate pairs are not valid. For example:

zz[zz, ]zzz[, [zzz][z], [z[z][z]z]

See main() for more examples.

nestedBrackets() should call firstIndexOf() and lastIndexOf() to help you solve the problem.

Use recursion. nestedBrackets() should call itself. No loops allowed inside this function.

c. Collatz

For this problem, trace the execution of your program on paper as part of your programming process. See the tracing template at the end of this document. Write whatever notes you feel are useful for solving the problem. You will upload an image and description of your tracing notes after completing the exercise.



Complete the function collatz(int n, int len). Find the length of the Collatz sequence starting from some n > 0. 

The numbers of the sequence are computed as follows:

If n is even, the next number is n / 2

If n is odd, the next number is 3n+1

When n reaches 1, the sequence is over.

For example:

Start = 10 :

Sequence: 10, 5, 16, 8, 4, 2, 1

Length: 7 

Return the length of the sequence when n reaches 1. The sequence includes the starting number and the final 1.

Use recursion. collatz() should call itself. No loops allowed.

Expert Solution
steps

Step by step

Solved in 3 steps with 3 images

Blurred answer
Knowledge Booster
Function Arguments
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
Database System Concepts
Database System Concepts
Computer Science
ISBN:
9780078022159
Author:
Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:
McGraw-Hill Education
Starting Out with Python (4th Edition)
Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON
Digital Fundamentals (11th Edition)
Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON
C How to Program (8th Edition)
C How to Program (8th Edition)
Computer Science
ISBN:
9780133976892
Author:
Paul J. Deitel, Harvey Deitel
Publisher:
PEARSON
Database Systems: Design, Implementation, & Manag…
Database Systems: Design, Implementation, & Manag…
Computer Science
ISBN:
9781337627900
Author:
Carlos Coronel, Steven Morris
Publisher:
Cengage Learning
Programmable Logic Controllers
Programmable Logic Controllers
Computer Science
ISBN:
9780073373843
Author:
Frank D. Petruzella
Publisher:
McGraw-Hill Education