Java : Write the Java code segment that uses a stack to determine if a string is a palindrome (assume all that blanks have been removed). A palindrome contains the same characters forwards as backwards, for example level is a palindrome. Your solution must use only a stack, you MUST process the string from left to right, and are allowed to go through the string only once.
Java :
Write the Java code segment that uses a stack to determine if a string is a palindrome (assume all that blanks have been removed). A palindrome contains the same characters forwards as backwards, for example level is a palindrome. Your solution must use only a stack, you MUST process the string from left to right, and are allowed to go through the string only once. You must use an efficient
Use :
ArrayStack class given below:
/**
* Creates an empty stack using the default capacity.
*/
public ArrayStack()
{
this(DEFAULT_CAPACITY);
}
/**
* Creates an empty stack using the specified capacity.
* @param initialCapacity the initial size of the array
*/
public ArrayStack(int initialCapacity)
{
top = 0;
stack = (T[])(new Object[initialCapacity]);
}

Trending now
This is a popular solution!
Step by step
Solved in 2 steps with 1 images









