tutorial03

tutorial03 - CSC2100B 2007 Spring Data Structures Tutorial...

Info iconThis preview shows pages 1–10. Sign up to view the full content.

View Full Document Right Arrow Icon
07:03 07:03   1 CSC2100B 2007 Spring Data Structures Tutorial 3 Last updated: 30 Jan, 2007 Deng Hongbo  Email: hbdeng [at] cse.cuhk.edu.hk Office: move to SHB101A
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
07:03 07:03   2 Assignment 1 Sample Program Sample Program (a1.jar)  Sample Input file (bank.dat) (WebCT)  http://www.cuhk.edu.hk/eLearning/webctce/ To run Save the .jar file and the input file in a directory. java –classpath a1.jar Palindrome     OR java –classpath a1.jar Bank Note: you do NOT need to include your programs in a .jar file  when you submit.
Background image of page 2
07:03 07:03   3 Input file: Bank.dat 1. N 3 10.9 2. V 1 -2.1 3. V 10 100.5 4.   5. N 10 200
Background image of page 3

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
07:03 07:03   4 Output: Teller [0]: Number Of Customer Served:2 Teller [0]: Total Amount Received: $98.4 Teller [1]: Number Of Customer Served:2 Teller [1]: Total Amount Received: $210.9 Teller [2]: Number Of Customer Served:0 Teller [2]: Total Amount Received: $0.0 Average Waiting Time for VIP = 0.0 Average Waiting Time for NonVIP = 0.0
Background image of page 4
07:03 07:03   5 Assignment 1 Any Questions?
Background image of page 5

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
07:03 07:03   6 Exercise 1 Stack and Queues (again!) // Queue.java public interface Queue {   public void enqueue(int c);   public int dequeue();   public int queueLength();   public boolean isEmpty();   }  // Stack.java   public interface Stack {   public void push(int element);   public int pop();   public int stackDepth();   public boolean isEmpty(); 
Background image of page 6
07:03 07:03   7 Exercise 1A (warm up…) What are the resulting stack/queue after the following steps? (MyQueue and MyStack implements the Queue and Stack interface  respectivety)   Queue q = new MyQueue(); q.enqueue(1); q.enqueue(2); q.enqueue(3); q.dequeue(); q.enqueue(4); q.dequeue(); D2003-2 Stack s = new MyStack(); s.push(1); s.push(2); s.push(3); s.pop(); s.pop(); s.push(4); s.push(5); s.pop(); D2004-2
Background image of page 7

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
07:03 07:03   8 Answer 1A What are the resulting stack/queue after the following steps? (MyQueue and MyStack implements the Queue and Stack interface  respectivety)   Queue q = new MyQueue(); q.enqueue(1); q.enqueue(2); q.enqueue(3); q.dequeue(); q.enqueue(4); q.dequeue(); D2003-2 Stack s = new MyStack(); s.push(1); s.push(2); s.push(3); s.pop(); s.pop(); s.push(4); s.push(5); s.pop(); D2004-2 [3][4] [1][4]
Background image of page 8
07:03 07:03   9 Exercise 1B What is the output? public class t3ex1 {
Background image of page 9

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Image of page 10
This is the end of the preview. Sign up to access the rest of the document.

Page1 / 20

tutorial03 - CSC2100B 2007 Spring Data Structures Tutorial...

This preview shows document pages 1 - 10. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online