{"id":29299,"date":"2013-05-30T12:06:49","date_gmt":"2013-05-30T06:36:49","guid":{"rendered":"http:\/\/www.kopykitab.com\/blog\/?p=29299"},"modified":"2013-05-30T12:06:49","modified_gmt":"2013-05-30T06:36:49","slug":"data-structure-notes","status":"publish","type":"post","link":"https:\/\/www.kopykitab.com\/blog\/data-structure-notes\/","title":{"rendered":"Data Structure Notes"},"content":{"rendered":"<h1 style=\"text-align: center;\">Data Structure Notes<\/h1>\n<p>&nbsp;<\/p>\n<p><b>Abstract Data Type<\/b><\/p>\n<p>An abstract data type (ADT) is a set of data values and associated operations that are precisely specified independent of any particular implementation; such a data type is abstract in the sense that it is independent of various concrete implementations. Some of the examples of the ADT are String, List, Linked, Stack, Queue, Binary search tree, Priority queue and more.<\/p>\n<p><strong>Binary Tree<\/strong><\/p>\n<p>The simplest form of tree is a\u00a0<em>binary tree.<\/em>\u00a0A\u00a0<em>binary tree<\/em>\u00a0consists of\u00a0 maximum two child nodes,<br \/>\na. a node (called the root node) and<br \/>\nb. left and right sub-trees.<br \/>\nBoth the sub-trees are themselves binary trees.<\/p>\n<p><img class=\"alignnone size-medium wp-image-29300\" alt=\"2\" src=\"http:\/\/www.kopykitab.com\/blog\/wp-content\/uploads\/2013\/05\/238-300x162.jpg\" width=\"300\" height=\"162\" srcset=\"https:\/\/www.kopykitab.com\/blog\/wp-content\/uploads\/2013\/05\/238-300x162.jpg 300w, https:\/\/www.kopykitab.com\/blog\/wp-content\/uploads\/2013\/05\/238-30x16.jpg 30w, https:\/\/www.kopykitab.com\/blog\/wp-content\/uploads\/2013\/05\/238.jpg 440w\" sizes=\"(max-width: 300px) 100vw, 300px\" \/><\/p>\n<p>&nbsp;<\/p>\n<p><b>Infix to Postfix Conversion<\/b><b><\/b><\/p>\n<p>Converting Infix to Postfix<\/p>\n<p>\u2022\u00a0\u00a0\u00a0 Read in infix string, one item at a time.<\/p>\n<p>\u2022\u00a0\u00a0\u00a0 If the item is an operand add to the postfix string.<\/p>\n<p>\u2022\u00a0\u00a0\u00a0 If the item is an operator push it on the stack if<\/p>\n<p>\u2022\u00a0\u00a0\u00a0 The stack is empty<\/p>\n<p>\u2022\u00a0\u00a0\u00a0 If the precedence of the item at the top of the stack is &lt; the item being processed<\/p>\n<p>\u2022\u00a0\u00a0\u00a0 If the precedence of the item at the top of the stack is &gt; the item being processed pop it to the postfix string<\/p>\n<p>\u2022\u00a0\u00a0\u00a0 When the infix string is empty pop the elements of the stack onto the postfix string to get the result<\/p>\n<p>The Algorithm<\/p>\n<p>1.\u00a0\u00a0\u00a0 Initialize the stack by pushing a \u201c(\u201d \u2014 this serves to mark the beginning of the stack and give it an initial precedence. Append a \u201c)\u201d to the input to pop the initial \u201c(\u201d from the stack.<\/p>\n<p>2.\u00a0\u00a0\u00a0 If the input is empty, go to Finished.<\/p>\n<p>3.\u00a0\u00a0\u00a0 Read one token (operand, parenthesis, operator) from the input.<\/p>\n<p>4.\u00a0\u00a0\u00a0 If the token is an operand, output it and goto Step 1.<\/p>\n<p>5.\u00a0\u00a0\u00a0 Look up the precedence of the input token in the \u201cInput\u201d column of the precedence table.<\/p>\n<p>6.\u00a0\u00a0\u00a0 Look up the precedence of the token on top of the stack in the \u201cStack\u201d column of the precedence table.<\/p>\n<p>7.\u00a0\u00a0\u00a0 If the precedence of the top of the stack is greater than or equal to the precedence of the input, first pop the token off the top of the stack. If it is not a \u201c(\u201d, output it. Either way, go to Step 5. Otherwise, if the precedence of the top of the stack is less than the precedence of the input, then if the input token is not a \u201c)\u201d, push it onto the stack<\/p>\n<p>8.\u00a0\u00a0\u00a0 Go to Step 1.<\/p>\n<p>9.\u00a0\u00a0\u00a0 Finished.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Data Structure Notes &nbsp; Abstract Data Type An abstract data type (ADT) is a set of data values and associated operations that are precisely specified independent of any particular implementation; such a data type is abstract in the sense that it is independent of various concrete implementations. Some of the examples of the ADT are &#8230; <a title=\"Data Structure Notes\" class=\"read-more\" href=\"https:\/\/www.kopykitab.com\/blog\/data-structure-notes\/\" aria-label=\"More on Data Structure Notes\">Read more<\/a><\/p>\n","protected":false},"author":4,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"fifu_image_url":"","fifu_image_alt":""},"categories":[4773],"tags":[2849],"amp_enabled":true,"_links":{"self":[{"href":"https:\/\/www.kopykitab.com\/blog\/wp-json\/wp\/v2\/posts\/29299"}],"collection":[{"href":"https:\/\/www.kopykitab.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.kopykitab.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.kopykitab.com\/blog\/wp-json\/wp\/v2\/users\/4"}],"replies":[{"embeddable":true,"href":"https:\/\/www.kopykitab.com\/blog\/wp-json\/wp\/v2\/comments?post=29299"}],"version-history":[{"count":0,"href":"https:\/\/www.kopykitab.com\/blog\/wp-json\/wp\/v2\/posts\/29299\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.kopykitab.com\/blog\/wp-json\/wp\/v2\/media?parent=29299"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.kopykitab.com\/blog\/wp-json\/wp\/v2\/categories?post=29299"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.kopykitab.com\/blog\/wp-json\/wp\/v2\/tags?post=29299"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}