{"id":3244,"date":"2022-09-21T16:38:49","date_gmt":"2022-09-21T11:08:49","guid":{"rendered":"https:\/\/cthecosmos.com\/?p=3244"},"modified":"2022-09-21T16:38:49","modified_gmt":"2022-09-21T11:08:49","slug":"the-simplicity-of-stack","status":"publish","type":"post","link":"https:\/\/cthecosmos.com\/?p=3244","title":{"rendered":"<strong>THE SIMPLICITY OF STACK<\/strong>"},"content":{"rendered":"\n<p class=\"has-white-background-color has-text-color has-background wp-block-paragraph\" style=\"color:#120909;font-size:17px;\">Stack, the most frequently used data structure. <strong>Stack<\/strong>, as the name suggests, keeps on stacking up the data one above the other. Consider an example of stacking up books in a box. The implementation of stack in your program is similar to that.<\/p>\n\n\n\n<p class=\"has-white-background-color has-text-color has-background wp-block-paragraph\" style=\"color:#120909;font-size:17px;\">Stack is often referred to as Last In First Out (<strong>LIFO<\/strong>). Why?\u00a0 Consider the same example of the books in box. You insert book by book in the box and would be able to remove the last placed book first and the first book you placed would be taken out last.<br><br>Stacks can be implemented using Arrays or Linked List. In this article, we shall see how it is implemented by using Arrays.<\/p>\n\n\n\n<p class=\"has-white-background-color has-text-color has-background wp-block-paragraph\" style=\"color:#120909;font-size:17px;\">\u00a0What are the operations to be performed to achieve this task? Visualize the books in the box. If the box is empty, you start loading it up with books. If it is full, you stop it and close the cover. And the inverse, you would unload unless there are no books left or until the book you are searching for is found.\u00a0 Use the same operations here, but let&#8217;s change the naming for simplicity. Push(), Pop(), PrintStack(). As the names suggest, Push() performs insertion of element into the stack, Pop() performs deletion of elements from the stack and PrintStack() just prints the stack.<\/p>\n\n\n\n<p class=\"has-white-background-color has-text-color has-background wp-block-paragraph\" style=\"color:#120909;font-size:17px;\">What do you do before adding the books? Make sure, the box has enough space. We use a similar analogy with the Push() operation. If the stack is full, Stop inserting the elements and let the user know that the stack is full. Let us also consider a variable top and initialize with -1 so that we can keep track of the topmost item.<\/p>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: cpp; title: ; notranslate\" title=\"\">\n&lt;pre class=&quot;wp-block-syntaxhighlighter-code&quot;&gt;\nvoid pushStack()\n{\nif(top&amp;lt;MAX-1){\n    int value;\n    printf(&quot;Enter the element: &quot;);\n    scanf(&quot;%d&quot;,&amp;amp;value);\n    ++top;\n    stack&amp;#x5B;top]=value;\n    printf(&quot;Pushed....\\n&quot;);\n}\nelse{\n    printf(&quot;!!!!!!!! ERROR: Stack is overflown... !!!!!!!!\\n&quot;);\n}\n}\n&lt;\/pre&gt;\n<\/pre><\/div>\n\n\n<p class=\"has-white-background-color has-text-color has-background wp-block-paragraph\" style=\"color:#120909;font-size:17px;\">Here, <strong>top<\/strong> and the <strong>stack array<\/strong> are declared as global variables. Just check if the top is less than the MAX storage allocated in the array, as long as it is less, you are good to Push the values into the stack.\u00a0 If the top value exceeds, Throw an error message to the user. As you see, we are <strong>incrementing<\/strong> the top just before adding an element such that we are able to insert the values in the desired position i.e during the first push, we get<br>top=0, stack[0] \u00a0\u00a0\u00a0&#8212;&#8211; First Push<br>top=1, stack[1]\u00a0\u00a0\u00a0 &#8212;&#8211; Second Push<br>top=2, stack[2]\u00a0\u00a0\u00a0 &#8212;&#8211; Second Push \u2026 you see the pattern.<br><\/p>\n\n\n\n<p class=\"has-white-background-color has-text-color has-background wp-block-paragraph\" style=\"color:#120909;font-size:17px;\">Time to remove the books from the box. Before doing that, just check if the box is empty, if it is, where would the book appear? Let&#8217;s go for the implementation using <strong>popStack()<\/strong> operation.<\/p>\n\n\n<div class=\"wp-block-syntaxhighlighter-code [code language=&quot;css&quot;] \"><pre class=\"brush: cpp; first-line: 1; title: ; notranslate\" title=\"\">\n&lt;pre class=&quot;wp-block-syntaxhighlighter-code &#x5B;code language=&quot;css&quot;]&quot;&gt;\nvoid popStack()\n{\n    if(top==-1)\n        printf(&quot;Stack is empty, cannot pop\\n&quot;);\n    else{\n        stack&amp;#x5B;top]=0;\n        top--;\n        printf(&quot;Popped...\\n&quot;);\n    }\n}\n&lt;\/pre&gt;\n<\/pre><\/div>\n\n\n<p class=\"has-white-background-color has-text-color has-background wp-block-paragraph\" style=\"color:#120909;font-size:17px;\">As seen, we are just checking if the stack is empty, we are doing that by <strong>top==-1 . <\/strong>Since you need to pop the element that is currently being pointed by <strong>top, <\/strong>pop the element and then <strong>decrement<\/strong> the top value. Here I am just initializing the removed value by 0 and decrementing the <strong>top<\/strong>.<\/p>\n\n\n\n<p class=\"has-white-background-color has-text-color has-background wp-block-paragraph\" style=\"color:#120909;font-size:17px;\">Now, I want to see how many books are present in the box. For this, we are using the <strong>printStack()<\/strong> with a simple printf and printing the elements until the top. If there are no elements in the stack for printing, just print a simple error message.<\/p>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: cpp; first-line: 1; title: ; notranslate\" title=\"\">\n&lt;pre class=&quot;wp-block-syntaxhighlighter-code&quot;&gt;\nvoid printStack(){\n    if(top==-1)\n    printf(&quot;\\n~~~~~~~~~~~No elements to print~~~~~~~~~~~\\n&quot;);\n\n    else{\n        for (int i = top; i &amp;gt;= 0; i--)    \n        printf(&quot;%d &quot;,stack&amp;#x5B;i]);\n    }\n\n}\n&lt;\/pre&gt;\n<\/pre><\/div>\n\n\n<figure class=\"wp-block-image size-large\"><img data-recalc-dims=\"1\" loading=\"lazy\" decoding=\"async\" width=\"1000\" height=\"712\" data-attachment-id=\"3264\" data-permalink=\"https:\/\/cthecosmos.com\/?attachment_id=3264\" data-orig-file=\"https:\/\/i0.wp.com\/cthecosmos.com\/wp-content\/uploads\/2022\/09\/img_stack_final.png?fit=1155%2C822&amp;ssl=1\" data-orig-size=\"1155,822\" data-comments-opened=\"1\" data-image-title=\"img_stack_final\" data-image-description=\"\" data-image-caption=\"\" data-large-file=\"https:\/\/i0.wp.com\/cthecosmos.com\/wp-content\/uploads\/2022\/09\/img_stack_final.png?fit=1000%2C712&amp;ssl=1\" src=\"https:\/\/i0.wp.com\/cthecosmos.com\/wp-content\/uploads\/2022\/09\/img_stack_final.png?resize=1000%2C712&#038;ssl=1\" alt=\"\" class=\"wp-image-3264\" \/><figcaption class=\"wp-element-caption\">Illustration of Stack<\/figcaption><\/figure>\n\n\n\n<p class=\"wp-block-paragraph\"><\/p>\n\n\n\n<p class=\"wp-block-paragraph\" style=\"font-size:17px;\">Using these three simple functions, a stack operation using arrays can be performed. Now let&#8217;s merge the code.<\/p>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: cpp; first-line: 1; title: ; notranslate\" title=\"\">\n&lt;pre class=&quot;wp-block-syntaxhighlighter-code&quot;&gt;\n#include&amp;lt;stdio.h&amp;gt;\n#include&amp;lt;stdlib.h&amp;gt;\n#define MAX 5\nint stack&amp;#x5B;MAX];\nint count =0;\nint top = -1;\n\nvoid pushStack()\n{\n    \n    if(top&amp;lt;MAX-1){\n        int value;\n        printf(&quot;Enter the element: &quot;);\n        scanf(&quot;%d&quot;,&amp;amp;value);\n        ++top;\n        stack&amp;#x5B;top]=value;\n        printf(&quot;Pushed....\\n&quot;);\n    }\n    else{\n        printf(&quot;!!!!!!!! ERROR: Stack is overflown... !!!!!!!!\\n&quot;);\n    }\n}\n\nvoid popStack()\n{\n    if(top==-1)\n        printf(&quot;Stack is empty, cannot pop\\n&quot;);\n    else{\n        stack&amp;#x5B;top]=0;\n        top--;\n        printf(&quot;Popped...\\n&quot;);\n    }\n}\n\nvoid  printStack(){\n    if(top==-1)\n    printf(&quot;\\n~~~~~~~~~~~No elements to print~~~~~~~~~~~\\n&quot;);\n\n    else{\n        for (int i = top; i &amp;gt;=0  ; i--)    \n        printf(&quot;%d &quot;,stack&amp;#x5B;i]);\n    }\n\n}\n\nvoid main()\n{\n\ndo{\n    printf(&quot;Select and option\\n1)Push element\\t2)Pop Element\\t3)Print Stack\\n&quot;);\n    int choice;\n    scanf(&quot;%d&quot;,&amp;amp;choice);\n    switch (choice)\n    {\n    case 1:\n            pushStack();\n            break;\n    case 2:\n            popStack();\n            break;\n    case 3:\n            printStack();\n            break;\n    default:\n        printf(&quot;Invalid Option\\n&quot;);\n        break;\n\n    }\n\n}while(1);\n}\n&lt;\/pre&gt;\n<\/pre><\/div>\n\n\n<p class=\"has-white-color has-midnight-gradient-background has-text-color has-background wp-block-paragraph\">From real-time undo, redo to actual stacking of function calls in the memory, the use of stack can be seen everywhere.<br><br><strong>Feel free to modify and experiment<\/strong>. Thanks for reading. Happy learning.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Stack, the most frequently used data structure. Stack, as the name suggests, keeps on stacking up the data one above the other. Consider an example of stacking up books in a box. The implementation of stack in your program is similar to that. Stack is often referred to as Last In First Out (LIFO). Why?\u00a0 [&hellip;]<\/p>\n<a href=\"https:\/\/cthecosmos.com\/?p=3244\" class=\"more-link\">Read More <span class=\"screen-reader-text\">THE SIMPLICITY OF STACK<\/span><\/a>","protected":false},"author":120055267,"featured_media":3271,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_jetpack_newsletter_access":"","_jetpack_dont_email_post_to_subs":false,"_jetpack_newsletter_tier_id":0,"_jetpack_memberships_contains_paywalled_content":false,"_wpcom_ai_launchpad_first_post":false,"_jetpack_hide_featured_image":false,"_jetpack_featured_image_duplicate_dismissed":0,"_jetpack_feature_clip_id":0,"_jetpack_memberships_contains_paid_content":false,"footnotes":"","jetpack_publicize_message":"{title}\n\n{excerpt}\n\n{url}","jetpack_publicize_feature_enabled":true,"jetpack_social_post_already_shared":false,"jetpack_social_options":{"image_generator_settings":{"template":"highway","default_image_id":0,"font":"","enabled":false},"version":2},"_wpas_customize_per_network":false,"jetpack_post_was_ever_published":false},"categories":[28627],"tags":[3378,584090,2426,167889,772321181,772321191,116003636,772321193,264,361344,196],"class_list":["post-3244","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-embedded","tag-algorithms","tag-arrays","tag-c","tag-c-language","tag-education","tag-embedded","tag-embedded-c-2","tag-embedded-systems","tag-learning","tag-linked-list","tag-programming","fallback-thumbnail"],"aioseo_notices":[],"aioseo_head":"\n\t\t<!-- All in One SEO 5.0.4 - aioseo.com -->\n\t<meta name=\"description\" content=\"Stack, the most frequently used data structure. Stack, as the name suggests, keeps on stacking up the data one above the other. Consider an example of stacking up books in a box. The implementation of stack in your program is similar to that. Stack is often referred to as Last In First Out (LIFO). Why?\" \/>\n\t<meta name=\"robots\" content=\"max-image-preview:large\" \/>\n\t<meta name=\"author\" content=\"Yashwanth Naidu Tikkisetty\"\/>\n\t<link rel=\"canonical\" href=\"https:\/\/cthecosmos.com\/?p=3244\" \/>\n\t\t<meta name=\"generator\" content=\"All in One SEO (AIOSEO) 5.0.4\" \/>\n\t\t<meta property=\"og:locale\" content=\"en_US\" \/>\n\t\t<meta property=\"og:site_name\" content=\"Yashwanth Naidu Tikkisetty - Embedded Systems | Space Blogger\" \/>\n\t\t<meta property=\"og:type\" content=\"article\" \/>\n\t\t<meta property=\"og:title\" content=\"THE SIMPLICITY OF STACK - Yashwanth Naidu Tikkisetty\" \/>\n\t\t<meta property=\"og:description\" content=\"Stack, the most frequently used data structure. Stack, as the name suggests, keeps on stacking up the data one above the other. Consider an example of stacking up books in a box. The implementation of stack in your program is similar to that. Stack is often referred to as Last In First Out (LIFO). Why?\" \/>\n\t\t<meta property=\"og:url\" content=\"https:\/\/cthecosmos.com\/?p=3244\" \/>\n\t\t<meta property=\"og:image\" content=\"https:\/\/cthecosmos.com\/wp-content\/uploads\/2018\/08\/logo1.png\" \/>\n\t\t<meta property=\"og:image:secure_url\" content=\"https:\/\/cthecosmos.com\/wp-content\/uploads\/2018\/08\/logo1.png\" \/>\n\t\t<meta property=\"og:image:width\" content=\"1200\" \/>\n\t\t<meta property=\"og:image:height\" content=\"1200\" \/>\n\t\t<meta property=\"article:published_time\" content=\"2022-09-21T11:08:49+00:00\" \/>\n\t\t<meta property=\"article:modified_time\" content=\"2022-09-21T11:08:49+00:00\" \/>\n\t\t<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n\t\t<meta name=\"twitter:title\" content=\"THE SIMPLICITY OF STACK - Yashwanth Naidu Tikkisetty\" \/>\n\t\t<meta name=\"twitter:description\" content=\"Stack, the most frequently used data structure. Stack, as the name suggests, keeps on stacking up the data one above the other. Consider an example of stacking up books in a box. The implementation of stack in your program is similar to that. Stack is often referred to as Last In First Out (LIFO). Why?\" \/>\n\t\t<meta name=\"twitter:image\" content=\"https:\/\/cthecosmos.com\/wp-content\/uploads\/2018\/08\/logo1.png\" \/>\n\t\t<script type=\"application\/ld+json\" class=\"aioseo-schema\">\n\t\t\t{\"@context\":\"https:\\\/\\\/schema.org\",\"@graph\":[{\"@type\":\"BlogPosting\",\"@id\":\"https:\\\/\\\/cthecosmos.com\\\/?p=3244#blogposting\",\"name\":\"THE SIMPLICITY OF STACK - Yashwanth Naidu Tikkisetty\",\"headline\":\"THE SIMPLICITY OF STACK\",\"author\":{\"@id\":\"https:\\\/\\\/cthecosmos.com\\\/?author=120055267#author\"},\"publisher\":{\"@id\":\"https:\\\/\\\/cthecosmos.com\\\/#person\"},\"image\":{\"@type\":\"ImageObject\",\"url\":\"https:\\\/\\\/i0.wp.com\\\/cthecosmos.com\\\/wp-content\\\/uploads\\\/2022\\\/09\\\/pexels-photo-7034647.jpeg?fit=867%2C1300&ssl=1\",\"width\":867,\"height\":1300,\"caption\":\"Photo by George Milton on Pexels.com\"},\"datePublished\":\"2022-09-21T16:38:49+05:30\",\"dateModified\":\"2022-09-21T16:38:49+05:30\",\"inLanguage\":\"en-US\",\"mainEntityOfPage\":{\"@id\":\"https:\\\/\\\/cthecosmos.com\\\/?p=3244#webpage\"},\"isPartOf\":{\"@id\":\"https:\\\/\\\/cthecosmos.com\\\/?p=3244#webpage\"},\"articleSection\":\"Embedded, Algorithms, Arrays, C, C Language, Education, Embedded, Embedded C, Embedded Systems, learning, Linked List, Programming\"},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\\\/\\\/cthecosmos.com\\\/?p=3244#breadcrumblist\",\"itemListElement\":[{\"@type\":\"ListItem\",\"@id\":\"https:\\\/\\\/cthecosmos.com\\\/#listItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\\\/\\\/cthecosmos.com\\\/\",\"nextItem\":{\"@type\":\"ListItem\",\"@id\":\"https:\\\/\\\/cthecosmos.com\\\/?cat=28627#listItem\",\"name\":\"Embedded\"}},{\"@type\":\"ListItem\",\"@id\":\"https:\\\/\\\/cthecosmos.com\\\/?cat=28627#listItem\",\"position\":2,\"name\":\"Embedded\",\"item\":\"https:\\\/\\\/cthecosmos.com\\\/?cat=28627\",\"nextItem\":{\"@type\":\"ListItem\",\"@id\":\"https:\\\/\\\/cthecosmos.com\\\/?p=3244#listItem\",\"name\":\"THE SIMPLICITY OF STACK\"},\"previousItem\":{\"@type\":\"ListItem\",\"@id\":\"https:\\\/\\\/cthecosmos.com\\\/#listItem\",\"name\":\"Home\"}},{\"@type\":\"ListItem\",\"@id\":\"https:\\\/\\\/cthecosmos.com\\\/?p=3244#listItem\",\"position\":3,\"name\":\"THE SIMPLICITY OF STACK\",\"previousItem\":{\"@type\":\"ListItem\",\"@id\":\"https:\\\/\\\/cthecosmos.com\\\/?cat=28627#listItem\",\"name\":\"Embedded\"}}]},{\"@type\":\"Person\",\"@id\":\"https:\\\/\\\/cthecosmos.com\\\/#person\",\"name\":\"Yashwanth Naidu Tikkisetty\",\"image\":{\"@type\":\"ImageObject\",\"@id\":\"https:\\\/\\\/cthecosmos.com\\\/?p=3244#personImage\",\"url\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/a02d9f38e4c924587b544c74f6d5de0c8469b6a5c684622f1aa4ea2ba65b17d8?s=96&d=identicon&r=g\",\"width\":96,\"height\":96,\"caption\":\"Yashwanth Naidu Tikkisetty\"}},{\"@type\":\"Person\",\"@id\":\"https:\\\/\\\/cthecosmos.com\\\/?author=120055267#author\",\"url\":\"https:\\\/\\\/cthecosmos.com\\\/?author=120055267\",\"name\":\"Yashwanth Naidu Tikkisetty\",\"image\":{\"@type\":\"ImageObject\",\"@id\":\"https:\\\/\\\/cthecosmos.com\\\/?p=3244#authorImage\",\"url\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/a02d9f38e4c924587b544c74f6d5de0c8469b6a5c684622f1aa4ea2ba65b17d8?s=96&d=identicon&r=g\",\"width\":96,\"height\":96,\"caption\":\"Yashwanth Naidu Tikkisetty\"}},{\"@type\":\"WebPage\",\"@id\":\"https:\\\/\\\/cthecosmos.com\\\/?p=3244#webpage\",\"url\":\"https:\\\/\\\/cthecosmos.com\\\/?p=3244\",\"name\":\"THE SIMPLICITY OF STACK - Yashwanth Naidu Tikkisetty\",\"description\":\"Stack, the most frequently used data structure. Stack, as the name suggests, keeps on stacking up the data one above the other. Consider an example of stacking up books in a box. The implementation of stack in your program is similar to that. Stack is often referred to as Last In First Out (LIFO). Why?\",\"inLanguage\":\"en-US\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/cthecosmos.com\\\/#website\"},\"breadcrumb\":{\"@id\":\"https:\\\/\\\/cthecosmos.com\\\/?p=3244#breadcrumblist\"},\"author\":{\"@id\":\"https:\\\/\\\/cthecosmos.com\\\/?author=120055267#author\"},\"creator\":{\"@id\":\"https:\\\/\\\/cthecosmos.com\\\/?author=120055267#author\"},\"image\":{\"@type\":\"ImageObject\",\"url\":\"https:\\\/\\\/i0.wp.com\\\/cthecosmos.com\\\/wp-content\\\/uploads\\\/2022\\\/09\\\/pexels-photo-7034647.jpeg?fit=867%2C1300&ssl=1\",\"@id\":\"https:\\\/\\\/cthecosmos.com\\\/?p=3244\\\/#mainImage\",\"width\":867,\"height\":1300,\"caption\":\"Photo by George Milton on Pexels.com\"},\"primaryImageOfPage\":{\"@id\":\"https:\\\/\\\/cthecosmos.com\\\/?p=3244#mainImage\"},\"datePublished\":\"2022-09-21T16:38:49+05:30\",\"dateModified\":\"2022-09-21T16:38:49+05:30\"},{\"@type\":\"WebSite\",\"@id\":\"https:\\\/\\\/cthecosmos.com\\\/#website\",\"url\":\"https:\\\/\\\/cthecosmos.com\\\/\",\"name\":\"Yashwanth Naidu Tikkisetty\",\"description\":\"Embedded Systems | Space Blogger\",\"inLanguage\":\"en-US\",\"publisher\":{\"@id\":\"https:\\\/\\\/cthecosmos.com\\\/#person\"}}]}\n\t\t<\/script>\n\t\t<!-- All in One SEO -->\n\n","aioseo_head_json":{"title":"THE SIMPLICITY OF STACK - Yashwanth Naidu Tikkisetty","description":"Stack, the most frequently used data structure. Stack, as the name suggests, keeps on stacking up the data one above the other. Consider an example of stacking up books in a box. The implementation of stack in your program is similar to that. Stack is often referred to as Last In First Out (LIFO). Why?","canonical_url":"https:\/\/cthecosmos.com\/?p=3244","robots":"max-image-preview:large","keywords":"","webmasterTools":{"miscellaneous":""},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"BlogPosting","@id":"https:\/\/cthecosmos.com\/?p=3244#blogposting","name":"THE SIMPLICITY OF STACK - Yashwanth Naidu Tikkisetty","headline":"THE SIMPLICITY OF STACK","author":{"@id":"https:\/\/cthecosmos.com\/?author=120055267#author"},"publisher":{"@id":"https:\/\/cthecosmos.com\/#person"},"image":{"@type":"ImageObject","url":"https:\/\/i0.wp.com\/cthecosmos.com\/wp-content\/uploads\/2022\/09\/pexels-photo-7034647.jpeg?fit=867%2C1300&ssl=1","width":867,"height":1300,"caption":"Photo by George Milton on Pexels.com"},"datePublished":"2022-09-21T16:38:49+05:30","dateModified":"2022-09-21T16:38:49+05:30","inLanguage":"en-US","mainEntityOfPage":{"@id":"https:\/\/cthecosmos.com\/?p=3244#webpage"},"isPartOf":{"@id":"https:\/\/cthecosmos.com\/?p=3244#webpage"},"articleSection":"Embedded, Algorithms, Arrays, C, C Language, Education, Embedded, Embedded C, Embedded Systems, learning, Linked List, Programming"},{"@type":"BreadcrumbList","@id":"https:\/\/cthecosmos.com\/?p=3244#breadcrumblist","itemListElement":[{"@type":"ListItem","@id":"https:\/\/cthecosmos.com\/#listItem","position":1,"name":"Home","item":"https:\/\/cthecosmos.com\/","nextItem":{"@type":"ListItem","@id":"https:\/\/cthecosmos.com\/?cat=28627#listItem","name":"Embedded"}},{"@type":"ListItem","@id":"https:\/\/cthecosmos.com\/?cat=28627#listItem","position":2,"name":"Embedded","item":"https:\/\/cthecosmos.com\/?cat=28627","nextItem":{"@type":"ListItem","@id":"https:\/\/cthecosmos.com\/?p=3244#listItem","name":"THE SIMPLICITY OF STACK"},"previousItem":{"@type":"ListItem","@id":"https:\/\/cthecosmos.com\/#listItem","name":"Home"}},{"@type":"ListItem","@id":"https:\/\/cthecosmos.com\/?p=3244#listItem","position":3,"name":"THE SIMPLICITY OF STACK","previousItem":{"@type":"ListItem","@id":"https:\/\/cthecosmos.com\/?cat=28627#listItem","name":"Embedded"}}]},{"@type":"Person","@id":"https:\/\/cthecosmos.com\/#person","name":"Yashwanth Naidu Tikkisetty","image":{"@type":"ImageObject","@id":"https:\/\/cthecosmos.com\/?p=3244#personImage","url":"https:\/\/secure.gravatar.com\/avatar\/a02d9f38e4c924587b544c74f6d5de0c8469b6a5c684622f1aa4ea2ba65b17d8?s=96&d=identicon&r=g","width":96,"height":96,"caption":"Yashwanth Naidu Tikkisetty"}},{"@type":"Person","@id":"https:\/\/cthecosmos.com\/?author=120055267#author","url":"https:\/\/cthecosmos.com\/?author=120055267","name":"Yashwanth Naidu Tikkisetty","image":{"@type":"ImageObject","@id":"https:\/\/cthecosmos.com\/?p=3244#authorImage","url":"https:\/\/secure.gravatar.com\/avatar\/a02d9f38e4c924587b544c74f6d5de0c8469b6a5c684622f1aa4ea2ba65b17d8?s=96&d=identicon&r=g","width":96,"height":96,"caption":"Yashwanth Naidu Tikkisetty"}},{"@type":"WebPage","@id":"https:\/\/cthecosmos.com\/?p=3244#webpage","url":"https:\/\/cthecosmos.com\/?p=3244","name":"THE SIMPLICITY OF STACK - Yashwanth Naidu Tikkisetty","description":"Stack, the most frequently used data structure. Stack, as the name suggests, keeps on stacking up the data one above the other. Consider an example of stacking up books in a box. The implementation of stack in your program is similar to that. Stack is often referred to as Last In First Out (LIFO). Why?","inLanguage":"en-US","isPartOf":{"@id":"https:\/\/cthecosmos.com\/#website"},"breadcrumb":{"@id":"https:\/\/cthecosmos.com\/?p=3244#breadcrumblist"},"author":{"@id":"https:\/\/cthecosmos.com\/?author=120055267#author"},"creator":{"@id":"https:\/\/cthecosmos.com\/?author=120055267#author"},"image":{"@type":"ImageObject","url":"https:\/\/i0.wp.com\/cthecosmos.com\/wp-content\/uploads\/2022\/09\/pexels-photo-7034647.jpeg?fit=867%2C1300&ssl=1","@id":"https:\/\/cthecosmos.com\/?p=3244\/#mainImage","width":867,"height":1300,"caption":"Photo by George Milton on Pexels.com"},"primaryImageOfPage":{"@id":"https:\/\/cthecosmos.com\/?p=3244#mainImage"},"datePublished":"2022-09-21T16:38:49+05:30","dateModified":"2022-09-21T16:38:49+05:30"},{"@type":"WebSite","@id":"https:\/\/cthecosmos.com\/#website","url":"https:\/\/cthecosmos.com\/","name":"Yashwanth Naidu Tikkisetty","description":"Embedded Systems | Space Blogger","inLanguage":"en-US","publisher":{"@id":"https:\/\/cthecosmos.com\/#person"}}]},"og:locale":"en_US","og:site_name":"Yashwanth Naidu Tikkisetty - Embedded Systems | Space Blogger","og:type":"article","og:title":"THE SIMPLICITY OF STACK - Yashwanth Naidu Tikkisetty","og:description":"Stack, the most frequently used data structure. Stack, as the name suggests, keeps on stacking up the data one above the other. Consider an example of stacking up books in a box. The implementation of stack in your program is similar to that. Stack is often referred to as Last In First Out (LIFO). Why?","og:url":"https:\/\/cthecosmos.com\/?p=3244","og:image":"https:\/\/cthecosmos.com\/wp-content\/uploads\/2018\/08\/logo1.png","og:image:secure_url":"https:\/\/cthecosmos.com\/wp-content\/uploads\/2018\/08\/logo1.png","og:image:width":1200,"og:image:height":1200,"article:published_time":"2022-09-21T11:08:49+00:00","article:modified_time":"2022-09-21T11:08:49+00:00","twitter:card":"summary_large_image","twitter:title":"THE SIMPLICITY OF STACK - Yashwanth Naidu Tikkisetty","twitter:description":"Stack, the most frequently used data structure. Stack, as the name suggests, keeps on stacking up the data one above the other. Consider an example of stacking up books in a box. The implementation of stack in your program is similar to that. Stack is often referred to as Last In First Out (LIFO). Why?","twitter:image":"https:\/\/cthecosmos.com\/wp-content\/uploads\/2018\/08\/logo1.png"},"aioseo_meta_data":{"post_id":"3244","title":null,"description":null,"keywords":null,"keyphrases":null,"primary_term":null,"canonical_url":null,"og_title":null,"og_description":null,"og_object_type":"default","og_image_type":"default","og_image_url":null,"og_image_width":null,"og_image_height":null,"og_image_custom_url":null,"og_image_custom_fields":null,"og_video":null,"og_custom_url":null,"og_article_section":null,"og_article_tags":null,"twitter_use_og":false,"twitter_card":"default","twitter_image_type":"default","twitter_image_url":null,"twitter_image_custom_url":null,"twitter_image_custom_fields":null,"twitter_title":null,"twitter_description":null,"schema":{"blockGraphs":[],"customGraphs":[],"default":{"data":{"Article":[],"Course":[],"Dataset":[],"FAQPage":[],"Movie":[],"Person":[],"Product":[],"ProductReview":[],"Car":[],"Recipe":[],"Service":[],"SoftwareApplication":[],"WebPage":[]},"graphName":"","isEnabled":true},"graphs":[]},"schema_type":"default","schema_type_options":null,"pillar_content":false,"robots_default":true,"robots_noindex":false,"robots_noarchive":false,"robots_nosnippet":false,"robots_nofollow":false,"robots_noimageindex":false,"robots_noodp":false,"robots_notranslate":false,"robots_max_snippet":null,"robots_max_videopreview":null,"robots_max_imagepreview":"large","priority":null,"frequency":null,"local_seo":null,"breadcrumb_settings":null,"limit_modified_date":false,"ai":null,"created":"2025-08-31 20:13:00","updated":"2025-08-31 20:13:00","seo_analyzer_scan_date":null,"focus_keyword":null,"additional_keywords":null,"truseo_locale":null},"aioseo_breadcrumb":"<div class=\"aioseo-breadcrumbs\"><span class=\"aioseo-breadcrumb\">\n\t\t\t<a href=\"https:\/\/cthecosmos.com\/\" title=\"Home\">Home<\/a>\n\t\t<\/span><span class=\"aioseo-breadcrumb-separator\">\u00bb<\/span><span class=\"aioseo-breadcrumb\">\n\t\t\t<a href=\"https:\/\/cthecosmos.com\/?cat=28627\" title=\"Embedded\">Embedded<\/a>\n\t\t<\/span><span class=\"aioseo-breadcrumb-separator\">\u00bb<\/span><span class=\"aioseo-breadcrumb\">\n\t\t\t<strong>THE SIMPLICITY OF STACK<\/strong>\n\t\t<\/span><\/div>","aioseo_breadcrumb_json":[{"label":"Home","link":"https:\/\/cthecosmos.com\/"},{"label":"Embedded","link":"https:\/\/cthecosmos.com\/?cat=28627"},{"label":"<strong>THE SIMPLICITY OF STACK<\/strong>","link":"https:\/\/cthecosmos.com\/?p=3244"}],"jetpack_publicize_connections":[],"jetpack_likes_enabled":true,"jetpack_sharing_enabled":true,"jetpack_shortlink":"https:\/\/wp.me\/p8CiEf-Qk","jetpack-related-posts":[],"jetpack_featured_media_url":"https:\/\/i0.wp.com\/cthecosmos.com\/wp-content\/uploads\/2022\/09\/pexels-photo-7034647.jpeg?fit=867%2C1300&ssl=1","_links":{"self":[{"href":"https:\/\/cthecosmos.com\/index.php?rest_route=\/wp\/v2\/posts\/3244","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/cthecosmos.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/cthecosmos.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/cthecosmos.com\/index.php?rest_route=\/wp\/v2\/users\/120055267"}],"replies":[{"embeddable":true,"href":"https:\/\/cthecosmos.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=3244"}],"version-history":[{"count":25,"href":"https:\/\/cthecosmos.com\/index.php?rest_route=\/wp\/v2\/posts\/3244\/revisions"}],"predecessor-version":[{"id":3274,"href":"https:\/\/cthecosmos.com\/index.php?rest_route=\/wp\/v2\/posts\/3244\/revisions\/3274"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/cthecosmos.com\/index.php?rest_route=\/wp\/v2\/media\/3271"}],"wp:attachment":[{"href":"https:\/\/cthecosmos.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=3244"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/cthecosmos.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=3244"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/cthecosmos.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=3244"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}