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 />

STEP 1: Push left parenthesis on to stack‐ "(" and add right parenthesis ‐")" to<br />

the end of expression E until the stack is empty.<br />

STEP 2: If element = operand then<br />

add elements to expression P<br />

end of if statement.<br />

STEP 3: If element = left parenthesis then<br />

push element on stack.<br />

end of if statement.<br />

STEP 4: If element = operator then<br />

<strong>1.</strong> repeatedly pop from stack and add to expression P.Each operator which<br />

have the same or higher precedence.<br />

2. Push the element on stack.<br />

end of if statement.<br />

STEP 5: If element = right parenthesis then<br />

<strong>1.</strong> Repeatedly pop from stack and add to expression P, each element until<br />

a left parenthesis is encountered.<br />

2. Remove left parenthesis and do not add this to the resultant expression<br />

P.<br />

end of if statement.<br />

end of step 2nd loop.<br />

STEP 6: Exit.<br />

Prepared By :­<br />

Er. Harvinder Singh<br />

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

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

Saved successfully!

Ooh no, something went wrong!