{"id":16160,"date":"2023-05-05T10:02:13","date_gmt":"2023-05-05T10:02:13","guid":{"rendered":"https:\/\/www.prepbytes.com\/blog\/?p=16160"},"modified":"2023-05-05T10:02:13","modified_gmt":"2023-05-05T10:02:13","slug":"which-data-structure-is-used-for-implementing-recursion","status":"publish","type":"post","link":"https:\/\/prepbytes.com\/blog\/which-data-structure-is-used-for-implementing-recursion\/","title":{"rendered":"Which Data Structure is used for Implementing Recursion?"},"content":{"rendered":"<p><img decoding=\"async\" src=\"https:\/\/prepbytes-misc-images.s3.ap-south-1.amazonaws.com\/assets\/1683280771631-Which%20data%20structure%20is%20used%20for%20implementing%20recursion.jpg\" alt=\"\" \/><\/p>\n<p>Stack(LIFO) data structure is one of the famous data structures used for implementing recursion. Recursion is a method of problem-solving where a function is run repeatedly on smaller inputs until a base case, or the smallest input with a simple answer, is reached.<\/p>\n<h2>What is Recursion in Data Structure?<\/h2>\n<p>Recursion is the process of repeatedly applying a rule or procedure until one arrives at the solution.<\/p>\n<p>The concept behind recursion is that we have a problem that needs to be solved, and we are trying to find a way to do it by showing that the solution is the outcome of applying a series of sequential computations to the outcome of solving a smaller version of the same problem. The same procedure is used to solve an even smaller version of the problem because the smaller problem is of the same type.<\/p>\n<p>The base condition and the recurrence relation are the two components of recursion. Let&#8217;s break them down individually using the factorial of a number as an example.<\/p>\n<h2>What is Recurrence?<\/h2>\n<p>The link between the same function and different input sizes is known as recurrence, This means that we frequently calculate the answer to a bigger input with a smaller input. For instance, suppose we need to compute the factorial of a number N in this case. We develop a helper function called fact(N), which returns the factorial of a number N.<\/p>\n<p>A factorial of numbers using this function can be represented as<br \/>\n*<em>fact(N) = N <\/em> fact(N-1)**<\/p>\n<p>With a smaller input, the preceding equation is known as a recurrence relation, even though the function fact(N) calls itself.<\/p>\n<h2>What is Base Condition?<\/h2>\n<p>This is the situation when the input size is so small that the answer is really simple. As in the factorial of a number example, we can observe that the base condition is a fact(1), meaning that given an input of N=1, we are aware of the answer being 1.<\/p>\n<p><img decoding=\"async\" src=\"https:\/\/prepbytes-misc-images.s3.ap-south-1.amazonaws.com\/assets\/1683280771776-1-01%20%2883%29.png\" alt=\"\" \/><\/p>\n<p>Once it locates the base case, the recursion goes back to the previous input, and the pending temporary function calls are stored in the stack data structure in the memory as shown below.<\/p>\n<p><img decoding=\"async\" src=\"https:\/\/prepbytes-misc-images.s3.ap-south-1.amazonaws.com\/assets\/1683280771776-1-02%20%2841%29.png\" alt=\"\" \/><\/p>\n<p>The stack keeps growing with each function call until the base case, in this instance fact(1) = 1, comes. Each function call is then assessed in the order of last in, first out.<\/p>\n<p><img decoding=\"async\" src=\"https:\/\/prepbytes-misc-images.s3.ap-south-1.amazonaws.com\/assets\/1683280771783-1-03%20%2827%29.png\" alt=\"\" \/><\/p>\n<h2>Stack for Recursion<\/h2>\n<p>We know that in the stack data structure, we have<\/p>\n<ol>\n<li>a list of elements<\/li>\n<li>Push element into the stack<\/li>\n<li>Pop element from the stack <\/li>\n<li>Last In First Out<\/li>\n<\/ol>\n<p>Computers offer a context comprising all the variables (and other names) currently in scope when they execute a programming language. A new context for the function is &quot;pushed&quot; on top of the old context when a function is called, saving the previous context. The contexts are stack frames, and this is the (system) call stack. All the variables (and functions) declared in the called function are listed in each stack frame.<\/p>\n<p><strong>Code Implementation<\/strong><\/p>\n\t\t\t\t\t\t<style>\r\n\t\t\t\t\r\n\t\t\t\t\t#tab_container_16125 {\r\n\toverflow:hidden;\r\n\tdisplay:block;\r\n\twidth:100%;\r\n\tborder:0px solid #ddd;\r\n\tmargin-bottom:30px;\r\n\t}\r\n\r\n#tab_container_16125 .tab-content{\r\n\tpadding:20px;\r\n\tborder: 1px solid #e6e6e6 !important;\r\n\tmargin-top: 0px;\r\n\tbackground-color:#ffffff !important;\r\n\tcolor: #000000 !important;\r\n\tfont-size:16px !important;\r\n\tfont-family: Open Sans !important;\r\n\t\r\n\t\tborder: 1px solid #e6e6e6 !important;\r\n\t}\r\n#tab_container_16125 .wpsm_nav-tabs {\r\n    border-bottom: 0px solid #ddd;\r\n}\r\n#tab_container_16125 .wpsm_nav-tabs > li.active > a, #tab_container_16125 .wpsm_nav-tabs > li.active > a:hover, #tab_container_16125 .wpsm_nav-tabs > li.active > a:focus {\r\n\tcolor: #000000 !important;\r\n\tcursor: default;\r\n\tbackground-color: #ffffff !important;\r\n\tborder: 1px solid #e6e6e6 !important;\r\n}\r\n\r\n#tab_container_16125 .wpsm_nav-tabs > li > a {\r\n    margin-right: 0px !important; \r\n    line-height: 1.42857143 !important;\r\n    border: 1px solid #d5d5d5 !important;\r\n    border-radius: 0px 0px 0 0 !important; \r\n\tbackground-color: #e8e8e8 !important;\r\n\tcolor: #000000 !important;\r\n\tpadding: 15px 18px 15px 18px !important;\r\n\ttext-decoration: none !important;\r\n\tfont-size: 14px !important;\r\n\ttext-align:center !important;\r\n\tfont-family: Open Sans !important;\r\n}\r\n#tab_container_16125 .wpsm_nav-tabs > li > a:focus {\r\noutline: 0px !important;\r\n}\r\n\r\n#tab_container_16125 .wpsm_nav-tabs > li > a:before {\r\n\tdisplay:none !important;\r\n}\r\n#tab_container_16125 .wpsm_nav-tabs > li > a:after {\r\n\tdisplay:none !important ;\r\n}\r\n#tab_container_16125 .wpsm_nav-tabs > li{\r\npadding:0px !important ;\r\nmargin:0px;\r\n}\r\n\r\n#tab_container_16125 .wpsm_nav-tabs > li > a:hover , #tab_container_16125 .wpsm_nav-tabs > li > a:focus {\r\n    color: #000000 !important;\r\n    background-color: #e8e8e8 !important;\r\n\tborder: 1px solid #d5d5d5 !important;\r\n\t\r\n}\r\n#tab_container_16125 .wpsm_nav-tabs > li > a .fa{\r\n\r\nmargin-right:5px !important;\r\n\r\nmargin-left:5px !important;\r\n\r\n\r\n}\r\n\r\n\t\t#tab_container_16125 .wpsm_nav-tabs a{\r\n\t\t\tbackground-image: none;\r\n\t\t\tbackground-position: 0 0;\r\n\t\t\tbackground-repeat: repeat-x;\r\n\t\t}\r\n\t\t\t\r\n\r\n\r\n#tab_container_16125 .wpsm_nav-tabs > li {\r\n    float: left;\r\n    margin-bottom: -1px !important;\r\n\tmargin-right:0px !important; \r\n}\r\n\r\n\r\n#tab_container_16125 .tab-content{\r\noverflow:hidden !important;\r\n}\r\n\r\n\r\n@media (min-width: 769px) {\r\n\r\n\t#tab_container_16125 .wpsm_nav-tabs > li{\r\n\t\tfloat:left !important ;\r\n\t\t\t\tmargin-right:-1px !important;\r\n\t\t\t\t\t}\r\n\t#tab_container_16125 .wpsm_nav-tabs{\r\n\t\tfloat:none !important;\r\n\t\tmargin:0px !important;\r\n\t}\r\n\r\n\t#tab_container_16125 .wpsm_nav-tabs > li {\r\n\t\t\t\t\r\n\t}\r\n\t#tab_container_16125 .wpsm_nav{\r\n\t\t\t}\r\n\r\n}\r\n\r\n\r\n\r\n@media (max-width: 768px) {\r\n\t#tab_container_16125 .wpsm_nav-tabs > li {\r\n\t\t\t\t\r\n\t}\r\n\t#tab_container_16125 .wpsm_nav{\r\n\t\t\t}\r\n}\r\n\r\n\r\n\t.wpsm_nav-tabs li:before{\r\n\t\tdisplay:none !important;\r\n\t}\r\n\r\n\t@media (max-width: 768px) {\r\n\t\t\t\t\r\n\t\t\t\t.wpsm_nav-tabs{\r\n\t\t\tmargin-left:0px !important;\r\n\t\t\tmargin-right:0px !important; \r\n\t\t\t\r\n\t\t}\r\n\t\t\t\t#tab_container_16125 .wpsm_nav-tabs > li{\r\n\t\t\tfloat:none !important;\r\n\t\t}\r\n\t\t\t\r\n\t}\t\t\t\t<\/style>\r\n\t\t\t\t<div id=\"tab_container_16125\" >\r\n\t \r\n\t\t\t\t\t<ul class=\"wpsm_nav wpsm_nav-tabs\" role=\"tablist\" id=\"myTab_16125\">\r\n\t\t\t\t\t\t\t\r\n\t\t\t\t\t\t\t<li role=\"presentation\"  class=\"active\"  onclick=\"do_resize()\">\r\n\t\t\t\t\t\t\t\t<a href=\"#tabs_desc_16125_1\" aria-controls=\"tabs_desc_16125_1\" role=\"tab\" data-toggle=\"tab\">\r\n\t\t\t\t\t\t\t\t\t\r\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t<i class=\"fa fa-code\"><\/i> \t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\r\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\r\n\t\t\t\t\t\t\t\t\t<span>C++<\/span>\r\n\t\t\t\t\t\t\t\t\t\r\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\r\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\r\n\t\t\t\t\t\t\t\t\t\r\n\t\t\t\t\t\t\t\t<\/a>\r\n\t\t\t\t\t\t\t<\/li>\r\n\t\t\t\t\t\t\t\t\t\t\t <\/ul>\r\n\r\n\t\t\t\t\t  <!-- Tab panes -->\r\n\t\t\t\t\t  <div class=\"tab-content\" id=\"tab-content_16125\">\r\n\t\t\t\t\t\t\t\t\t\t\t\t <div role=\"tabpanel\" class=\"tab-pane  in active \" id=\"tabs_desc_16125_1\">\r\n\t\t\t\t\t\t\t\t<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"cpp\">#include&lt;bits\/stdc++.h&gt;\r\nusing namespace std;\r\n\r\nint sum(int k) \r\n{\r\n    if (k &lt;= 1) {\r\n        \/\/ base case\r\n        return 1;\r\n    } else {\r\n        \/\/ recursive case\r\n        return k + sum(k - 1);\r\n    }\r\n}\r\n\r\nint main()\r\n{\r\n    int n = 3;\r\n    int ans = sum(n);\r\n    cout&lt;&lt;ans;\r\n \r\n}\r\n<\/pre>\t\t\t\t\t\t <\/div>\r\n\t\t\t\t\t\t\t\r\n\t\t\t\t\t <\/div>\r\n\t\t\t\t\t \r\n\t\t\t\t <\/div>\r\n <script>\r\n\t\tjQuery(function () {\r\n\t\t\tjQuery('#myTab_16125 a:first').tab('show')\r\n\t\t});\r\n\t\t\r\n\t\t\t\tjQuery(function(){\r\n\t\t\tvar b=\"fadeIn\";\r\n\t\t\tvar c;\r\n\t\t\tvar a;\r\n\t\t\td(jQuery(\"#myTab_16125 a\"),jQuery(\"#tab-content_16125\"));function d(e,f,g){\r\n\t\t\t\te.click(function(i){\r\n\t\t\t\t\ti.preventDefault();\r\n\t\t\t\t\tjQuery(this).tab(\"show\");\r\n\t\t\t\t\tvar h=jQuery(this).data(\"easein\");\r\n\t\t\t\t\tif(c){c.removeClass(a);}\r\n\t\t\t\t\tif(h){f.find(\"div.active\").addClass(\"animated \"+h);a=h;}\r\n\t\t\t\t\telse{if(g){f.find(\"div.active\").addClass(\"animated \"+g);a=g;}else{f.find(\"div.active\").addClass(\"animated \"+b);a=b;}}c=f.find(\"div.active\");\r\n\t\t\t\t});\r\n\t\t\t}\r\n\t\t});\r\n\t\t\r\n\r\n\t\tfunction do_resize(){\r\n\r\n\t\t\tvar width=jQuery( '.tab-content .tab-pane iframe' ).width();\r\n\t\t\tvar height=jQuery( '.tab-content .tab-pane iframe' ).height();\r\n\r\n\t\t\tvar toggleSize = true;\r\n\t\t\tjQuery('iframe').animate({\r\n\t\t\t    width: toggleSize ? width : 640,\r\n\t\t\t    height: toggleSize ? height : 360\r\n\t\t\t  }, 250);\r\n\r\n\t\t\t  toggleSize = !toggleSize;\r\n\t\t}\r\n\r\n\r\n\t<\/script>\r\n\t\t\t\t\r\n\t\t\t\n<p><strong>Output<\/strong><\/p>\n<pre><code>6<\/code><\/pre>\n<p>Suppose we want to execute sum(3):<br \/>\nThe top of the system stack is exactly the base, thus when we run sum(3), a stack frame is stored, and a new stack frame for the function is &quot;pushed&quot; on top of the stack. The example is as follows:<\/p>\n<p><img decoding=\"async\" src=\"https:\/\/prepbytes-misc-images.s3.ap-south-1.amazonaws.com\/assets\/1683280771805-1-04%20%2820%29.png\" alt=\"\" \/><\/p>\n<p>The top stack frame will be removed from the system stack when the base case has been completed:<\/p>\n<p><img decoding=\"async\" src=\"https:\/\/prepbytes-misc-images.s3.ap-south-1.amazonaws.com\/assets\/1683280771835-1-05%20%2814%29.png\" alt=\"\" \/><\/p>\n<p>The next top stack frame will also be popped after that:<\/p>\n<p><img decoding=\"async\" src=\"https:\/\/prepbytes-misc-images.s3.ap-south-1.amazonaws.com\/assets\/1683280771865-1-06%20%2810%29.png\" alt=\"\" \/><\/p>\n<p>As the process continues, the computer will eventually run the initial programme and provide an accurate response:<\/p>\n<p><img decoding=\"async\" src=\"https:\/\/prepbytes-misc-images.s3.ap-south-1.amazonaws.com\/assets\/1683280771868-1-07%20%289%29.png\" alt=\"\" \/><\/p>\n<p><strong>Conclusion<\/strong><br \/>\nWe concluded that stack is the data structure used for implementing the recursion and is used to store the activation record of a function call, which includes the address of the calling function, local variables, and arguments. The recursive function&#8217;s time complexity is proportional to the number of calls that are made to it and space complexity is equal to the number of calls made to it since the call stack will hold the same number of activation records.<\/p>\n<h2>Frequently Asked Questions<\/h2>\n<p><strong>Q1. What type of data structure implements a priority queue?<\/strong><br \/>\n<strong>Ans.<\/strong> An array, a linked list, a heap data structure, or a binary search tree can all be used to build a priority queue. One of these data structures that effectively implement priority queues is the heap data structure.<\/p>\n<p><strong>Q2. Which data structure is employed in the implementation of a fixed or static stack?<\/strong><br \/>\n<strong>Ans.<\/strong> The finest example of static data structures is an array, which has a fixed size and allows for subsequent data modification.<\/p>\n<p><strong>Q3. Why is a stack referred to as an abstract data type?<\/strong><br \/>\n<strong>Ans.<\/strong> Because push and pop are the two main operations in a stack, it is known as an abstract data type. Which are when applied to any set of data, it is free from the type of data that the set must contain.<\/p>\n<p><strong>Q4. What is the difference between static and dynamic implementation of a list?<\/strong><br \/>\n<strong>Ans.<\/strong> A static data structure has a defined size and cannot be altered during runtime. As a dynamic list can change to fit the data inside of it, it uses less space overall.<\/p>\n<p><strong>Q5. Can we use an array to implement a stack?<\/strong><br \/>\n<strong>Ans.<\/strong> When using an array, the stack is created using the array. Arrays are utilised for all stack-related tasks.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Stack(LIFO) data structure is one of the famous data structures used for implementing recursion. Recursion is a method of problem-solving where a function is run repeatedly on smaller inputs until a base case, or the smallest input with a simple answer, is reached. What is Recursion in Data Structure? Recursion is the process of repeatedly [&hellip;]<\/p>\n","protected":false},"author":52,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_monsterinsights_skip_tracking":false,"_monsterinsights_sitenote_active":false,"_monsterinsights_sitenote_note":"","_monsterinsights_sitenote_category":0,"footnotes":""},"categories":[191],"tags":[],"class_list":["post-16160","post","type-post","status-publish","format-standard","hentry","category-data-structure"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v25.8 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>Which Data Structure is used for Implementing Recursion?<\/title>\n<meta name=\"description\" content=\"Recursion is the process of repeatedly applying a rule or procedure until one arrives at the solution.\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/prepbytes.com\/blog\/which-data-structure-is-used-for-implementing-recursion\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Which Data Structure is used for Implementing Recursion?\" \/>\n<meta property=\"og:description\" content=\"Recursion is the process of repeatedly applying a rule or procedure until one arrives at the solution.\" \/>\n<meta property=\"og:url\" content=\"https:\/\/prepbytes.com\/blog\/which-data-structure-is-used-for-implementing-recursion\/\" \/>\n<meta property=\"og:site_name\" content=\"PrepBytes Blog\" \/>\n<meta property=\"article:publisher\" content=\"https:\/\/www.facebook.com\/prepbytes0211\/\" \/>\n<meta property=\"article:published_time\" content=\"2023-05-05T10:02:13+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/prepbytes-misc-images.s3.ap-south-1.amazonaws.com\/assets\/1683280771631-Which%20data%20structure%20is%20used%20for%20implementing%20recursion.jpg\" \/>\n<meta name=\"author\" content=\"Prepbytes\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Prepbytes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\/\/prepbytes.com\/blog\/which-data-structure-is-used-for-implementing-recursion\/#article\",\"isPartOf\":{\"@id\":\"https:\/\/prepbytes.com\/blog\/which-data-structure-is-used-for-implementing-recursion\/\"},\"author\":{\"name\":\"Prepbytes\",\"@id\":\"http:\/\/43.205.93.38\/#\/schema\/person\/3f7dc4ae851791d5947a7f99df363d5e\"},\"headline\":\"Which Data Structure is used for Implementing Recursion?\",\"datePublished\":\"2023-05-05T10:02:13+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\/\/prepbytes.com\/blog\/which-data-structure-is-used-for-implementing-recursion\/\"},\"wordCount\":902,\"commentCount\":0,\"publisher\":{\"@id\":\"http:\/\/43.205.93.38\/#organization\"},\"image\":{\"@id\":\"https:\/\/prepbytes.com\/blog\/which-data-structure-is-used-for-implementing-recursion\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/prepbytes-misc-images.s3.ap-south-1.amazonaws.com\/assets\/1683280771631-Which%20data%20structure%20is%20used%20for%20implementing%20recursion.jpg\",\"articleSection\":[\"Data Structure\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\/\/prepbytes.com\/blog\/which-data-structure-is-used-for-implementing-recursion\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\/\/prepbytes.com\/blog\/which-data-structure-is-used-for-implementing-recursion\/\",\"url\":\"https:\/\/prepbytes.com\/blog\/which-data-structure-is-used-for-implementing-recursion\/\",\"name\":\"Which Data Structure is used for Implementing Recursion?\",\"isPartOf\":{\"@id\":\"http:\/\/43.205.93.38\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\/\/prepbytes.com\/blog\/which-data-structure-is-used-for-implementing-recursion\/#primaryimage\"},\"image\":{\"@id\":\"https:\/\/prepbytes.com\/blog\/which-data-structure-is-used-for-implementing-recursion\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/prepbytes-misc-images.s3.ap-south-1.amazonaws.com\/assets\/1683280771631-Which%20data%20structure%20is%20used%20for%20implementing%20recursion.jpg\",\"datePublished\":\"2023-05-05T10:02:13+00:00\",\"description\":\"Recursion is the process of repeatedly applying a rule or procedure until one arrives at the solution.\",\"breadcrumb\":{\"@id\":\"https:\/\/prepbytes.com\/blog\/which-data-structure-is-used-for-implementing-recursion\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/prepbytes.com\/blog\/which-data-structure-is-used-for-implementing-recursion\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/prepbytes.com\/blog\/which-data-structure-is-used-for-implementing-recursion\/#primaryimage\",\"url\":\"https:\/\/prepbytes-misc-images.s3.ap-south-1.amazonaws.com\/assets\/1683280771631-Which%20data%20structure%20is%20used%20for%20implementing%20recursion.jpg\",\"contentUrl\":\"https:\/\/prepbytes-misc-images.s3.ap-south-1.amazonaws.com\/assets\/1683280771631-Which%20data%20structure%20is%20used%20for%20implementing%20recursion.jpg\"},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/prepbytes.com\/blog\/which-data-structure-is-used-for-implementing-recursion\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"http:\/\/43.205.93.38\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Data Structure\",\"item\":\"https:\/\/prepbytes.com\/blog\/category\/data-structure\/\"},{\"@type\":\"ListItem\",\"position\":3,\"name\":\"Which Data Structure is used for Implementing Recursion?\"}]},{\"@type\":\"WebSite\",\"@id\":\"http:\/\/43.205.93.38\/#website\",\"url\":\"http:\/\/43.205.93.38\/\",\"name\":\"PrepBytes Blog\",\"description\":\"ONE-STOP RESOURCE FOR EVERYTHING RELATED TO CODING\",\"publisher\":{\"@id\":\"http:\/\/43.205.93.38\/#organization\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"http:\/\/43.205.93.38\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Organization\",\"@id\":\"http:\/\/43.205.93.38\/#organization\",\"name\":\"Prepbytes\",\"url\":\"http:\/\/43.205.93.38\/\",\"logo\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"http:\/\/43.205.93.38\/#\/schema\/logo\/image\/\",\"url\":\"https:\/\/blog.prepbytes.com\/wp-content\/uploads\/2025\/07\/uzxxllgloialmn9mhwfe.webp\",\"contentUrl\":\"https:\/\/blog.prepbytes.com\/wp-content\/uploads\/2025\/07\/uzxxllgloialmn9mhwfe.webp\",\"width\":160,\"height\":160,\"caption\":\"Prepbytes\"},\"image\":{\"@id\":\"http:\/\/43.205.93.38\/#\/schema\/logo\/image\/\"},\"sameAs\":[\"https:\/\/www.facebook.com\/prepbytes0211\/\",\"https:\/\/www.instagram.com\/prepbytes\/\",\"https:\/\/www.linkedin.com\/company\/prepbytes\/\",\"https:\/\/www.youtube.com\/channel\/UC0xGnHDrjUM1pDEK2Ka5imA\"]},{\"@type\":\"Person\",\"@id\":\"http:\/\/43.205.93.38\/#\/schema\/person\/3f7dc4ae851791d5947a7f99df363d5e\",\"name\":\"Prepbytes\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"http:\/\/43.205.93.38\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/secure.gravatar.com\/avatar\/232042cd1a1ea0e982c96d2a2ec93fb70a8e864e00784491231e7bfe5a9e06b5?s=96&d=mm&r=g\",\"contentUrl\":\"https:\/\/secure.gravatar.com\/avatar\/232042cd1a1ea0e982c96d2a2ec93fb70a8e864e00784491231e7bfe5a9e06b5?s=96&d=mm&r=g\",\"caption\":\"Prepbytes\"},\"url\":\"https:\/\/prepbytes.com\/blog\/author\/gourav-jaincollegedekho-com\/\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Which Data Structure is used for Implementing Recursion?","description":"Recursion is the process of repeatedly applying a rule or procedure until one arrives at the solution.","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/prepbytes.com\/blog\/which-data-structure-is-used-for-implementing-recursion\/","og_locale":"en_US","og_type":"article","og_title":"Which Data Structure is used for Implementing Recursion?","og_description":"Recursion is the process of repeatedly applying a rule or procedure until one arrives at the solution.","og_url":"https:\/\/prepbytes.com\/blog\/which-data-structure-is-used-for-implementing-recursion\/","og_site_name":"PrepBytes Blog","article_publisher":"https:\/\/www.facebook.com\/prepbytes0211\/","article_published_time":"2023-05-05T10:02:13+00:00","og_image":[{"url":"https:\/\/prepbytes-misc-images.s3.ap-south-1.amazonaws.com\/assets\/1683280771631-Which%20data%20structure%20is%20used%20for%20implementing%20recursion.jpg","type":"","width":"","height":""}],"author":"Prepbytes","twitter_card":"summary_large_image","twitter_misc":{"Written by":"Prepbytes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/prepbytes.com\/blog\/which-data-structure-is-used-for-implementing-recursion\/#article","isPartOf":{"@id":"https:\/\/prepbytes.com\/blog\/which-data-structure-is-used-for-implementing-recursion\/"},"author":{"name":"Prepbytes","@id":"http:\/\/43.205.93.38\/#\/schema\/person\/3f7dc4ae851791d5947a7f99df363d5e"},"headline":"Which Data Structure is used for Implementing Recursion?","datePublished":"2023-05-05T10:02:13+00:00","mainEntityOfPage":{"@id":"https:\/\/prepbytes.com\/blog\/which-data-structure-is-used-for-implementing-recursion\/"},"wordCount":902,"commentCount":0,"publisher":{"@id":"http:\/\/43.205.93.38\/#organization"},"image":{"@id":"https:\/\/prepbytes.com\/blog\/which-data-structure-is-used-for-implementing-recursion\/#primaryimage"},"thumbnailUrl":"https:\/\/prepbytes-misc-images.s3.ap-south-1.amazonaws.com\/assets\/1683280771631-Which%20data%20structure%20is%20used%20for%20implementing%20recursion.jpg","articleSection":["Data Structure"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/prepbytes.com\/blog\/which-data-structure-is-used-for-implementing-recursion\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/prepbytes.com\/blog\/which-data-structure-is-used-for-implementing-recursion\/","url":"https:\/\/prepbytes.com\/blog\/which-data-structure-is-used-for-implementing-recursion\/","name":"Which Data Structure is used for Implementing Recursion?","isPartOf":{"@id":"http:\/\/43.205.93.38\/#website"},"primaryImageOfPage":{"@id":"https:\/\/prepbytes.com\/blog\/which-data-structure-is-used-for-implementing-recursion\/#primaryimage"},"image":{"@id":"https:\/\/prepbytes.com\/blog\/which-data-structure-is-used-for-implementing-recursion\/#primaryimage"},"thumbnailUrl":"https:\/\/prepbytes-misc-images.s3.ap-south-1.amazonaws.com\/assets\/1683280771631-Which%20data%20structure%20is%20used%20for%20implementing%20recursion.jpg","datePublished":"2023-05-05T10:02:13+00:00","description":"Recursion is the process of repeatedly applying a rule or procedure until one arrives at the solution.","breadcrumb":{"@id":"https:\/\/prepbytes.com\/blog\/which-data-structure-is-used-for-implementing-recursion\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/prepbytes.com\/blog\/which-data-structure-is-used-for-implementing-recursion\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/prepbytes.com\/blog\/which-data-structure-is-used-for-implementing-recursion\/#primaryimage","url":"https:\/\/prepbytes-misc-images.s3.ap-south-1.amazonaws.com\/assets\/1683280771631-Which%20data%20structure%20is%20used%20for%20implementing%20recursion.jpg","contentUrl":"https:\/\/prepbytes-misc-images.s3.ap-south-1.amazonaws.com\/assets\/1683280771631-Which%20data%20structure%20is%20used%20for%20implementing%20recursion.jpg"},{"@type":"BreadcrumbList","@id":"https:\/\/prepbytes.com\/blog\/which-data-structure-is-used-for-implementing-recursion\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"http:\/\/43.205.93.38\/"},{"@type":"ListItem","position":2,"name":"Data Structure","item":"https:\/\/prepbytes.com\/blog\/category\/data-structure\/"},{"@type":"ListItem","position":3,"name":"Which Data Structure is used for Implementing Recursion?"}]},{"@type":"WebSite","@id":"http:\/\/43.205.93.38\/#website","url":"http:\/\/43.205.93.38\/","name":"PrepBytes Blog","description":"ONE-STOP RESOURCE FOR EVERYTHING RELATED TO CODING","publisher":{"@id":"http:\/\/43.205.93.38\/#organization"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"http:\/\/43.205.93.38\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Organization","@id":"http:\/\/43.205.93.38\/#organization","name":"Prepbytes","url":"http:\/\/43.205.93.38\/","logo":{"@type":"ImageObject","inLanguage":"en-US","@id":"http:\/\/43.205.93.38\/#\/schema\/logo\/image\/","url":"https:\/\/blog.prepbytes.com\/wp-content\/uploads\/2025\/07\/uzxxllgloialmn9mhwfe.webp","contentUrl":"https:\/\/blog.prepbytes.com\/wp-content\/uploads\/2025\/07\/uzxxllgloialmn9mhwfe.webp","width":160,"height":160,"caption":"Prepbytes"},"image":{"@id":"http:\/\/43.205.93.38\/#\/schema\/logo\/image\/"},"sameAs":["https:\/\/www.facebook.com\/prepbytes0211\/","https:\/\/www.instagram.com\/prepbytes\/","https:\/\/www.linkedin.com\/company\/prepbytes\/","https:\/\/www.youtube.com\/channel\/UC0xGnHDrjUM1pDEK2Ka5imA"]},{"@type":"Person","@id":"http:\/\/43.205.93.38\/#\/schema\/person\/3f7dc4ae851791d5947a7f99df363d5e","name":"Prepbytes","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"http:\/\/43.205.93.38\/#\/schema\/person\/image\/","url":"https:\/\/secure.gravatar.com\/avatar\/232042cd1a1ea0e982c96d2a2ec93fb70a8e864e00784491231e7bfe5a9e06b5?s=96&d=mm&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/232042cd1a1ea0e982c96d2a2ec93fb70a8e864e00784491231e7bfe5a9e06b5?s=96&d=mm&r=g","caption":"Prepbytes"},"url":"https:\/\/prepbytes.com\/blog\/author\/gourav-jaincollegedekho-com\/"}]}},"_links":{"self":[{"href":"https:\/\/prepbytes.com\/blog\/wp-json\/wp\/v2\/posts\/16160","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/prepbytes.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/prepbytes.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/prepbytes.com\/blog\/wp-json\/wp\/v2\/users\/52"}],"replies":[{"embeddable":true,"href":"https:\/\/prepbytes.com\/blog\/wp-json\/wp\/v2\/comments?post=16160"}],"version-history":[{"count":1,"href":"https:\/\/prepbytes.com\/blog\/wp-json\/wp\/v2\/posts\/16160\/revisions"}],"predecessor-version":[{"id":16161,"href":"https:\/\/prepbytes.com\/blog\/wp-json\/wp\/v2\/posts\/16160\/revisions\/16161"}],"wp:attachment":[{"href":"https:\/\/prepbytes.com\/blog\/wp-json\/wp\/v2\/media?parent=16160"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/prepbytes.com\/blog\/wp-json\/wp\/v2\/categories?post=16160"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/prepbytes.com\/blog\/wp-json\/wp\/v2\/tags?post=16160"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}