Algorithms and OOD (CSC 207 2013F) : Assignments

Assignment 9: Miscellaneous


This assignment is currently in draft form.

Due: 10:30 p.m., Tuesday, 12 November 2013

Summary: In this assignment, you will explore the implementation of sorting algorithms.

Purposes: To help you in your future analysis of algorithms. To help you think more about the use of stacks.

Collaboration: I encourage you to work in groups of size two or three, although you may also work alone. You may discuss this assignment with anyone, provided you credit such discussions when you submit the assignment.

Wrapper (Prologue): Individually read through this assignment and make sure that you understand what is required. Then use the form available at http://bit.ly/207hw9pro to indicate (a) how long you think this assignment will take and (b) what you think will be the most challenging aspect of this assignment.

Wrapper (Epilogue): When you are done with the assignment, fill out the form available at http://bit.ly/207hw9epi to indicate (a) how long the assignment took, (b) what the most challenging part of the assignment was, and (c) something important you learned from doing the assignment. If you find that the assignment took much less or much more time than you expected, also include (d) a note as to what might have led to that difference.

Submitting: Please put all of your work in a GitHub repository named csc207-hw9. Email me the address of that repository. Please title your email “CSC207 2013F Assignment 9 (Your Names)”.

Warning: So that this assignment is a learning experience for everyone, we may spend class time publicly critiquing your work.

Problems

1. In class, we've looked at a few recurrence relations that model the running time of algorithms and informally found their “closed form” (non-recursive) solution. Using similar techniques, find the closed form of the following recurrence relations.

  • f0(1) = 1. f0(n) = n + f0(n/2).
  • f1(1) = 1. f1(n) = n + f1(n-1).
  • f2(1) = 1. f2(n) = c + f2(n-1), for some constant c.
  • f3(1) = 1. f3(n) = c + f3(n/2), for some constant c.
  • f4(1) = 1. f4(n) = n + 2*f4(n/2).
  • f5(1) = 1. f5(n) = c + 2*f5(n/2), for some constant c.
  • f6(1) = 1. f6(n) = c + 2*f6(n-1), for some constant c.
  • f7(1) = 1. f7(n) = n + 2*f7(n-1). (This one is optional.)

2. Implement a RPN calculator. You should support input of real numbers and the following operations:

  • +, -, *, / - the standard arithmetic operators;
  • p - print the top value on the stack;
  • s - print the whole stack;
  • c - clear the stack; and
  • one other interesting operation of your choice.

Although it doesn't have exactly the same interface, you can experiment with the command-line RPN calculator dc to help understand these operations. (I don't think dc provides s.)

Copyright (c) 2013 Samuel A. Rebelsky.

Creative Commons License

This work is licensed under a Creative Commons Attribution 3.0 Unported License. To view a copy of this license, visit http://creativecommons.org/licenses/by/3.0/ or send a letter to Creative Commons, 543 Howard Street, 5th Floor, San Francisco, California, 94105, USA.