Those are JAVA Programs. Please
write them in recursions , it requires the methods have to be
recursive(I understood how to write them by using for loop).
Please don't use
any syntax beyond chapter of Recursion. I only covered the
materials to recursions and the materials before recursion chapter.
Appreciated!

public class RecursiveMethodsUtil {
public static void writeSqaures(int n) {
if(n == 1) {
System.out.print("1 ");
} else if(n > 1) {
if(n % 2 == 0) {
System.out.print((n-1)*(n-1) + " ");
writeSqaures(n-2);
System.out.print(n*n + " ");
} else {
System.out.print(n*n + " ");
writeSqaures(n-2);
System.out.print((n-1)*(n-1) + " ");
}
}
}
public static boolean isPalindrome(String s) {
if(s.length() <= 1) {
return true;
} else {
if(s.charAt(0) != s.charAt(s.length()-1)) {
return false;
} else {
return isPalindrome(s.substring(1, s.length()-1));
}
}
}
public static void main(String[] args) {
writeSqaures(8);
System.out.println();
writeSqaures(11);
System.out.println();
writeSqaures(1);
System.out.println();
writeSqaures(0);
System.out.println();
System.out.println(isPalindrome("madam"));
System.out.println(isPalindrome("racecar"));
System.out.println(isPalindrome("step on no pets"));
System.out.println(isPalindrome("Java"));
}
}

Those are JAVA Programs. Please write them in recursions , it requires the methods have to be...
Please write in java
Write a main program that runs the following two recursive methods demonstrating that they work. #1) Write a recursive method writeSquares that accepts an integer n and prints the first n squares with the odd squares in decending order, followed by the even squares in acending order. For example • writeSquares(8): prints . 49 25 9 1 4 16 36 64 • writeSquares(11); prints 121 81 49 25 9 1 2 16 36 64 100 •...
Please i need programs in C 32) Write a function that, given a string, a width, and an empty string for output, centers the string in the output, centers the string in the output area. The function is to return 1 if the formating is successful and 0 if any errors, such as string length greater than width, are formed. 35) Write a function called newStrCmp that does the same job as strcmp. The declaration for your functions is to...
can someone please help me with this. I need to use
java.
Recursion Write and run a program that reads in a set of numbers and stores them in a sequential array. It then calls a recursive function to sort the elements of the array in ascending order. When the sorting is done, the main function prints out the elements of the newly sorted array Hint: How do you sort an array recursively? Place the smallest element of the array...
Create two Java classes called Recursive, RecursiveDemo. Write four methods a- int sum_sqr_rec(stack<int> stk) which will receive a stack of "int" and output the sum of the squares of the elements in the stack. b- int plus_minus_rec(stack<int> stk) which will receive a stack of "int" (example: {a,b,c,d,e,f,g,h,i,j}) and output the sum of the elements in the stack as follows: a - b + c - d + e - f + g - h + i -j c- void prt_chars_rev_rec(stack<char>...
3. Write Java methods to accomplish each of the following Write a method named simpleAry which accepts and return nothing. It creates an array that can hold ten integers. Fill up each slot of the array with the number 113. Then, display the contents of the array on the screen. You must use a loop to put the values in the array and also to display them. Write a method named sury which accepts an array of type double with...
write in java 1. Assume the availability of a method named makeLine that can be passed a non-negative integer n and a character c and return a String consisting of n identical characters that are all equal to c. Write a method named printTriangle that receives two integer parameters n and k. If n is negative the method does nothing. If n happens to be an even number, itsvalue is raised to the next odd number (e.g. 4-->5). Then, when k has the value zero, the method prints...
Assignment 6, Merge Arrays (java) Instructions In this assignment, you will write a program which merges two arrays of positive integers and removes any duplicate entries. Your program will first ask for a valid length which must be an integer which is 10 or greater. The program should continue to ask until a valid length is entered. The program will then create two arrays of the length entered, fill these with random integers between 1 and 100 inclusive, and print...
Assignment 2 In this assignment, you will write two short programs to solve problems using recursion. 1. Initial Setup Log in to Unix. Run the setup script for Assignment 2 by typing: setup 2 2. Towers of Hanoi Legend has it that in a temple in the Far East, priests are attempting to move a stack of disks from one peg to another. The initial stack had 64 disks threaded onto one peg and arranged from bottom to top by...
JAVA LANG PLEASE: I have follwed these below guidelines but when i run my queue test it is not executing but my stack is working fine, can you fix it please! MyQueue.java Implement a queue using the MyStack.java implementation as your data structure. In other words, your instance variable to hold the queue items will be a MyStack class. enqueue(String item): inserts item into the queue dequeue(): returns and deletes the first element in the queue isEmpty(): returns true or false...
Hallo! I have a problem in my code, I need help please in java code. My task is : Write a program that can read a text from a file and do frequency analysis on the letters that occur . To store information (frequency) you must use an array. Tip! The place where you collect the frequency of eg the letter A is the equivalent of the ASCII code of "A" ie 65. The array should be 127 elements. For...