Programming

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}.

Do You Need A Similar Assignment?

Place an order with us. Our skilled and experienced writers will deliver a custom paper which is not plagiarized within the deadline which you will specify.

Note; 6 Hours urgent orders deliver also available.

If you need more clarifications contact our support staff via the live chat for immediate response.

 

Type of paper Academic level Subject area
Number of pages Paper urgency Cost per page:
 Total: