Question: Please help me code the following in: JAVA Please use many COMMENTS Full points will be awarded, thanks in advance! UsingStackSuitorsLab class: import java.util.LinkedList; import
Please help me code the following in: JAVA
Please use many COMMENTS
Full points will be awarded, thanks in advance!

UsingStackSuitorsLab class:
import java.util.LinkedList;
import java.util.Queue;
public class UsingStacksSuitorsLab implements Runnable {
private static int threadCount = 0;
private String name;
public UsingStacksSuitorsLab() {
name = "#" + threadCount++ + "Thread";
}
public static void main(String[] args) {
String s1 = "food"; /ot a palindrome
String s2 = "racecar"; //a palindrome
System.out.println("String1 is \"" + s1 + "\"");
System.out.println("String2 is \"" + s2 + "\"");
/* System.out.println(s1 + " reversed is: ");
printReverse(s1);
System.out.println(s2 + " reversed is: ");
printReverse(s2);
recPrintReverse(s1);
System.out.println();
recPrintReverse(s2);
System.out.println();
System.out.println(s1 + " is a palindrome: " + isPalindrome(s1));
System.out.println(s2 + " is a palindrome: " + isPalindrome(s2));
System.out.println(s1 + " is a palindrome(recursively): " + isPalindromeRec(s1));
System.out.println(s2 + " is a palindrome(recursively): " + isPalindromeRec(s2));
System.out.println("Did we build a Queue of Threads and start them? " + buildThreadQueue());
int n = 6;
System.out.println("For " + n + " suitors, stand in place:" + findPlaceToStand(n));
n = 10;
System.out.println("For " + n + " suitors, stand in place:" + findPlaceToStand(n));*/
}
public static void printReverse(String target) {
//todo: use a stack
}
public static void recPrintReverse(String target) {
//todo
}
public static boolean isPalindrome(String input) {
//todo: use a stack
}
public static boolean isPalindromeRec(String sentence) {
//todo
}
public static int findPlaceToStand(int numSuitors) {
//todo
return -1;
}
public static boolean buildThreadQueue() { //returns true upon success
Queue
//when our program starts up, it might create multiple threads to use
//q.enqueue( new Thread(new UsingStacksSuitorsLab()));
System.out.println("Initial Thread order:");
q.toString();
//We need to iterate over our pool of threads and call start() on each one
//Make a loop that dequeues a thread, calls start on it, and enqueues it again
//for(?) {
Thread curreent = q.deque();
current.start();
q.enqueue(current);
/* current = get a thread
current.start();
put the thread back
}*/
System.out.println("Thread order after start()ing:");
q.toString();
return true; //on successful start
}
/*
* No need to edit anything below here,
* unless you'd like to change the
* behaviour of each thread in the thread pool above
*/
@Override
public void run() {
for(int i = 0; i
System.out.println(name + ": " + i + "th iteration");
try {
Thread.sleep(10);
} catch (InterruptedException e) {
//do nothing here
}
}
}
}
Palindromes &Stacks Iteratively In this section, we'll determine that the String "bob" is a palindrome while "food" is not, both iteratively and recursively. Start by uncommenting the lines of code that call isPalindrome) in main, and... In main, uncomment out all calls to isPalindrome) . Find the isPalindrome) function in the driver and look at how it's called from main Inside of isPalindrome, do the following: o Declare a stack to use from the previous labs (the linked Stack is preferable here) If your Stack is broken, you can consider using Java's Stack Stack
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
