Assignment 2

The goal of this assignment is to familiarize yourself with web programming techniques. Although you will (likely) need to write a small amount of HTML, CSS, or Javascript, the focus is on the technology running on the server which can be written in any language you like.

Projects

This course will finish with a project. Please submit a proposal for what you’d like to do, along with who you’re working with. Groups of 3-4 are preferred, but I’m open to suggestions. The scope of the project should reflect the size of the group.

You should support the following URLs and methods.

  • GET /project

    Return an HTML page summarizing your project proposal.

Web application

You will turn in this assignment by creating a web application. This application will serve up your answers to questions as well as provide an interface to the code you will write.

Binary heap

You will implement a a minimum priority queue via a binary heap. You will implement two versions of the heap: one using the pointer definition, and one using the array definition.

You should support the following URLs and associated operations.

  • GET /heap/<name>

    Return the status of the heap stored a the URL /heap/<name>.

    For example, a GET request to /heap/0 should return the status of heap 0.

    The status should be a human-readable representation of the heap. At the very least it should report the size of the heap and the current top element.

  • POST /heap/<name>

    Push a new element onto the heap. If the heap doesn’t exist (or is empty), create it. The pushed element should be stored in the form named value, i.e. the following HTML form could add a value to the heap 0:

    <form action="/heap/0" method="post">
      <input type="text" name="value" size=10></input>
      <input type="submit"></input>
    </form>
    
  • GET /heap/<name>/pop

    Pop and return the top element of the heap. It is an error to pop from an empty heap.

  • GET /heap/<name>/peek

    Return the top element of the heap, leaving it unchanged. It is an error to peek on an empty heap.

  • GET /heap/time/array?length=LENGTH&seed=SEED

    Time the performance of inserting LENGTH random elements onto the array heap, and then popping them all off. The random sequence should be controlled by the SEED value. You should return two values, the time required for inserting the elements and the time required for popping the elements.

  • GET /heap/time/pointer?length=LENGTH&seed=SEED

    Time the performance of inserting LENGTH random elements onto the pointer heap, and then popping them all off. The random sequence should be controlled by the SEED value. You should return two values, the time required for inserting the elements and the time required for popping the elements.

Source code

I want to be able to the code you used to create this service. Host a Git bare repository containing your work for me to clone from.

  • GET /git

    Returns the Git repository that I can clone from.

Submission

Ideally you will host your project somewhere that I can test it. This can be on a personal computer, a cloud server, or a cloud service. If you want to use a personal computer, talk to me about how we can test this (you might just end up sending me the code so I can run it locally). If you host it on a cloud server or service, send me the URL. Note that services such as Heroku and Amazon Web Services offer (some amount of) free hosting.

Regardless of how you turn in your assignment, your code should be well tested. Include these tests in your Git repository.