1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
Bingel [31]
3 years ago
6

A 'array palindrome' is an array which, when its elements are reversed, remains the same (i.e., the elements of the array are sa

me when scanned forward or backward) Write a recursive, boolean-valued method, isPalindrome, that accepts an integer-valued array, and a pair of integers representing the starting and ending indexes of the portion of the array to be tested for being a palindrome. The function returns whether that portion of the array is a palindrome. An array is a palindrome if: the array is empty (0 elements) or contains only one element (which therefore is the same when reversed), or the first and last elements of the array are the same, and the rest of the array (i.e., the second through next-to-last elements) form a palindrome.

Computers and Technology
1 answer:
tia_tia [17]3 years ago
8 0

Answer:

Here is the JAVA program:

class Main {    

static boolean isPalindrome(int array[], int starting, int ending) {  /*a boolean method that takes an integer-valued array, and a pair of integers representing the starting and ending indexes of the portion of the array to be tested for being a palindrome */

   if (starting >= ending) {  //base case

       return true;     }  //returns true

   if (array[starting] == array[ending]) {  //recursive case

       return isPalindrome(array, starting + 1, ending - 1);     }  //calls isPalindrome recursively to find out palindrome

   else {  

       return false;    }  }  //returns false if array is not palindrome

 

   public static void main (String[] args) {  //start of main function

   int array[] = { 1,2,3,2,1};  //creates an array

   int size = array.length;   //computes the size of array

 System.out.print(isPalindrome(array, 0, size - 1));    } } //calls method to test array for being  a palindrome

Explanation:

The program works as follows:

array = { 1,2,3,2,1}

starting = 0

ending = size-1 = 5-1 = 4

if (starting >= ending) condition evaluates to false because starting i.e. 0 is not greater or equal to ending i.e. 4. So the program moves to the next if part

if (array[starting] == array[ending])

This becomes:

if (array[0] == array[4])

The element at 0th index is the first element of the array i.e. 1 and the element at 4th index of array is the last element of array i.e. 1. So both these elements are equal so the following statement executes:

return isPalindrome(array, starting + 1, ending - 1);

Now the starting and ending become:

starting+1 = 0+1 = 1

ending-1 = 3

if (starting >= ending) base condition evaluates to false because starting  is not greater or equal to ending. So the program moves to the next if part

if (array[starting] == array[ending])

This becomes:

if (array[1] == array[3])

The element at 1st index is 2 and the element at 3rd index of array is 2. So both these elements are equal so the following statement executes:

return isPalindrome(array, starting + 1, ending - 1);

Now the starting and ending become:

starting+1 = 1+1 = 2

ending-1 = 2

if (starting >= ending) base condition evaluates to true because starting  is  equal to ending. So the following statement executes:

       return true;    

This means the function returns true and this shows that array is a palindrome.

The screenshot of the program and its output is attached.

You might be interested in
Is a component that provides a button control in a gui application or applet?
harina [27]
<span>GUI is a graphical user interface. It is a graphical window that provides interaction with the user. 
</span>The button is a pushbutton, which can be pressed to trigger an action.<span>
A graphic control component or a control element is a component that provides a button control in a GUI application. It is also called a control element because it </span><span>is an element of interaction between the user controlling the application.</span>
7 0
3 years ago
You suspect a component in a computer is fried. You remove any unnecessary hardware devices one by one to narrow down where the
tankabanditka [31]

The examination phase

Further Explanation:

Hardware troubleshooting in computers requires a systematic and logical approach. Taking a logical approach helps you identify the root cause much easily. Ask yourself those questions first before getting to the bottom of anything. You will find it helpful to reproduce the problem and develop a hypothesis of the problem if you ask yourself those 20 questions.

Next comes the examination phase. Having gathered everything, I will now attempt a fix based on what I think I found. In my case, I suspect that there a component in my computer that is fried. A few ways to tell if my motherboard or components attached to the motherboard are fried is to remove the side panel first and examine the circuitry before removing any unnecessary hardware devices. Obvious sings will be smell of smoke. Examine the capacitors as well. Burnt capacitors have rounded tops. This is a clear indication that they are blown.

I will now remove every single component one by one from the motherboard and test my hardware on a low-level.

Learn more about computer hardware troubleshooting

brainly.com/question/12704715

brainly.com/question/13182488

#LearnWithBrainly

8 0
3 years ago
Just answer in five-line. Question:
Eddi Din [679]

Answer:

It is a half-duplex serial transmission mode, and this can be provided through the RS-485 two wired electrical interface. And this can be connected to the ethernet if required, connect to the LAN, and finally transmitting the video footage to all the screens. And the two reasons are:

1. Noiseless

2. Allows around 32 receivers.

Explanation:

Please check the answer.

3 0
3 years ago
Electronic résumés have an attractive, highly formatted appearance. please select the best answer from the choices provided t f
Len [333]

An electronic resume can carry so much data about the person, and it includes images also. Then the statement is true.

<h3>What is an electronic resume?</h3>

An electronic resume is termed as a resume that is read by a computer program that summarizes the information of each person.

The electronic resume has the data such as their parent name, education, skills, job experience, hobbies, languages, and so on.

Thus, the photo of the document about the project or internship that has been done in the past can be given on the electronic resume by uploading the certificate on the computer system along with the resume.

For example, in companies like Linkedin, and so on there are many companies that ask about the person before creating an account.

More about the electronic resume link is given below.

brainly.com/question/2798964

4 0
2 years ago
Read 2 more answers
before donating a computer you should use a program to wipe the hardest to remove all of his data true or false
Katarina [22]
True or they could get into your stuff. 
6 0
3 years ago
Other questions:
  • The term ________ refers to the use of a single unifying device that handles media, internet, entertainment, and telephone needs
    13·1 answer
  • Suppose that sum is an int variable. The statement sum += 7; is equivalent to the statement sum = sum + 7;
    7·1 answer
  • How are the internet and the World Wide Web different from each other
    14·1 answer
  • I wonder how world is created
    12·2 answers
  • What step can Miguel take to solve his dilemma? Miguel is working on a project that requires him to switch back and forth freque
    12·2 answers
  • After reading the article, "The Impact of Technology", answer the following question.
    7·1 answer
  • [This is on Edhesive (coding and programming)]
    8·2 answers
  • If you were required to give a speech identifying the risks of using computers and digital devices, which group of items would y
    7·1 answer
  • Suppose a family has had a house fire in which
    7·2 answers
  • Kenny FRIEND ME. Ps that is my brother
    9·2 answers
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!