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

Representation of stacks<br />

Examples:<br />

• Pile of tray in cadet area.<br />

• Shunting for railway boogies system.<br />

IMPEMENTATION OF STACKS<br />

Stacks can be implemented in two ways:<br />

• Static implementation<br />

• Dynamic implementation<br />

•<br />

STATIC IMPLEMENTATION:<br />

This kind of implementation uses arrays to create stack . The array<br />

implementation o stack is not the flexible technique because the size of the<br />

array is fixed . If there is few elements to be stored in the stack then the<br />

statically allocated memory will be wasted and if there are more no. of<br />

elements to be stored in the stack then we can’t be able to change the size of<br />

array to increase its capacity.<br />

DYANAMIC IMPLEMENTATION:<br />

In this kind of implementation array is represented in the form of linked list by<br />

<strong>using</strong> pointers to implement the stacks type of data structure.<br />

Example :<br />

• Int a[7]<br />

we have to insert four elements 10,20,30,40 in the array.<br />

Prepared By :­<br />

Er. Harvinder Singh<br />

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

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

Saved successfully!

Ooh no, something went wrong!