Difference: CSC121F2023Lab11Hint1 (1 vs. 2)

Revision 22024-03-05 - CathyBareiss

Line: 1 to 1
 
META TOPICPARENT name="CSC121F2023Lab11"

Algorithm for placing one item

  • This algorithm should be sent the 2D array and one item.
  • Assume there there is space available
  • Start with the 0'th ship
Changed:
<
<
  • While there is space and you have not checked every ship
>
>
  • While there is space, you have not placed the item, and you have not checked every ship
 
    • Start with the 0'th container on the current ship
    • While it is not placed and you have not checked every container on the current ship
      • If there is room

Revision 12023-06-22 - cathybareiss

Line: 1 to 1
Added:
>
>
META TOPICPARENT name="CSC121F2023Lab11"

Algorithm for placing one item

  • This algorithm should be sent the 2D array and one item.
  • Assume there there is space available
  • Start with the 0'th ship
  • While there is space and you have not checked every ship
    • Start with the 0'th container on the current ship
    • While it is not placed and you have not checked every container on the current ship
      • If there is room
        • place it
        • indicate that you found where to place it
      • otherwise go to the next container
    • if need be go to the next ship
  • if never placed that means there was no room
 
This site is powered by the TWiki collaboration platform Powered by PerlCopyright © 2008-2026 by the contributing authors. All material on this collaboration platform is the property of the contributing authors.
Ideas, requests, problems regarding TWiki? Send feedback