CSC400 Final Exam Answer sheet
Depaul id# _1485030_
Answer ALL the questions.
Show all your works for Part III in order to receive full credit !
Write your answers to Part I & Part II in the table below:
Part I (40pts)
/This program is simulating a different queue for each of the 5 servers
public class IndividualQueues
final static int arrivalTimeLimit = 3600;
1. order the following functions by asymptotic growth rate:
4nlogn + 2n
3n + 100 log n
n2 + 10 n
n log n
2. Give a big-Oh characterization, in terms of n, of the running time of the methods Ex1 to Ex4 ,
shown in Code Fragmen
The class Bag
For the class Bag<T> (with extendible array, defined
in "Bag.java" written in the 10/12 class), add the following
public T remove(T elt) - This method searches
through the 'data' array to find the parameter 'elt', if it
exists, it s
The class LinkedList class (add selected methods from
Textbook Exercises on p. 164-165)
Using the class LinkedList (singly-linked) shown in the class
lecture note on Lists, add the following methods.
Note that Java has a LinkedList class which is implemen
Think Java, Chapter 7 (Iteration), Exercise 1.
o Create a new program, named LoopApp (thus
the class name is LoopApp and the filename has
to be "LoopApp.java"). Then copy the two
methods shown on the page into your program.
NOTE: There is an error in t
1. Write a program which computes the expected cost of
an item in a specified number of years. The program
asks for the cost of the item, the number of years from
now that the item will be purchased, and the rate of
inflation. The program then outputs the
Class MyLoan and an application
Name the class "MyLoan".
Write the class, and an application program in main(),
in the same file.
The class MyLoan should have the following members:
Private instance variables:
double amountBorrowed - the principal amou
Tiny Scrabble Game
This problem to implement a small application which
simulates the game of Scrabble. Your specific task is to
write two classes from scratch (LTile and RandomBag) and
complete an application class (tinyScrGame).
Class LTile - a tile in t
A A . A
if A A =
A |+| A
| +.+ |
A |+| A
A A A |=| A | + | A | + | A |
| A A | A A | A A |+| A A A |
| i =1Ai | =
| Ai |
| A A
| + + (-1) n | n=1 Ai |
Examples from the chapter 9 of the text
9.5.10 How many different ways to arrange the letters in the word MISSISSIPPI ?
1 M 4 Is 4 Ss 2 Ps
Balls in the boxes
9.6.2 How many ways to select 15 cans of soda with 5 different types
The study of the number of ways to put
things together into various combinations.
E.g. In a contest entered by 100 people,
How many different top-10 outcomes could
E.g. If a password is 6-8 letters and/or
How many passwor
public class MathamaticalFormulas cfw_
/ Mathamatical constants
final static double PI = 3.14;
final static double E = 2.71;
final static int BITS_PER_BYTE = 8;
final static int BITS_PER_NIBBLE = 4;
public static void main(String
* Compilation: javac Queue.java
* Execution: java Queue < input.txt
* Data files: http:/algs4.cs.princeton.edu/13stacks/tobe.txt
* A generic queue, implemented using a linked list.
* % java Queue < tobe.txt
* to be or not to be (2 left on q
/*This program will find the average value, mininum value, maximum value,
standard deviation, and median of a sequence of exam scores which are in the range 0 to 100*/
/This program will parse through an XML file
public class ParseXML
/This method will parse through a XML text file
public static void main(String args) cfw_
/This program is about priority queues
public class MaxPQArrayList<Key extends Comparable<Key>
private ArrayList<Key> pq; /stores items on pri
1. 1. Solve the following recurrence relation :
ak 7ak 1 10ak 2 k 2 with a0 a1 2
2. Solve the following recurrence relation :
ak 4ak 1 4ak 2 with a0 0 a1 1
3. a) Define F : Z Z by the rule F(n) = 2 -3n, for all integers n,
i) Is F one-to-one? (Prove o
1. Determine whether the relation R on the set of all people is reflexive, symmetric, antisymmetric, and/or transitive, where (a,b) R if and only if
(a) a is taller than b.
(b) a and b are born on the same day.
(c) a has the same first name as b.
/ filename: autoboxing.java
/ This program demonstrates the 'autoboxing' in Java - a primitive
/ data types (int, double, char etc.) and their respective reference
/ types (Integer, Double, Character etc.) are automatically
/ whenever applies