Dave Risch. Project Specifications There is a “knapsack” that you want to fill with the most valuable items that are available to you. Each item has a.

Slides:



Advertisements
Similar presentations
CS Section 600 CS Section 002 Dr. Angela Guercio Spring 2010.
Advertisements

Knapsack Problem Section 7.6. Problem Suppose we have n items U={u 1,..u n }, that we would like to insert into a knapsack of size C. Each item u i has.
Algorithm Design Techniques: Greedy Algorithms. Introduction Algorithm Design Techniques –Design of algorithms –Algorithms commonly used to solve problems.
Knapsack Problem: Greedy vs. Brute Force pp (Section 7.6)
CSCE 411H Design and Analysis of Algorithms Set 8: Greedy Algorithms Prof. Evdokia Nikolova* Spring 2013 CSCE 411H, Spring 2013: Set 8 1 * Slides adapted.
CS223 Advanced Data Structures and Algorithms 1 Greedy Algorithms Neil Tang 4/8/2010.
Chapter 5 Fundamental Algorithm Design Techniques.
Greedy Algorithms Clayton Andrews 2/26/08. What is an algorithm? “An algorithm is any well-defined computational procedure that takes some value, or set.
Greed "Greed is good. Greed is right. Greed works. Greed clarifies, cuts through, and captures the essence of the evolutionary spirit." Gordon Gecko (Michael.
Greed is good. (Some of the time)
This title is orange because of Halloween. It is totally not because it’s always orange.
The Greedy Approach Chapter 8. The Greedy Approach It’s a design technique for solving optimization problems Based on finding optimal local solutions.
Chapter 4 The Greedy Approach. Minimum Spanning Tree A tree is an acyclic, connected, undirected graph. A spanning tree for a given graph G=, where E.
Lecture 3: Greedy Method Greedy Matching Coin Changing Minimum Spanning Tree Fractional Knapsack Dijkstra's Single-Source Shortest-Path.
Greedy vs Dynamic Programming Approach
18 = = = = = = = =
0-1 Knapsack Problem A burglar breaks into a museum and finds “n” items Let v_i denote the value of ith item, and let w_i denote the weight of the ith.
3 -1 Chapter 3 The Greedy Method 3 -2 The greedy method Suppose that a problem can be solved by a sequence of decisions. The greedy method has that each.
CPSC 411, Fall 2008: Set 4 1 CPSC 411 Design and Analysis of Algorithms Set 4: Greedy Algorithms Prof. Jennifer Welch Fall 2008.
© 5/7/2002 V.S. Subrahmanian1 Knapsack Problem Notes V.S. Subrahmanian University of Maryland.
Greedy Algorithms Reading Material: Chapter 8 (Except Section 8.5)
© 5/7/2002 V.S. Subrahmanian1 Knapsack Problem Notes V.S. Subrahmanian University of Maryland.
Greedy Algorithms CIS 606 Spring Greedy Algorithms Similar to dynamic programming. Used for optimization problems. Idea – When we have a choice.
Greedy Algorithms Like dynamic programming algorithms, greedy algorithms are usually designed to solve optimization problems Unlike dynamic programming.
Week 2: Greedy Algorithms
The Knapsack Problem Input –Capacity K –n items with weights w i and values v i Goal –Output a set of items S such that the sum of weights of items in.
CPSC 411, Fall 2008: Set 4 1 CPSC 411 Design and Analysis of Algorithms Set 4: Greedy Algorithms Prof. Jennifer Welch Fall 2008.
Dynamic Sets and Data Structures Over the course of an algorithm’s execution, an algorithm may maintain a dynamic set of objects The algorithm will perform.
Algorithmic Foundations COMP108 COMP108 Algorithmic Foundations Greedy methods Prudence Wong
© The McGraw-Hill Companies, Inc., Chapter 3 The Greedy Method.
Scott Perryman Jordan Williams.  NP-completeness is a class of unsolved decision problems in Computer Science.  A decision problem is a YES or NO answer.
Minimum Spanning Trees
Design of Algorithms using Brute Force Approach. Primality Testing (given number is n binary digits)
Advanced Algorithms Analysis and Design By Syed Hasnain Haider.
Algorithms April-May 2013 Dr. Youn-Hee Han The Project for the Establishing the Korea ㅡ Vietnam College of Technology in Bac Giang.
Lecture 19 Greedy Algorithms Minimum Spanning Tree Problem.
Math for Liberal Studies.  The knapsack problem is a variation of the bin packing problems we have been discussing  This time, there is just one bin.
Spring 2008The Greedy Method1. Spring 2008The Greedy Method2 Outline and Reading The Greedy Method Technique (§5.1) Fractional Knapsack Problem (§5.1.1)
1 The instructor will be absent on March 29 th. The class resumes on March 31 st.
Greedy Algorithms. Zhengjin,Central South University2 Review: Dynamic Programming Summary of the basic idea: Optimal substructure: optimal solution to.
Spanning Trees Dijkstra (Unit 10) SOL: DM.2 Classwork worksheet Homework (day 70) Worksheet Quiz next block.
Ch3 /Lecture #4 Brute Force and Exhaustive Search 1.
Greedy Algorithms Prof. Kharat P. V. Department of Information Technology.
Advanced Algorithms Analysis and Design By Dr. Nazir Ahmad Zafar Dr Nazir A. Zafar Advanced Algorithms Analysis and Design.
1 Ch18. The Greedy Methods. 2 BIRD’S-EYE VIEW Enter the world of algorithm-design methods In the remainder of this book, we study the methods for the.
Introduction to Algorithms: Brute-Force Algorithms.
Genetic Algorithm (Knapsack Problem)
CSCE 411 Design and Analysis of Algorithms
COMP108 Algorithmic Foundations Greedy methods
May 12th – Minimum Spanning Trees
Merge Sort 7/29/ :21 PM The Greedy Method The Greedy Method.
Greedy Algorithms (Chap. 16)
Robbing a House with Greedy Algorithms
Greedy Method     Greedy Matching     Coin Changing     Minimum Spanning Tree     Fractional Knapsack     Dijkstra's Single-Source Shortest-Path.
Heuristics Definition – a heuristic is an inexact algorithm that is based on intuitive and plausible arguments which are “likely” to lead to reasonable.
Minimum Spanning Tree.
The Greedy Method Spring 2007 The Greedy Method Merge Sort
Merge Sort 11/28/2018 8:16 AM The Greedy Method The Greedy Method.
Greedy Algorithm Enyue (Annie) Lu.
Shortest Path.
Brute Force Approaches
Analysis & Design of Algorithms (CSCE 321)
A path that uses every vertex of the graph exactly once.
Minimum Spanning Tree Algorithms
CSE332: Data Abstractions Lecture 18: Minimum Spanning Trees
Greedy Algorithms: Maximizing Loot
Merge Sort 5/2/2019 7:53 PM The Greedy Method The Greedy Method.
The Greedy Approach Young CS 530 Adv. Algo. Greedy.
Lecture 5 Dynamic Programming
Prim’s algorithm for minimum spanning trees
Presentation transcript:

Dave Risch

Project Specifications There is a “knapsack” that you want to fill with the most valuable items that are available to you. Each item has a value, weight, and value density. (which is determined by dividing the value/weight) The items then get listed in order of value density. Uses a greedy algorithm to select the highest valued items. Keeps selecting items until the weight of the next best item can’t fit. At that point, it will skip that item and look for the next item that can fit.

Goals Create a NP-hard program that uses a greedy algorithm Program will choose the best items for you to take within a certain weight capacity. Output the items, along with their values, weights and value densities.

Applications Applications that use a greedy algorithm usually fail to find the optimal solution. Yet when they do work for a certain class, they are generally used because of their speed. Greedy algorithms are used in applications such as Kruskal’s, Prim’s, and Dijkstra’s. Also used in routing. A message is forwarded to the closest neighboring node.

Design Use object programming to make items with value, weights and value densities. Put objects in an array, and sort objects in order of their densities. Loop through, choosing the highest value density objects. Add weights until the next item won’t fit the weight restriction. Skip that object and check the object after to see if it will fit and so on until the weight is maxed out. Add selected items to a list, output the item, value, weight and value density.

Testing To test the program, I will use different values, weights, value densities to see if it chooses the correct items. Use different weight restrictions to see if it will choose an item even though the item before it exceeded the max weight. Add or remove items that you can take to mix things up.

Conclusions so far After further researching, I found you can use dynamic programming to make the knapsack problem more efficient than if you use a greedy algorithm.