{[ promptMessage ]}

Bookmark it

{[ promptMessage ]}

Deque - 91.404 UMass Lowell 91.404 Analysis of Algorithms...

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

View Full Document Right Arrow Icon
// 91.404 UMass Lowell 91.404 Analysis of Algorithms, Prof. KarenDaniels (Fall 2000) // Java implementation of Deque operations using array of Objects public class DequeTest {   public static void main(String[] args) {       int n = 8;       int i;       Deque Q = new Deque(n);       for (i=0;i<n-3;i++)  {         Q.EnqueueBack(new Integer(i));         Q.Print();        }       for (i=n-3;i<=n;i++) {         Q.EnqueueFront(new Integer(i));         Q.Print();        }       boolean front = true;       Object x = null;       for (i=0; i<=n; i++)  {         if (front) x = Q.DequeueFront();         else x = Q.DequeueBack();         Q.Print();         front = !front;        }      } }  class Deque {    int n = 10;  // default value    int head, tail;    Object D[];    Deque() {      head = tail = 0;  // assuming 0-based array! (different from textbook)
Background image of page 1

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

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

{[ snackBarMessage ]}