Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Exercise 2 (20 pts) Consider the problem of counting, in a given text, the number of substrings that start with an A and end with

image text in transcribed

Exercise 2 (20 pts) Consider the problem of counting, in a given text, the number of substrings that start with an A and end with a B. For example, there are four such substrings in CGHABDFGAGHAHGHBS. Assume all input and output is in upper case. 1. Design a brute-force algorithm for this problem and determine its efficiency class (order of growth). Implement a method to do this and a main method to run the program. 2. Design and implement a more efficient algorithm for this problem as a method and invoke it from the same main program as written above. In implementing your program, read in the input as shown (the first line is the string, the second line is the starting substring, and the third line is the second substring: SAMPLE INPUT: CGHABDFGAGHAHGHBS A B Your output will consist of a single integer, displaying the number of substrings: SAMPLE OUTPUT: 4

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

Step: 3

blur-text-image

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

DB2 11 The Database For Big Data And Analytics

Authors: Cristian Molaro, Surekha Parekh, Terry Purcell, Julian Stuhler

1st Edition

ISBN: 1583473858, 978-1583473856

More Books

Students also viewed these Databases questions

Question

2. Identify issues/causes for the apparent conflict.

Answered: 1 week ago

Question

3. What strategies might you use?

Answered: 1 week ago