{"id":4119,"date":"2023-08-28T11:29:03","date_gmt":"2023-08-28T05:59:03","guid":{"rendered":"https:\/\/cbsepython.in\/?p=4119"},"modified":"2023-08-28T11:29:03","modified_gmt":"2023-08-28T05:59:03","slug":"data-structures-class-12-notes","status":"publish","type":"post","link":"https:\/\/cbsepython.in\/data-structures-class-12-notes\/","title":{"rendered":"Data Structures Class 12 Notes"},"content":{"rendered":"<h2><span style=\"color: #000000;\">Data Structures Class 12 Notes<\/span><\/h2>\n<p><span style=\"color: #000000;\"><strong>DATA STRUCTURES<\/strong><\/span><\/p>\n<p><span style=\"color: #000000;\">A data structure defines a mechanism to store, organise and access data along with operations (processing) that can be efficiently performed on the data. A data structure is a group of data that have different data types which can be accessed as a unit .<\/span><\/p>\n<p><span style=\"color: #000000;\">For example, string is a data structure containing a sequence of elements where each element is a character. On the other hand, list is a sequence data structures in which each element may be of different types.We can apply different operations like reversal, slicing, counting of elements etc. on list and string. <\/span><\/p>\n<p><span style=\"color: #000000;\">Hence, a data structure organises a multiple elements in a way so that certain operations on each elements as well as the collective data unit could be performed easily.<\/span><\/p>\n<h3 style=\"text-align: center;\"><span style=\"text-decoration: underline;\"><span style=\"color: #000000; text-decoration: underline;\">Data Structures Class 12 Notes<\/span><\/span><\/h3>\n<p>&nbsp;<\/p>\n<h3><span style=\"color: #000000;\">Data type vs Data structure<\/span><\/h3>\n<p><span style=\"color: #000000;\">\u2022 A data type defines a set of values along with well-defined operations stating its <\/span><span style=\"color: #000000;\">input-output behavior. <\/span><br \/>\n<span style=\"color: #000000;\">\u2022 A data structure is a physical implementation that clearly defines a way of storing, <\/span><span style=\"color: #000000;\">accessing, manipulating data stored in a data structure. <\/span><br \/>\n<span style=\"color: #000000;\">For example, List as a data type which can store heterogeneous data type of elements, <\/span><span style=\"color: #000000;\">but when implemented as data structure its behavior is clearly prescribed (searching, <\/span><span style=\"color: #000000;\">sorting etc.)<\/span><\/p>\n<p>&nbsp;<\/p>\n<h2><span style=\"color: #000000;\">Implementation of data structures can be done in two ways.<\/span><\/h2>\n<p><span style=\"color: #000000;\"><strong>Simple Data Structures : <\/strong>Built from primitive data types(integers, real, character, boolean). Example Array or Linear list<\/span><\/p>\n<p><span style=\"color: #000000;\"><strong>Compound Data Structures :<\/strong> Simple data structures are used to form more data structure . They are classified into two types<\/span><\/p>\n<p><span style=\"color: #000000;\"><strong>1.Linear :<\/strong> Means elements are stored in sequential order. <\/span><\/p>\n<p><span style=\"color: #000000;\">Example: Stack, Queue, Linked List<\/span><\/p>\n<p><span style=\"color: #000000;\"><strong>2.Non Linear :<\/strong> Data can be stored as multilevel structures. <\/span><\/p>\n<p><span style=\"color: #000000;\">Example Trees, Graph<\/span><\/p>\n<p><span style=\"color: #000000;\">(Only similarity between stack and queue is that both belong to linear data structures)<\/span><\/p>\n<h3 style=\"text-align: center;\"><span style=\"text-decoration: underline;\"><span style=\"color: #000000; text-decoration: underline;\">Data Structures Class 12 Notes<\/span><\/span><\/h3>\n<h2><span style=\"color: #000000;\">What is Stack?<\/span><\/h2>\n<ul>\n<li><span style=\"color: #000000;\">Stack is a Linear Data Structure<\/span><\/li>\n<li><span style=\"color: #000000;\">Stack is a list of elements in which an element may be inserted or deleted only at one end ,called the TOP of the stack<\/span><\/li>\n<li><span style=\"color: #000000;\">It follows the principle of Last In First Out (LIFO).<\/span><\/li>\n<li><span style=\"color: #000000;\">LIFO means the elements inserted last would be the first to be deleted<\/span><\/li>\n<\/ul>\n<p>&nbsp;<\/p>\n<h2><span style=\"color: #000000;\">Operations on Stack<\/span><\/h2>\n<p><span style=\"color: #000000;\">There are mainly two types of Operation that can be done with stack.<\/span><\/p>\n<p><span style=\"color: #000000;\"><strong>i) Push\u00a0<\/strong><\/span><\/p>\n<p><span style=\"color: #000000;\"><strong>ii) Pop\u00a0<\/strong><\/span><\/p>\n<p>&nbsp;<\/p>\n<p><span style=\"color: #000000;\">Push: Insertion of a element on the top of the stack is called Push.<\/span><\/p>\n<p><img fetchpriority=\"high\" decoding=\"async\" class=\"wp-image-4120 size-large\" src=\"https:\/\/cbsepython.in\/wp-content\/uploads\/2023\/08\/Push_Operation-1024x302.jpg\" alt=\"data structures class 12 notes\" width=\"1024\" height=\"302\" title=\"\" srcset=\"https:\/\/cbsepython.in\/wp-content\/uploads\/2023\/08\/Push_Operation-1024x302.jpg 1024w, https:\/\/cbsepython.in\/wp-content\/uploads\/2023\/08\/Push_Operation-300x89.jpg 300w, https:\/\/cbsepython.in\/wp-content\/uploads\/2023\/08\/Push_Operation-768x227.jpg 768w, https:\/\/cbsepython.in\/wp-content\/uploads\/2023\/08\/Push_Operation.jpg 1135w\" sizes=\"(max-width: 1024px) 100vw, 1024px\" \/><\/p>\n<h3 style=\"text-align: center;\"><span style=\"text-decoration: underline;\"><span style=\"color: #000000; text-decoration: underline;\">Data Structures Class 12 Notes<\/span><\/span><\/h3>\n<p><span style=\"color: #000000;\">Pop : Removal of an element from the top of the stack is called Pop.<\/span><\/p>\n<p><img decoding=\"async\" class=\"wp-image-4121 size-full\" src=\"https:\/\/cbsepython.in\/wp-content\/uploads\/2023\/08\/Pop_Operation.jpg\" alt=\"data structures class 12 notes\" width=\"756\" height=\"222\" title=\"\" srcset=\"https:\/\/cbsepython.in\/wp-content\/uploads\/2023\/08\/Pop_Operation.jpg 756w, https:\/\/cbsepython.in\/wp-content\/uploads\/2023\/08\/Pop_Operation-300x88.jpg 300w\" sizes=\"(max-width: 756px) 100vw, 756px\" \/><\/p>\n<p>&nbsp;<\/p>\n<blockquote><p><span style=\"color: #000000;\">Push and Pop Operations are done from single end called TOP<\/span><\/p><\/blockquote>\n<h3 style=\"text-align: center;\"><span style=\"text-decoration: underline;\"><span style=\"color: #000000; text-decoration: underline;\">Data Structures Class 12 Notes<\/span><\/span><\/h3>\n<h3><span style=\"color: #000000;\">Overflow and Underflow case<\/span><\/h3>\n<p><span style=\"color: #000000;\"><strong>Overflow :<\/strong> It refers to a situation , when one tries to push an element an element in stack\/queue, that is already full . In Python, (for stacks and list implemented as list ), since list can grow, OVERFLOW condition does not arise until the memory is exhausted .<\/span><\/p>\n<p><span style=\"color: #000000;\"><strong>Underflow :<\/strong> It refers to a situation when one tries to pop\/delete an item from an empty stack or queue. That is stack or queue is currently having no element and still one tried to pop an element.<\/span><\/p>\n<h3 style=\"text-align: center;\"><span style=\"text-decoration: underline;\"><span style=\"color: #000000; text-decoration: underline;\">Data Structures Class 12 Notes<\/span><\/span><\/h3>\n<h2><span style=\"color: #000000;\">Implementation of stack using list <\/span><\/h2>\n<p><span style=\"color: #000000;\">The implementation of stack using list in Python is the easiest of all programming <\/span><span style=\"color: #000000;\">language.<\/span><\/p>\n<p><span style=\"color: #000000;\">Basic operations performed on stack are:<\/span><\/p>\n<ol>\n<li><span style=\"color: #000000;\">Creating a stack<\/span><\/li>\n<li><span style=\"color: #000000;\">Push\/Adding elements to the stack<\/span><\/li>\n<li><span style=\"color: #000000;\">Checking for empty stack<\/span><\/li>\n<li><span style=\"color: #000000;\">Pop\/Deleting elements from a stack<\/span><\/li>\n<li><span style=\"color: #000000;\">Traversal\/Displaying a stack<\/span><\/li>\n<\/ol>\n<h3><span style=\"color: #000000;\">List methods used and Important things to remember <\/span><\/h3>\n<ol>\n<li><span style=\"color: #000000;\">list.append(element) \u2013 It is used to implement push operations(used to append or <\/span><span style=\"color: #000000;\">add elements at the end of the list)<\/span><\/li>\n<li><span style=\"color: #000000;\">list.pop() \u2013It is used to implement pop operations(removing elements at the end)<\/span><\/li>\n<li><span style=\"color: #000000;\">list[::-1]-List slicing is used to print the elements in the reverse order from top <\/span><span style=\"color: #000000;\">position to list[0]<\/span><\/li>\n<li><span style=\"color: #000000;\">top=len(list)-1 (length of list -1)<\/span><\/li>\n<li><span style=\"color: #000000;\">stack &#8211; LIFO(Last In First Out)<\/span><\/li>\n<li><span style=\"color: #000000;\">Push and Pop through one end(Top) <\/span><\/li>\n<\/ol>\n<h3 style=\"text-align: center;\"><span style=\"text-decoration: underline;\"><span style=\"color: #000000; text-decoration: underline;\">Data Structures Class 12 Notes<\/span><\/span><\/h3>\n<h2><span style=\"color: #000000;\">Applications of Stack<\/span><\/h2>\n<ol>\n<li><span style=\"color: #000000;\">Reversing a word\/line: This can be accomplished by pushing each character on to a stack <\/span><span style=\"color: #000000;\">as it is read. When the line is finished, characters are popped off the stack and they will <\/span><span style=\"color: #000000;\">come off in the reverse order.<\/span><\/li>\n<li><span style=\"color: #000000;\">The compilers use stacks to store the previous state of a program when a function is <\/span><span style=\"color: #000000;\">called during recursion.<\/span><\/li>\n<li><span style=\"color: #000000;\">Backtracking is a form of recursion. But it involves choosing only one option out of <\/span><span style=\"color: #000000;\">possibilities. Used in solving Puzzle Sudoku.<\/span><\/li>\n<li><span style=\"color: #000000;\">Undo mechanism in Text editors by keeping all the text changes in a stack.<\/span><\/li>\n<\/ol>\n<p><a href=\"https:\/\/cbsepython.in\/implement-a-stack-using-list-python-program-for-class-11\/\"><span style=\"color: #000000;\"><span style=\"color: #0000ff;\">Implementation of a stack using list \u2013 menu oriented program<\/span><\/span> <\/a><\/p>\n<p>&nbsp;<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Data Structures Class 12 Notes DATA STRUCTURES A data structure defines a mechanism to store, organise and access data along with operations (processing) that can be efficiently performed on the data. A data structure is a group of data that have different data types which can be accessed as a unit . For example, string [&hellip;]<\/p>\n","protected":false},"author":3,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[16,20],"tags":[],"class_list":["post-4119","post","type-post","status-publish","format-standard","hentry","category-cbse-sample-papers-class-12","category-cbse-computer-science-with-python-class-12"],"_links":{"self":[{"href":"https:\/\/cbsepython.in\/wp-json\/wp\/v2\/posts\/4119","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/cbsepython.in\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/cbsepython.in\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/cbsepython.in\/wp-json\/wp\/v2\/users\/3"}],"replies":[{"embeddable":true,"href":"https:\/\/cbsepython.in\/wp-json\/wp\/v2\/comments?post=4119"}],"version-history":[{"count":0,"href":"https:\/\/cbsepython.in\/wp-json\/wp\/v2\/posts\/4119\/revisions"}],"wp:attachment":[{"href":"https:\/\/cbsepython.in\/wp-json\/wp\/v2\/media?parent=4119"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/cbsepython.in\/wp-json\/wp\/v2\/categories?post=4119"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/cbsepython.in\/wp-json\/wp\/v2\/tags?post=4119"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}