10.09.2013 Views

1. Advanced Data Structure using C++

1. Advanced Data Structure using C++

1. Advanced Data Structure using C++

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

LECTURE NOTES OF ADVANCED DATA STRUCTURE (MT-CSE 110)<br />

Implementation 2:<br />

Wrapped Configuration<br />

EMPTY QUEUE<br />

[2] [3] [2] [3]<br />

[1] [4] [1] J1<br />

[4]<br />

[0] [5] [0] [5]<br />

front = 0 front = 0<br />

rear = 0 rear = 3<br />

Can be seen as a circular queue<br />

Leave one empty space when queue is full<br />

Why?<br />

FULL QUEUE FULL QUEUE<br />

[2] [3] [2] [3]<br />

J2 J3<br />

J8 J9<br />

[1] J1 J4 [4][1] J7<br />

[4]<br />

J5<br />

J6 J5<br />

[0] [5] [0] [5]<br />

front =0<br />

rear = 5<br />

How to test when queue is empty?<br />

How to test when queue is full?<br />

J2<br />

J3<br />

front =4<br />

rear =3<br />

Prepared By :­<br />

Er. Harvinder Singh<br />

Assist Prof., CSE, H.C.T.M (Kaithal) Page ‐ 146 ‐

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!