Question: CSc 2720-Data Structures: Lab 3 How to Submit Please submit your answers in icollege once you have completed Failure to submit will result in a
CSc 2720-Data Structures: Lab 3 How to Submit Please submit your answers in icollege once you have completed Failure to submit will result in a zero for this lab. Problem 1: Write a function called backspaceCompare that takes two strings 1 and s2 and evaluate them when both are typed into empty text editors. (# means a backspace character) back spaceconpare should return true if the evaluated strings are equal or false if they are not equal. You should make use of the built-in java implementation of the stack data structure under java.util.Stack. (assume that the user inputs correct strings) Example 1 Input: s1 "DatastructuresissssassFuns2"DataStructuresIszwpasFun Output: true Explanation: Both s1 and s2 become "DataStructuresIsFun Example 2 Output: false Explanation: si becomes "a while s2 becomes import java.util.Stack; public class Lab3 ( public static void main (String[] args)( String sl . "Datastructures|ssssss#un". String s2 DataStructuresiszwp Fun boolean ans backspaceCompare(si, s2); System.out println(ans) Should be True public static boolean backspaceCompare(String s, String s2) StackcCharacter> s1 stack-new StackcCharacter>) StackcCharacter> s2stack - new StackcCharacter>); stack.push("D" stack.peeko stack.pop) stack. SEnpty( ) // Example of push Example of peek Example of pop // Example of isEmpty IINSERT YOUR CODE HERE
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
