Time remaining:
Stacks : Character Matching

label Programming
account_circle Unassigned
schedule 0 Hours
account_balance_wallet $5

2 Stacks: Character Matching

Consider the following Java interface for stacks:

public interface Stack<T>{

public T pop(); // returns the top element

// and removes it from the stack

public T top(); // returns top element without removal

public void push(T item); // adds an item to the top

public boolean isEmpty(); // returns true if stack is empty

}

Write a non-recursive Java metho d with the signature:

public static boolean matchTest(String cand);

that returns

true

if and only if

cand

is

balanced

in its characters. A string is balanced in

its characters if:

1.

it is empty

2.

it has the form

a xs a

where the

xs

consists of zero or more strings that are balanced

in their characters.

Thus, the following strings:

abbcdeedca

aa

112211

12233441

are all balanced in their characters.

matchTest

must

use a

Stack

to carry out its task

Oct 17th, 2017
it not possible
Jun 29th, 2013

Studypool's Notebank makes it easy to buy and sell old notes, study guides, reviews, etc.
Click to visit
The Notebank
...
Oct 17th, 2017
...
Oct 17th, 2017
Oct 18th, 2017
check_circle
Mark as Final Answer
check_circle
Unmark as Final Answer
check_circle
Final Answer

Secure Information

Content will be erased after question is completed.

check_circle
Final Answer