Stacks and Queues in Data structure in hindi
Stack Kya hai
stack Ek non-primitive linear data structure hota hai jisme kisi new Data item ko jodna or pahle se present data item ko delete karne ka kaam stack ke ek end se kiya jata hai jise stack ka top kahte hai.
Esi top se sabhi data items ka insertion aur deletion kiya jata hai stack me jo data item last me add hota hai vh deletion ke time sabse pahle delete hota hai. Esi reason se ese Last-In-First-Out(LIFO) kaha jata hai.
Ex-1.Stack of plates in a marriage party or coin stacker.jaha par fresh plate top par rakha jata hai aur top se hi plates remove kiya jata hai.
Ex-2.ydi hum biscuits ya poppins khate hai par dono ke ek chhor ko open karke ek-ek karke biscuits aur Poppins ko nikalte hai yha par bhi stack ki property ko use kiya jata hai
Basic Features of Stack
- Stack ek hi tarah ke data types Ka sequential collection hota hai
- Stack ek last-in-first-out type ka data structure hai
- Stack me data item Ko insert karne ke liye PUCH() function ka use kiya jata hai jabki Delete karne ke liye POP() function ka.Dono insertion aur deletion karne ke liye keval Ek End ka prayog kiya jata hai jisko Top of stack kahte hai
- Ydi kisi stack ki size puri tarah full hai to data item ko add(insertion) karte time overflow State ban jata hai jabki ek aisa state bhi aata hai jab stack me koi bhi data item nahi hota hai vh state underflow kahlata hai.
Application of Stack
Reversing a string...
Kisi string ko Reverse karne ke liye stack ka use kiya jata hai
Example:-Ambition, Agar Es word ko ulta (Reverse) karna hoga to pahle Ese Stack me Insert karenge phir agar Es stack me data ko pop(Delete)karenge to ye word (String) melega noitibmA
Esprakar kisi string/word ko reverse kiya ja sakta hai
Undo/Redo:-
Kisi text editor me, kisi data me kiye gaye changes ko again return karne undo ka use karke step by step us purane text par ja sakte hai. aur Redo ka use karke puna edit ya change kiye huye text par pahuch sakte hai. Eska use excel ya word me kiya jata hai
Tower of Hanoi:-
No comments