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

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

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

There are two basic operations that can be performed on a queue. These are :‐<br />

<strong>1.</strong>Insertion operation (put)<br />

2.Deletion operation(Get)<br />

Insertion operation (Put) Algorithm on a Queues:‐<br />

Insertion operation<br />

procedure:‐Insert (Q,F,R,N,X)<br />

Q=name of queue<br />

F=front pointer variable<br />

R=rear pointer variable<br />

X=element to be inserted<br />

N=maximum size of queue<br />

PROCEDURE<br />

Step ‐1:‐ [over flow condition?]<br />

if R>=N,then write<br />

“OVER FLOW CONDITION”<br />

&return<br />

[end of if‐statement ]<br />

Step‐2:‐ [is queue empty?]<br />

if F=0,then F=1<br />

[end of if‐statement]<br />

Step 3:‐[increment rear pointer]<br />

R=R+1<br />

Step 4:‐[insert new element]<br />

Q(R) =X<br />

step 5:‐ finished<br />

return<br />

Deletion (Get) operation of Algorithm on Queues:‐<br />

Procedure:‐Delete (Q,F,R,X)<br />

x=variable used to store deleted elements<br />

Step 1:‐[under flow condition?]<br />

if F=0,then write<br />

“UNDER FLOW CONDITION”<br />

Prepared By :­<br />

Er. Harvinder Singh<br />

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

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

Saved successfully!

Ooh no, something went wrong!