Tutorial_9_v02-for-viewing-printing - CC2203 Data...

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

View Full Document Right Arrow Icon
CC2203 Data Structures and Algorithms Sem 2, 2009-2010 Tutorial 9 Instruction In this tutorial, you are required to submit your tutorial work answer for exercise to me. Tutorial work will not be graded unless your coursework fails (coursework below D grade). If one’s coursework fails, that tutorial work will be graded to see if condone pass should be issued or not. Exercise 1 Given the following Java code: class Node { Object element; // element in the node Node next; // next is the pointer pointing at the next node Node(Object element) { this.element = element; this.next = null; } Node(Object element, Node next) { this.element = element; this.next = next; } } public class LinkedQueue { Node front; public boolean isEmpty() { return front == null; // return true iff queue is empty } public Object getFrontElement() { if (isEmpty()) return null; // return null if the queue is empty else return front.element; // return the element at the queue front } public Object getRearElement() { // code to be completed. } public void put(Object theElement) { // insert theElement at the queue rear Node n = new Node(theElement); // create a node for theElement
Background image of page 1

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

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

This note was uploaded on 08/18/2011 for the course COMP 3868 taught by Professor Keithchan during the Summer '97 term at Hong Kong Polytechnic University.

Page1 / 3

Tutorial_9_v02-for-viewing-printing - CC2203 Data...

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

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