1 / 5

Ics202 Data Structures

Ics202 Data Structures. Queueus. enqueue(1). enqueue (5). 3. 1. 4. 3. 1. 4. 1. 3. 1. 4. 1. 5. dequeue( ). dequeue( ). dequeue( ). 1. 5. 4. 1. 5. 1. 4. 1. 5.

bruis
Download Presentation

Ics202 Data Structures

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Ics202Data Structures

  2. Queueus enqueue(1) enqueue(5) 3 1 4 3 1 4 1 3 1 4 1 5 dequeue( ) dequeue( ) dequeue( ) 1 5 4 1 5 1 4 1 5

  3. import ADTs.QueueAsArray;import ADTs.Visitor;import ADTs.IntegerPrintingVisitor;public class QueueAsArrayTest{ public static void main(String[] args) { // create an object of the class QueueAsArray called queue with size = 20. // create an object of the class QueueAsArray called queue2 with size = 20. // Using the enqueue() method, to insert (1,2,3) into the queue. System.out.println("Visiting Queue Elements Using Visitor"); Visitor v = newIntegerPrintingVisitor();queue.accept(v);

  4. // Using the dequeue() method, to delete (1,2) from the queue. queue.showContent(); // Using the enqueue() method, to insert (1,2,3) into the queue2. System.out.println(); // Using the showContent () method to show the elements of queue2.if (queue.isEQ(queue2))System.out.println("queue equals queue2");else if (queue.isLT(queue2))System.out.println("queue less than queue2");else if (queue.isGT(queue2))System.out.println("queue greater than queue2"); }}

  5. Using steps in Example 1 to test QueueAsLinkedList , Create your project with name (QueueAsLinkedListTest) . enqueue(1) enqueue(5) 3 1 4 3 1 4 1 3 1 4 1 5 dequeue( ) dequeue( ) dequeue( ) 1 5 4 1 5 1 4 1 5

More Related