Many encoded strings contain delimiters. A delimiter is a non-empty string that acts as a boundary between different parts of a larger string. The delimiters involved in this question occur in pairs that must be balanced, with each pair having an open delimiter and a close delimiter. There will be only one type of delimiter for each string. The following are examples of delimiters.
Example 1
Expressions in mathematics use open parentheses "(" and close parentheses ")" as delimiters. For each open parenthesis, there must be a matching close parenthesis.
(x + y) * 5 is a valid mathematical expression.
(x + (y) is NOT a valid mathematical expression because there are more open delimiters
than close delimiters.
HTML uses <B> and </B> as delimiters. For each open delimiter <B>, there must be a matching close
Example 2 delimiter </B>.
<B> Make this text bold </B>
<B> Make this text bold </UB>
is valid HTML.
is NOT valid HTML because there is one open delimiter and no matching close delimiter.
In this question, you will write two methods in the following Delimiters class. public class Delimiters
{
/** The open and close delimiters. */ ;
;
/** Constructs a Delimiters object where open is the open delimiter and close is the
* close delimiter.
* Precondition: open and close are non-empty strings. */
public Delimiters(String open, String close)
{
openDel = open;
closeDel = close;
private String openDel
private String closeDel
}
/** Returns an ArrayList of delimiters from the array tokens, as described in part (a). */ public ArrayList<String> getDelimitersList(String[] tokens)
{ /* to be implemented in part (a) */ }
/** Returns true if the delimiters are balanced and false otherwise, as described in part (b). * Precondition: delimiters contains only valid open and close delimiters.
*/
public boolean isBalanced(ArrayList<String> delimiters)
{ /* to be implemented in part (b) */ }
// There may be instance variables, constructors, and methods that are not shown. }
Trending nowThis is a popular solution!
Step by stepSolved in 2 steps
- Let Σ= {Ac,BA,bcb,cd,ab,d,i}. Find the length for the given below strings• dbcbdBAAcdab• BAdddBAAcbcbab• bcbibcbiAcibcbiiiarrow_forwardComputer Science You must count the number of strings of length 6 over the alphabet A = {x, y, z}. Any string of length 6 can be considered as a 6-tuple. For example, the string xyzy can be represented by the tuple (x,y,z,y). So the number of strings of length 6 over A equals the number of 6-tuples over A, which by product rule is N. Find N. (Use the following product rule for any finite set A and any natural number n : |A^n|=|A|^n)arrow_forward2. Build CFG to generate all strings of the form 0 1 ", where n is greater or equal to 0. Please demonstrate the derivation of 111000000111arrow_forward
- Let 2= (0,1). Compute the language of the regular expression. ((01 +10) (1(11)")arrow_forwardJava, I am not displaying my results correct. It should add up the digits in the string. input string |result for the sumIt Recursion functions and a findMax function that finds the largest number in a string "1d2d3d" | 6 total "55" |10 total "xx" | 0 total "12x8" |12 Max number "012x88" |88 Max Number "012x88ttttt9xe33ppp100" |100 Max Number public class Finder { //Write two recursive functions, both of which will parse any length string that consists of digits and numbers. Both functions //should be…arrow_forwardUp for the count def counting_series (n): The Champernowme word 1234567891011121314151617181920212223., also known as the counting series, is an infinitely long string of digits made up of all positive integers written out in ascending order without any separators. This function should return the digit at position n of the Champernowne word. Position counting again starts from zero for us budding computer scientists. Of course, the automated tester will throw at your function values of n huge enough that those who construct the Champernowne word as an explicit string will run out of both time and space long before receiving the answer. Instead, note how the fractal structure of this infinite sequence starts with 9 single-digit numbers, followed by 90 two-digit numbers, followed by 900 three-digit numbers, and so on. This observation gifts you a pair of seven league boots that allow their wearer skip prefixes of this series in exponential leaps and bounds, instead of having to crawl…arrow_forward
- Language - Java Generate 5000 random numbers in the range of [-16 to +16] both values are inclusive. Find and print the average of all of these 5000 random numbers.arrow_forwardQuestion 1: As you are a student of university now, you need to ensure your assignments are plagiarism-free. To do this, you decide to design a simple plagiarism checker. Your checker will take 2 strings as input. Then it will compare the 2 strings and check how many words they have in common. Then, print the percentage in common, by calculating: (No. of words in common / (No of words in string 1+ No of words in string 2)) * 100. If the calculated plagiarism is greater than or equal to 30%, print "Plagiarism detected." Otherwise, print "Good job!". Note: you need to compare "words" not individual characters. You can consider that all characters in both inputs will be in only lowercase or uppercase. ========= ======== Sample Input 1: my dog's name is bob bob is my dog's name Sample Output 1: Common percentage: 50% Plagiarism detected. Explanation 1: Length of string1= 5, Length of string2= 5, number of common words= 5. Hence, common percentage= (5/(5+5))*100 = 50 %3D Sample Input 2: my…arrow_forwardWrite a progprogram in python language that take a string from user and print that and then take a integer and from that position remove the element from the stringarrow_forward
- Database System ConceptsComputer ScienceISBN:9780078022159Author:Abraham Silberschatz Professor, Henry F. Korth, S. SudarshanPublisher:McGraw-Hill EducationStarting Out with Python (4th Edition)Computer ScienceISBN:9780134444321Author:Tony GaddisPublisher:PEARSONDigital Fundamentals (11th Edition)Computer ScienceISBN:9780132737968Author:Thomas L. FloydPublisher:PEARSON
- C How to Program (8th Edition)Computer ScienceISBN:9780133976892Author:Paul J. Deitel, Harvey DeitelPublisher:PEARSONDatabase Systems: Design, Implementation, & Manag...Computer ScienceISBN:9781337627900Author:Carlos Coronel, Steven MorrisPublisher:Cengage LearningProgrammable Logic ControllersComputer ScienceISBN:9780073373843Author:Frank D. PetruzellaPublisher:McGraw-Hill Education