Use java to write the programs1 write a program that uses

Assignment Help Computer Engineering
Reference no: EM13379923

Use java to write the programs

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

2. Let a[0..n-1] be an array of n distinct integers. A pair (a[i], a[j]) is said to be an inversion if these numbers are out of order, i.e., i<j but a[i] > a[j].

For example: if array a contains the following numbers: 9, 8, 4, 5?then the number of inversions is 5.  ?(inversions are 9 > 8, 9 > 4, 9 > 5, 8 > 4, 8 > 5)

(a) Write a program that uses the brute-force approach to count the number of inversions in the array.

(b) Write a program that uses the divide-and-conquer technique to count the number of inversion in the array.

Reference no: EM13379923

Questions Cloud

Write a c program that displays a table showing the price : write a c program that displays a table showing the price of silver and gold. the table will have three columns. the
A multinational tour operator agency has gained new : a multinational tour operator agency has gained new business growth in the north american market through the use of
1 in platosrepublic glaucon presents a three-part argument : 1. in platosrepublic glaucon presents a three-part argument meant to show that justice is not natural but rather
The aim of this assignment is for you to think about the : the aim of this assignment is for you to think about the appropriateness of different kinds of conceptual models that
Use java to write the programs1 write a program that uses : use java to write the programs1. write a program that uses the brute-force approach to solve the 01 knapsack problem.
Wireless data center networking1a what do you think is the : wireless data center networking1.a what do you think is the traffic demand information in this research i.e. what
From your knowledge and experience how are computer : from your knowledge and experience how are computer forensic investigators in todays world of complex technology are
An information technology recruiting firm has been growing : an information technology recruiting firm has been growing rapidly over the past few years. the number of clients over
One of the needs that your client has is a databaseto : one of the needs that your client has is a database.to design a database a database planner should spend a considerable

Reviews

Write a Review

Computer Engineering Questions & Answers

  Question1 provide an executive overview that addresses as

question1. provide an executive overview that addresses as following-describe the benefits and current trends of data

  Questiona company is involved in initial software a new

questiona company is involved in initial software. a new director has made a unilateral decision to compel electronic

  What could possibly be used as a key field

I need help with doing some web search research on relational databases and define briefly how such a database works, and basic components.

  Write one exception class that includes multiple exceptions

How would you write one exception class that includes multiple exceptions, for example, if a file is not found and if an array is not dynamically allocated properly. (C++)

  Write down the worst cardiac simulator of all time

make the worst CARDIAC simulator of all time (in C++) that tells the user how to execute only a single instruction typed as a 3 digit number by the user.

  Oriented programming paradigm is considered a better choice

express why the object oriented programming paradigm is considered a better choice than the structured programming paradigm. Does it reflect our "natural" way of thinking or do you find it artificial?

  How can state the units for each metric

express the units for each metric, such as dollars per hour, rejects per day, schedule slippage per task in days, budgeted versus actual cost expenditure per task,etc. One character in a group I once had expressed the progress of laying a cable in..

  Explaining troubleshooting

AV software has removed the malware from highly infected system. After first reboot, an error message is showed which consists of a reference to the strange DLL file which is missing. Explain two options you must use in order to start troubleshoot..

  Program on bst

Program on BST

  How to create a poster or presentation

For an on line poster presentation, you need to use PowerPoint, Visio, MS Word, or another program that allows you to use graphics and pictures along with words to tell a story. Posters are created to tell a visual story so the intent is to use le..

  Why throw and handle an appropriate exception

Write down a C++ program that prompts the user to enter a length in feet and inches and outputs the equivalent length in centimeters. If the user enters a negative number or a non-digit number, throw and handle an appropriate exception and prompt ..

  What is the least number of tcp segments

The following questions is related to TELNET. A user types cp file1 file2. What is the minimum number of TCP segments exchanged if the transfer uses the following mode. Explain the answer.

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