Question
Week 4 Summary In this weeks summary, the dispatch department has contacted you with a new problem. Once they receive a new order, they have
Week 4 Summary
In this weeks summary, the dispatch department has contacted you with a new problem. Once they receive a new order, they have to look for each product's availability in the existing warehouses. The preference is to ship from the minimum amount of warehouses and to always ship from the warehouse that contains the maximum amount of units.
For example, review the following order (number 10333) that was received by the dispatch department this morning:
Product ID | Amount |
0001 | 10 |
0005 | 12 |
0003 | 3 |
0002 | 4 |
Be sure to also review the following diagram that shows the warehouse and the list of available products:
| Warehouse 1 | Warehouse 2 | Warehouse 3 |
Product 001 | 10 | 3 | 100 |
Product 002 | 0 | 7 | 6 |
Product 003 | 3 | 4 | 1 |
Product 004 | 4 | 4 | 4 |
Product 005 | 7 | 1 | 4 |
The ideal shipment would be as follows:
Product ID | Units | Warehouse |
0001 | 10 | 1 |
0005 | 7 | 1 |
| 1 | 2 |
| 4 | 3 |
0003 | 3 | 2 |
0002 | 4 | 2 |
Complete the following:
What approach would you follow to create an algorithm to solve this particular problem? Brute force or greedy? Explain the logic that you follow for your choice.
Present the algorithm either using pseudocode or a flowchart. (C++)
A brute-force algorithm solves a problem in the most simple, direct or obvious way. As a result, such an algorithm can end up doing far more work to solve a given problem than a more clever or sophisticated algorithm might do. On the other hand, a brute-force algorithm is often easier to implement than a more sophisticated one and, because of this simplicity, sometimes it can be more efficient.
Typically, a brute-force algorithm solves such a problem by exhaustively enumerating all the possibilities. I.e., for every decision we consider each possible outcome.
A greedy algorithm is one that makes the sequence of decisions (in some order) such that once a given decision has been made, that decision is never reconsidered. Greedy algorithms can run significantly faster than brute force ones. Unfortunately, it is not always the case that a greedy strategy leads to the correct solution.
Save your Word document.
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started