Access Millions of academic & study documents

GridWorld Worksheet

Content type
User Generated
Subject
Computer Science
Type
Worksheet
Showing Page:
1/9

Sign up to view the full document!

lock_open Sign Up
Showing Page:
2/9

Sign up to view the full document!

lock_open Sign Up
Showing Page:
3/9

Sign up to view the full document!

lock_open Sign Up
End of Preview - Want to read all 9 pages?
Access Now
Unformatted Attachment Preview
Overview Overview: We will start with a "strawman" approach that does NOT meet all of the requirements of the GridWorld assignment. We will analyze it and then, refine it. After each refinement, we will do a new analysis until ultimately we converge on an approach that meets all requirements. GridWorld-Strategies Page 1 Design-0 Main idea: Use a vector of "PersonInfo" structures. call this vector people Let's • The vector is indexed by personID • The PersonInfo structure contains: ○ A boolean flag: is_alive ○ Two integers row, col which indicate the district the person lives in (only meaningful if actually alive). • nRows, nCols Note: there is no explicit representation of the grid itself as a 2D array in this bare-bones approach. operation functional req? birth(r,c) whereis(id) death(id) GridWorld-Strategies Page 2 runtime req? death(id) move(id,newR, newC) population(r,c) population() members(r,c) GridWorld-Strategies Page 3 Design-1 Main idea: Extend design-0 to also have: • an RxC 2D array of "District" structures. Call this array grid (i.e., data member name) • A District structure contains: ○ An integer list called members. Details:  grid[r][c].members contains all of the people living in district (r,c) in order of seniority  assume a singly-linked list organization for now with both front/back pointers.  The list supports Queue operations (push_back and pop_front) in O(1) time (note importance of back pointer). NOTES ...
Purchase document to see full attachment
User generated content is uploaded by users for the purposes of learning and should be used following Studypool's honor code & terms of service.
Studypool
4.7
Indeed
4.5
Sitejabber
4.4