Programming

| January 28, 2015

1. (10 points) Given a string of characters, count the number of substrings that start with an A and end with a B. For example, there are four such substrings in CABAAXBYA, i.e. AB, ABAAXB, AAXB, AXB. Write a program that uses the brute-force approach to count the number of such substrings in a given string.

A sample dialogue might look like as follows:

Please enter a string: ADABCBA

The number of substrings that start with an A and end with a B is 4

2. (10 points) Given a graph (with 6 vertices) represented in adjacency matrix, write a program that uses the brute-force approach to determine whether the graph is a star as follows (i.e., there is a center vertex in the graph, and the other 5 vertices are connected to this vertex, but there is no edge between any of these 5 vertices)

3. (10 points) Write a program that uses the decrease-and-conquer algorithm as discussed in class to generate the power set of a set of nunique elements. The power set of a set S is the set of all the subsets of S, including the empty set and S itself. For example, if S is {4, 9, 5}, the power set your program should output is {}, {4}, {9}, {4, 9}, {5}, {4, 5}, {9, 5}, {4, 9, 5}.

Get a 5 % discount on an order above $ 150
Use the following coupon code :
2020Discount
Regression analysis
Types of inputs and outputs

Category: Coursework

Our Services:
Order a customized paper today!