Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

image text in transcribed

/** * 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

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Decisions Based On Data Analytics For Business Excellence

Authors: Bastian Weber

1st Edition

9358681683, 978-9358681680

More Books

Students also viewed these Databases questions