CSE 212: Programming with Data Structures

W02: Interview Question

Overview

This assignment must be completed individually to ensure you are meeting all course outcomes. You should not complete this assignment with a group. If you obtain help from a tutor, the tutor should help you understand principles but should not help you answer these problems. It is an honor code violation to obtain answers for these problems from others including using the internet (i.e. sites that allow students to share their solutions).

Instructions

This assignment is meant to simulate the kind of question you might receive in a job interview. It is important for you to understand the problem, develop a quality solution, and communicate it in a clear and professional manner.

You will need to record and upload a short video with your response to the question below. When making your video, please remember the following:

Scenario: Garden Simulator Game

You have been asked to help write a computer game that simulates planting and growing a garden. In this game, the player moves throughout the landscape trying to discover piles of seeds, which can be planted back in a garden space.

There are different kinds of seeds (for example, pumpkins, tomatoes, peas, etc.) and in each pile of seeds there may be different amounts (for example, 10, 25, 100, etc.). When the player picks up a pile of seeds it gets added to their supply basket.

After placing seeds in the supply basket, the player can then plant them. When planting seeds from the supply basket they can only plant the ones that they most recently picked up, until those seeds are all used. So for example, if they picked up a pile of pumpkin seeds, and later a pile of tomato seeds, they would have to plant all of the tomato seeds before they are able to plant the pumpkin seeds. The player cannot plant seeds if their supply basket is empty.

Once seeds have been planted, the player can water and fertilize them in any order they would like. As long as they have sufficient water and fertilizer, plants will continue to grow until they are ready to be harvested. At that point the food can be harvested, or the plant can be left alone, in which case it will eventually turn into a new pile of seeds that can be picked up.

Questions

In your video, provide a response to each of the following questions:

  1. What would be the best data structure to model the behavior of the supply basket? Justify your answer and explain how it would be used.
  2. What is the time complexity of adding new seeds to the supply basket?
  3. What is the time complexity of removing seeds from the supply basket?
  4. What is the time complexity of checking to see if the supply basket is empty?

Submission

When you have finished the video:

  1. Upload the video as a public, unlisted video.
  2. Return to I-Learn to submit a link to your video.

Other Links: