Short Answers Sections 7.1 - 7.2 Queues and Their Applications |
public static int counter(EasyReader in) // Precondition: There is a line of input waiting to be read from in. // Postcondition: A line of input has been read from in, up to but not // including the newline character. The return value of the method // is the number of times that the LAST character of the line appeared // somewhere in this line. // EXAMPLE Input: ABBXDXXZX // The value returned by counter would be 4 for this input since there // are 4 X's in the input line.
Short Answers
Section 7.3
Implementations of
the Queue ADT
IntQueue q = new IntQueue( ); q.insert(1); q.insert(2); q.insert(3); System.out.println(q.getFront( ));
_______ __________________________________ front| | data| | | | | | |_______| |______|______|______|______|______| [0] [1] [2] [3] [4]
IntQueue q = new IntQueue( ); q.insert(1); q.insert(2); q.insert(3); System.out.println(q.getFront( ));
_______ front| | |_______| _______ rear| | |_______|
Short Answers
Section 7.4
Priority Queues
public class PriorityQueue { // A PriorityNode is a node from a linked list of strings, with // methods for getString, setString, getPriority, setPriority, // getLink, and setLink. private PriorityNode head; public void insert(String entry, int priority)... public String getFront( )... ... }
head = head.getLink( );
Multiple Choice Sections 7.1-7.2 Queues and Their Applications |
Multiple Choice
Section 7.3
Implementations of
the Queue ADT
Multiple Choice
Section 7.4
Priority Queues