The Knapsack Problem you own this product

prerequisites
arrays • slices • passing functions to other functions
skills learned
exhaustive search • backtracking • branch and bound • Rod's technique • dynamic programming
Rod Stephens
1 week · 4-6 hours per week · BEGINNER

pro $24.99 per month

  • access to all Manning books, MEAPs, liveVideos, liveProjects, and audiobooks!
  • choose one free eBook per month to keep
  • exclusive 50% discount on all purchases

lite $19.99 per month

  • access to all Manning books, including MEAPs!

team

5, 10 or 20 seats+ for your team - learn more


Look inside

Picture this: You’ve amassed a fortune selling Instagram filters and you’re cruising the Bermuda Triangle on one of your yachts when you strike a USO (unidentified submerged object). Now you’re sinking! Your life raft isn’t big enough to salvage all of your 200 valuable objects (of varying sizes, weights, and values). To help you decide which of your treasures—the Monet, the Degas, the bust by Canova—to take with you on the raft, you’ll write a Go program that uses different approaches, including exhaustive search, branch and bound, Rod’s technique, and dynamic programming to solve the knapsack problem, a classic in computer science for situations just like this. When you’re finished, you’ll learn what the tradeoffs are, and you’ll know which of your valuables you’ll be able to save and which will end up at the bottom of the ocean!

This project is designed for learning purposes and is not a complete, production-ready application or solution.

project author

Rod Stephens

Rod Stephens started out as a mathematician but discovered the fun of algorithms and has been programming ever since. Rod was a Microsoft Visual Basic Most Valuable Professional (MVP) for 15 years, has spoken to user groups and conferences, and has taught introductory programming courses. He has written more than 35 books including Essential Algorithms: A Practical Approach to Computer Algorithms Using Python and C# and Beginning Software Engineering, both of which include material related to this series of liveProjects.

prerequisites

This liveProject is for Go programmers, from beginning level to advanced, who want to learn how to use Go to solve the classic knapsack problem. To begin these liveProjects you’ll need to be familiar with the following:

TOOLS

  • A Go compiler (such as Visual Studio Code or Online GDB)
TECHNIQUES
  • Basic math
  • Basic Go features (including arrays, structs, and slices)

features

Self-paced
You choose the schedule and decide how much time to invest as you build your project.
Project roadmap
Each project is divided into several achievable steps.
Get Help
While within the liveProject platform, get help from other participants and our expert mentors.
Compare with others
For each step, compare your deliverable to the solutions by the author and other participants.
book resources
Get full access to select books for 90 days. Permanent access to excerpts from Manning products are also included, as well as references to other resources.

choose your plan

team

monthly
annual
$49.99
$399.99
only $33.33 per month
  • five seats for your team
  • access to all Manning books, MEAPs, liveVideos, liveProjects, and audiobooks!
  • choose another free product every time you renew
  • choose twelve free products per year
  • exclusive 50% discount on all purchases
  • The Knapsack Problem project for free