Write your programs using any programming language

Assignment Help Data Structure & Algorithms
Reference no: EM132226959

You can write your programs using any programming language you prefer. Upload your programs (source code) and screen dumps that show your program execution

Question 1. 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

Question 2. Write a program that uses the brute-force approach to solve the 0/1 knapsack problem. Suppose there are n items with weights w1, w2, ..., wn and values v1, v2, ..., vn and a knapsack of capacity W. Use the decrease-by-one technique to generate the power set and calculate the total weights and values of each subset, then find the largest value that fits into the knapsack and output that value.
For example: If there are 3 items with the following weights and values:

weight: 8 4 5
value: 20 10 11
and the capacity of the knapsack is 9, your program should then calculate the total weight and the total value of each subset in the power set:
total weight of subset: 0, 8, 4, 12, 5, 13, 9, 17
total value of subset: 0, 20, 10, 30, 11, 31, 21, 41

The largest value that fits into the knapsack: 21.

Reference no: EM132226959

Questions Cloud

What is the optimal order quantity for refillable mugs : What is the optimal order quantity (EOQ) for refillable mugs? When should the shop owners re-order another delivery of refillable mugs?
Identify variables within structures or institutions : Write a 3-page blog post that explains how individual perceptions of power can create conflict situations between law enforcement and members of a community.
Research the ethical issue affecting the company : Research the ethical issue affecting the company you have chosen to research. Design an ethical code for the chosen company.
What is the average number of customers standing in line : What is the average number of customers standing in line between the start of Station A and the end of Station D?
Write your programs using any programming language : Write your programs using any programming language you prefer. Upload your programs (source code) and screen dumps that show your program execution
How the conflict is affecting the rest of the organization : Identify the factors that may be responsible for causing the conflict. Explain how the conflict is affecting the rest of the organization.
Average service time per call over the two hour period : What was the average service time per call during the first hour of the shift? What was the average service time per call over the two hour period?
What are five different definitions of communication : What are five (5) different definitions of communication from at least five (5) different sources.
Discuss about three dimensional virtual environment : Online learning is considered a virtual learning environment (VLE); however there are other types of VLE that you may have used or heard about.

Reviews

Write a Review

Data Structure & Algorithms Questions & Answers

  Implement an open hash table

In this programming assignment you will implement an open hash table and compare the performance of four hash functions using various prime table sizes.

  Use a search tree to find the solution

Explain how will use a search tree to find the solution.

  How to access virtualised applications through unicore

How to access virtualised applications through UNICORE

  Recursive tree algorithms

Write a recursive function to determine if a binary tree is a binary search tree.

  Determine the mean salary as well as the number of salaries

Determine the mean salary as well as the number of salaries.

  Currency conversion development

Currency Conversion Development

  Cloud computing assignment

WSDL service that receives a request for a stock market quote and returns the quote

  Design a gui and implement tic tac toe game in java

Design a GUI and implement Tic Tac Toe game in java

  Recursive implementation of euclids algorithm

Write a recursive implementation of Euclid's algorithm for finding the greatest common divisor (GCD) of two integers

  Data structures for a single algorithm

Data structures for a single algorithm

  Write the selection sort algorithm

Write the selection sort algorithm

  Design of sample and hold amplifiers for 100 msps by using n

The report is divided into four main parts. The introduction about sample, hold amplifier and design, bootstrap switch design followed by simulation results.

Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd