Small program on Algorithms , Data Structure & Algorithms

Assignment Help:
Objective

The goal of this project is to extend and implement an algorithm presented in the course and to apply notions introduced by the course to this program/algorithm. The assignment is relatively open-ended. The instructor will answer any question you may have. However, when in doubt, work toward the project goal stated above. This is an individual project. You may discuss it with other students, but the work you present must be your own only.

Deliverable

You will produce two items: (1) the code of the program specified below, and (2) a narrative of your work specified below. You will e-mail both items to the TA (whose address will become available in the syllabus early in the course). The items will be transmitted as attachments to your e-mail. The code will be formatted as ASCII text. The narrative will be formatted as either ASCII text or PDF. The deadline follows the rules of the homework, the beginning of the first lecture of the week following the assignment, except that you will e-mail the material rather than bringing a hard copy to class. Late submission will be accepted up to 3 days and will be penalized at 10% a day.

Code spec

Your code will extend and implement the Knapsack Problem as presented in Section 8.2 of the textbook. The extension will become clear while describing the output. Your program is expected to read a file called "input-2.txt" containing 3*k lines, li,j for i in 1,2,... k and j in 1,2,3. An example of input file is input-2.txt. For any i, line li,1 contains n positive integers separated by a comma. They are the weights W1,W2,... of a Knapsack Problem instance with n items, where n is less than 100. Likewise, line li,2 contains n positive integers separated by a comma. They are the values V1,V2,... of the items whose weights are in the previous line. Finally, line li,3 contains a single integer, the knapsack capacity. No other characters beside digits and commas are in each line.

Your program is expected to write a file called "output-2.txt" containing 5*k lines, mi,j for i in 1,2,... k and j in 1,2,...5. The output file corresponding to input-2.txt is output-2.txt. For i in 1,2,... k and j in 1,2,3, mi,j=li,j. Line mi,4 contains a single integer, the Knapsack Problem instance optimal solution. Line mi,5 contains a sequence of positive integers in increasing values. They are the indexes, starting with 1, of the items that make up an optimal solution. The general format of the output is the same as the format of the input. The extension with respect to the textbook algorithm is the generation of a set of items witnessing an optimal solution. If there is more than one set, any set is acceptable.
The weights, values, capacities and other parameters will be within reasonable ranges for a modern laptop or desktop. The programming language can be any of Java, Python, Ruby, C, and C++. Deliver all your code in a single file that can be compiled and executed on cs.pdx.edu. Your program should perform reasonably efficiently both in theory and in practice.

Narrative spec

The narrative is intended to show that you know and understand the aspects of the project related to this course, in particular, ability to: (1) extend and implement an algorithms, (2) relate theoretical complexity to practice, (3) code correct, readable and efficient programs, and (4) communicate your work clearly and concisely.

I would expect to find one or more of the following: (1) a description of the extension in the same style as the algorithm in the textbook, (2) a description of key data structures and algorithms used in the program, (3) the running time analysis of your algorithm/program, and (4) any benchmarking, profiling and/or testing employed for development.

Hints

You are encouraged to start your work early. Reading and writing the files are tasks that you already partially solved in Project 1. The Knapsack Problem is very easy to understand. Initially, you can implement a brute force program without computing the indexes. This will work for small problem instances. Then, you can replace the brute force approach with the dynamic programming approach presented in the textbook. Finally, you can introduce the extension. As the code evolves, you can use the previous version to test the current version''s correctness.

Related Discussions:- Small program on Algorithms

Exlain double linked list, Double Linked List In a doubly linked list, ...

Double Linked List In a doubly linked list, also known as 2 way lists, each node is separated into 3 parts. The first part is called last pointer field. It has the address of t

Creation of Heap, Q. Create a heap with the given list of keys: ...

Q. Create a heap with the given list of keys: 8, 20, 9, 4, 15, 10, 7, 22, 3, 12                                                  Ans: Creation

Chaining Method as Method of Collision Resolution , Q. The given values are...

Q. The given values are to be stored in a hash table 25, 42, 96, 101, 102, 162, 197 Explain how the values are hashed by using division technique of hashing with a table

Explain the concept of hidden lines and surface removal, Explain the concep...

Explain the concept of hidden lines The problem of hidden lines or surfaces was implicit even in 2-D graphics, but we did not mention it there, because what was intended to be

Algorithms, characteristics of a good algorithm

characteristics of a good algorithm

Write an algorithm insert, Q. Write an algorithm INSERT which takes a point...

Q. Write an algorithm INSERT which takes a pointer to a sorted list and a pointer to a node and inserts the node into its correct position or place in the list.  Ans: /* s

Context sensitive f1 help on a field, In what ways we can get the context s...

In what ways we can get the context sensitive F1 help on a field?' Data element documentation. Data element additional text in screen painter. Using the process on help r

Compare and contrast various sorting techniques, Q. Compare and contrast va...

Q. Compare and contrast various sorting techniques or methods with respect to the memory space and the computing time.

What is Oscillating Sort?, For the Oscillating sort to be applied, it is ne...

For the Oscillating sort to be applied, it is necessary for the tapes to be readable in both directions and able to be quickly reversed. The oscillating sort is superior to the po

Write Your Message!

Captcha
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