Queue using an array
This presentation is the property of its rightful owner.
Sponsored Links
1 / 28

Queue using an array PowerPoint PPT Presentation


  • 62 Views
  • Uploaded on
  • Presentation posted in: General

Queue using an array. .head. .tail. Pointers head and tail always point to the first empty slot before or after elements in the list. Thus, initially they point to the same slot, say 0. Add object to rear of list. 1. .head. .tail. Add object to rear of list. 1. 2. .head. .tail.

Download Presentation

Queue using an array

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.While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server.


- - - - - - - - - - - - - - - - - - - - - - - - - - E N D - - - - - - - - - - - - - - - - - - - - - - - - - -

Presentation Transcript


Queue using an array

Queue using an array


Queue using an array

.head

.tail

Pointers head and tail always point to the first empty slot before or after

elements in the list. Thus, initially they point to the same slot, say 0.


Queue using an array

Add object to rear of list

1

.head

.tail


Queue using an array

Add object to rear of list

1

2

.head

.tail


Queue using an array

Add object to rear of list

1

2

3

.head

.tail


Queue using an array

Add object to rear of list

1

2

3

4

.head

.tail


Queue using an array

Remove from front

2

3

4

.head

.tail

1

.object


Queue using an array

Remove from front

3

4

.head

.tail

2

.object


Queue using an array

Add

3

4

5

.head

.tail


Queue using an array

Remove

4

5

.head

.tail

3

.object


Queue using an array

Add

4

5

6

.head

.tail


Queue using an array

Add

4

7

5

6

.head

.tail


Queue using an array

Add

4

7

8

5

6

.head

.tail


Queue using an array

Add

4

7

8

5

6

9

.tail

.head


Queue using an array

Queue using

Circularly Linked List


Queue using an array

Circularly linked list

.tail


Queue using an array

Queue: insert item at rear, remove at front

.tail


Queue using an array

Queue: remove from front

_object

.tail

_object = tail->next->item;


Queue using an array

Queue: remove from front

Temp

_temp

_object

.tail

_temp = tail->next;


Queue using an array

Queue: remove from front

Temp

_temp

_object

.tail

_tail->next = tail->next->next;


Queue using an array

Queue: remove from front

Temp

_temp

_object

.tail

_delete temp;


Queue using an array

Queue: remove from front

Temp

_object

.tail

_return object;


Queue using an array

Queue: remove from front

Temp

.tail

_


Queue using an array

Queue: insert at rear

Temp

.tail

_


Queue using an array

Queue: insert at rear

_cell

Temp

NULL

.tail

_cell = new Cell(object);


Queue using an array

Queue: insert at rear

_cell

Temp

.tail

_cell->next = tail->next;


Queue using an array

Queue: insert at rear

_cell

Temp

.tail

_tail->next = cell;


Queue using an array

Queue: insert at rear

_cell

Temp

.tail

_tail = tail->next;


  • Login