JOIN us on
WhatsApp Group Join Now
Telegram Join Join Now

हिंदी माध्यम नोट्स

Categories: C Language in hindi

Stack : General Information in c language in hindi , स्टैक क्या है c कंप्यूटर भाषा में हिंदी में

स्टैक क्या है c कंप्यूटर भाषा में हिंदी में , Stack : General Information in c language in hindi  :-
Stack एक basic data struture है data को stack/piles के linear arrangement मे store किया जाता है |और इस data structure मे , data को stack के top मे से insert / delete कर सकते है|stack के struture को समज़ने के लिए उदाहरण है एक के एक उपर books का arrangement |जिसमे नै book को add और delete arrangement के top से किया जाता है |
अतः stack जिस concept पर आधारित है उसे LIFO (last in first out) कहते है |इस article मे , stack के basic operations को देखगे जैसे data को access करना |data की insert करना |data को delete करना आदि |
1.Push () : इस function का use किसी नए element को stack मे add किया जाता है |अतः किसी नए element को stack मे add कराने की प्रोसेस को push कहते है |
2.pop() :  इस function का use किसी नए element को stack मे remove किया जाता है |अतः किसी नए element को stack मे हटाना की प्रोसेस को pop कहते है |
3.is-empty() : इस function का use stack का status check किया जाता है |
अगर function ‘1’ return करे तब stack मे कोई element नहीं है |
और ‘0’ return करे तब stack मे element है |
4.is-full () : इस function से stack का status check किया जाता है |
अगर function ‘1’ देता है तब stack मे कोई नया element push नहीं हो सकता है |
अन्यथा stack मे element  add हो सकता है |
5.getsize () : इस function से , stack मे उपस्थित element की सख्या को return किया जाता है |
सभी functions, getsize() के अलावा  की time complexity O(1) होती है |और getsize() function की time complexity in worest case मे O(n) होती है |
Stack implantation by linked list

किसी linked list को stack से implantation करना सबसे सरल operation होता है |इसके दो प्रकार होते है :-

1. linked लिस्ट item

2. constructor
linked लिस्ट मे ,stack element की लिए item field होती है और address के लिए address feild होती है |constructor मे same लिस्ट का copy होता है जो की stack operation मे मदद करता है |
किसी भी linked लिस्ट मे , data को add लिस्ट के top पर कराया जाता है|और पहले वाला top अब next बन जाता है जो की लिस्ट मे add किये जाने item को point करता है |और add item इस लिस्ट का नया top बन जाता है |इसका अल्गोरिथ है :-
function push(item)

{

list_pre(item);

end function

}
list_pre(item);  function मे top को check किया जाता है इसके लिए निन्म function को use किया जाता है :-
function top()
{
return list.begin.getvalue ()
}

अगर किसी item को delete किया जाता है तब linked list के first node को डिलीट किया जाता है |इसके लिए algorithmहै :
function pop()
{
remove_listfirst();

}
इसके बाद लिस्ट के emptyness को सजहेस्क किया जाता है |जिसे
function empty ()
{
return (empty () );
}Performance Analysis

linked लिस्ट मे ,लिस्ट के first element को access करने o(1) operation करना पड़ता है|लिस्ट एक pointer को contain करता है जो की लिस्ट के emptyness और fullness को check करता है |कसी बार यूजर getsize(0 function को use नहीं करते है जिससे की मेम्रोरी space को बचाया जा सकता है |लेकिन memory space को optimize नहीं कर सकते है |

सभी stack operation के लिए array implemetation better रहता है क्योकि

array impleminatation मे , array के first element को stack का last element होता है |जैसे जैसे arrayबढेगी ,stack मे age और की बढ़ते है |इस impleminatation मे एक ही प्रॉब्लम होती है की अगर array फुल होती है तो डट को add नहीं किया जा सकता है |

Application

1.Convert decimal number into binary number

किसी decimal number को binary number मे convert काढ़े का अल्गोरिथ है :-

1. input number
2. while loop को चलाया जाता है
3. number को 2 से डिवाइड किया जाता है (Loop की body ) और qucent को number मे save करते है |
4. reminder को print किया जाता है | और qucent को 2 से डिवाइड करते है |
5. step 3,4 tab तक चलता है जब तक number की value 0 से ज्यादा होती है |

लेकिन इस लॉजिक की एक प्रॉब्लम है जसिसे अगर number 23 है जिसे binary number मे convert करना  है इसका आउटपुट आएगा 11101 लेकिन actual मे आउटपुट 10111 होगा|

इस प्रोब्लेम को solve करने के लिए stack का use किया जाता है |सबसे पहले हम reminder को stack मे insert करते है |जब devision क्कोम्प्लेते हो जाट अहै |stack मे store digits को बहार निकाल print कर देते है|

इसकी अल्गोइरिथ्म है :-

1.stack को create करेगे |
2.decimal number को input करेगे |
3.फिर while loop चलेगे |loop की body मे .
3.1 binary =number % 2
3.2 push binary into stack
3.3 अगर stack फुल है तब error message print हो जाये गा और algorithm terminate हो जायेगा |
3.4 divid number by 2 और store qucent into number

4. step 3 को tab तक repeat करगे जब तक number की value ‘0’ से ज्यादा है |
5.while loop को चलायेगे |loop की body मे ,
5.1pop binary from stack
5.2 binary को print करायेगे |
6. loop तब तक चलेगा जब तक की stack empty नहीं हो जाता है |
7 stop
इसके अलावा stack को कई दुसरे appliaction होते  है जैसे :-

1. Tower ऑफ़ honio

2. Expression Evalution

3. Syntax Parsing

4. Rearranging rail road cars

5. Stock Span Problem

इन सभी प्रोब्लेम्स को सार से हम आगे आने वाले articles मे पढेगे|

Sbistudy

Recent Posts

Question Tag Definition in english with examples upsc ssc ias state pcs exames important topic

Question Tag Definition • A question tag is a small question at the end of a…

2 weeks ago

Translation in english grammer in hindi examples Step of Translation (अनुवाद के चरण)

Translation 1. Step of Translation (अनुवाद के चरण) • मूल वाक्य का पता करना और उसकी…

2 weeks ago

Report Writing examples in english grammer How to Write Reports explain Exercise

Report Writing • How to Write Reports • Just as no definite rules can be laid down…

2 weeks ago

Letter writing ,types and their examples in english grammer upsc state pcs class 12 10th

Letter writing • Introduction • Letter writing is an intricate task as it demands meticulous attention, still…

2 weeks ago

विश्व के महाद्वीप की भौगोलिक विशेषताएँ continents of the world and their countries in hindi features

continents of the world and their countries in hindi features विश्व के महाद्वीप की भौगोलिक…

2 weeks ago

भारत के वन्य जीव राष्ट्रीय उद्यान list in hin hindi IAS UPSC

भारत के वन्य जीव भारत में जलवायु की दृष्टि से काफी विविधता पाई जाती है,…

2 weeks ago
All Rights ReservedView Non-AMP Version
X

Headline

You can control the ways in which we improve and personalize your experience. Please choose whether you wish to allow the following:

Privacy Settings
JOIN us on
WhatsApp Group Join Now
Telegram Join Join Now