100 likes | 264 Views
Queue ADT. By Pantharee S. Queue Model. Like Stack , queues are list. Insertion is done at the end, whereas deletion is performed at the other end. (FIFO) Enqueue - inserts an element at the end of the list (rear)
E N D
Queue ADT By Pantharee S.
Queue Model Like Stack , queues are list. Insertion is done at the end, whereas deletion is performed at the other end. (FIFO) Enqueue- inserts an element at the end of the list (rear) Dequeue- deleted (and returns) the element at the start of the list (front)
Queue Model Queue Q Dequeue(Q) Enqueue(x,Q)
Array Implement of Queueswith Circular Array Initial State After Enqueue(1) After Enqueue(3)
Array Implement of Queueswith Circular Array After Dequeue,Which return 2 After Dequeue,Which return 4 After Dequeue,Which return 1
Array Implement of Queueswith Circular Array After Dequeue,Which return 3 and Makes the Queue Empty
จงบอกผลของการทำงานจากบนลงล่างจงบอกผลของการทำงานจากบนลงล่าง ..... Enqueue(“A”) A. void ..... Enqueue(“B”)B. “A” ..... Enqueue(“C”)C. “B” ..... Dequeue()D. “C” ..... Dequeue() E. “X” ..... Enqueue(“X”) ..... Dequeue()
ตำแหน่งของตัวที่อยู่ท้าย Queue คือข้อใด A) front + size B) front + size – 1 C) front + size + 1 D) (front + size)%elementData.lenght E) (front + size – 1)%elementData.length F) (front + size + 1)%elementData.lenght
Dequeue() ต้องทำสิ่งใดต่อไปนี้ A) size - -; B) elementData[front] = null; C) (++front)%elementData.length;
Peek ต้องคืนข้อมูลตัวใด A) elementData[front] B) elementData[front + 1] C) elementData[front + size – 1] D) elementData[size – 1]