Algorithms and OOD (CSC 207 2013F) : EBoards

CSC207.01 2013F, Class 35: Implementing Queues with Arrays


Overview

Prelim

Admin

HW 8

_Why can't I write?

T[] vals = new T[size];

Short answer: Java has design issues.

Medium answer: Lots of subtleties in Java's parameterized classes. More precisely, it can't know at compile time what T is, which makes it hard to generate the code to build the array.

Hack answer:

@SuppressWarnings({"unchecked"})
void myproc() {
    T[] vals = (T[]) new Object[size];
} // myproc()

_Can I merge in place in O(n) time?

No. Well, maybe, but it's not worth the time to figure it out.

_Does iterative mergesort have to run in O(nlogn) time?

Yes, your implementation does.

Ideas from last class

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.