Question

Java 1. Write a method to search for and remove an element from a linked list,...

Java

1. Write a method to search for and remove an element from a linked list, thereby returning the data portion of the node.

2. Making use of both Stacks and Queues, write a function that will determine whether or not a String is a palindrome

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

`Hey,

Note: Brother in case of any queries, just comment in box I would be very happy to assist all your queries

import java.util.Stack;
import java.util.Scanner;
public class PalindromeTest {

public static void main(String[] args) {

   System.out.print("Enter any string:");
Scanner in=new Scanner(System.in);
String inputString = in.nextLine();
Stack stack = new Stack();

for (int i = 0; i < inputString.length(); i++) {
stack.push(inputString.charAt(i));
}

String reverseString = "";

while (!stack.isEmpty()) {
reverseString = reverseString+stack.pop();
}

if (inputString.equals(reverseString))
System.out.println("The input String is a palindrome.");
else
System.out.println("The input String is not a palindrome.");

}
}

Note: Brother according to HomeworkLib's policy we are only allowed to answer 1 part if there are many. So, I request you to post other part as separate posts.

Kindly revert for any queries

Thanks.

Add a comment
Know the answer?
Add Answer to:
Java 1. Write a method to search for and remove an element from a linked list,...
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
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