Question: /** * This program uses a loop, in each iteration of which a string and an alphabet (given as string) are read, and the response

 /** * This program uses a loop, in each iteration of

/** * This program uses a loop, in each iteration of which a string and an alphabet (given as string) are read, and the response is true/false: whether the string is a valid regular expression over the alphabet. The empty set symbol is @. */ import java.util.*; import java.io.*; public class isREX { static boolean itIsREX (String r, String alph) { int rlen = r.length(); if (rlen == 0) return false; // the next two 'if's test the induction basis, that is, // whether r = @, or r = one of the symbols in alph if (r.equals("@")) return true; if (rlen == 1) { if (alph.indexOf(r.charAt(0)) >= 0) return true; else return false; } // At this point any valid regular expression r must be of the // form (t*) or (s+t) ot (st), where s and t are reg. express. if (rlen   PROBLEM 5 (7 marks) Consider the program isREX.java on the course website. The program contains the Boolean function itIsREX which returns whether a given string r is a mathematical regular expression over a given alphabet according to the structural induction definition in the text. However, the implementation of the function itIsREX is incomplete, as it is missing the case where the given string r is of the form (st), where s and t are regular expressions. Your task is to read the existing code in itIsREX and complete the code for the missing case. The new program isREX.java must be submitted to the course website.  PROBLEM 5 (7 marks) Consider the program isREX.java on the course website. The program contains the Boolean function itIsREX which returns whether a given string r is a mathematical regular expression over a given alphabet according to the structural induction definition in the text. However, the implementation of the function itIsREX is incomplete, as it is missing the case where the given string r is of the form (st), where s and t are regular expressions. Your task is to read the existing code in itIsREX and complete the code for the missing case. The new program isREX.java must be submitted to the course website

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!