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

  Crypto device encryption

A foreign navy has implemented the secure communications system where submarine commanders transmit the single 5- letter message every day.

  Questionexplain contents of an initially empty avl tree at

questionexplain contents of an initially empty avl tree at the end of each of following sequences of operations-i.

  Relationship between mis and information technology

What is the relationship between management information systems and information technology (IT).

  Questionmodify this function to check to see if one list is

questionmodify this function to check to see if one list is a shallow copy of other.def firstmismatchlst1 lst2-list of

  Create program with a gui in vb.net

write down a program with a GUI in VB.Net (not Web based). Make it so that the user can input the amount and term of the mortgage as well as the interest rate.

  Write a member function called display

Write a member function called Display that displays the elements of an object of type queueClass. Assume the pointer-based queue is in use, and note that you are writing a member function of the class, so you have access the private data members.

  Definition of method dashedline

Write down the definition of the method dashedLine , with one parameter, an int. If parameter is negative or zero, method does nothing.

  What do you mean by the tip

"How to Use JavaScript to Liven up your Web site, how to protect users whose browsers will not load JavaScript. What is the tip? would Web site designers write JavaScript code so all browsers can use it? Why?

  A class named customerrecord that holds customer number

create a class named CustomerRecord that holds a customer number, name, and address. Include methods to set the values for each data field and output the values for each data field. design the class diagram and write the code (not language specifi..

  What aspects of environment support structure of colleges

What aspects of environment support structure of colleges.

  Assume the user enters 4 and 5 in the initial form

while the user clicks a button, display the appropriate results on the second form. For example, suppose the user enters 4 and 5 in the initial form and clicks the "Compute Area" button.

  Write out a program that acts as a simplified eliza

write out a program that acts as a simplified Eliza using prolog but I can't even figure out where to start. Here are the steps I have to follow. 1. accept a sentence that is typed in by the user as a list.

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