Teachers and Examiners (CBSESkillEduction) collaborated to create the Data Structures Class 12 Notes. All the important Information are taken from the NCERT Textbook Computer Science (083) class 12.
Data Structures Class 12 Notes
Introduction to Data Structure
A data structure is a specific type of structure used to arrange, process, retrieve, and store data. There are a number of fundamental and specialized forms of data structures, all of which are made to organise data for a particular use. Users may easily get the data using data structure and they use it in the proper ways.
For example – Let’s say I want to gather certain information from the user and keep it for a long period. Then you can use data structures, which make it easier to store, retrieve and manage data easily.
Element of Data Representation
There are two different type of representation of data –
a) Raw data – Raw data are raw facts. These are simply values or set of values.
b) Data item – Data item represents single unit of value of certain type.
Data Structures Class 12 Notes
Difference between Data type vs Data Structure
A data type is one of the variations of a variable that can only have values of the same type allocated to them. A data type specifies a group of values in addition to well specified operations that describe the input-output behaviour. A data structre, on the other hand, is a physical implementation that explicitly defines a method of storing, reading, and altering data stored in a data structre.
Types of Data Structure
There are two different types of Data Structure.
a) Simple Data Structure – These data structures are normally built form primitive data types like integers, reals, characters, Boolean.
b) Compound Data Structure – Simple data structure can be combined in various ways to form more complex structures called compound data structures. Compound data structures are classified into following two types –
- Linear data structures – If its elements are stored in sequence is known as linear data structure. example Array.
- Non-linear Data structures – These are multilevel data structures. Example is Tree.
Linear List Arrays
A list with limited number of elements stored in memory is referred to as a linear array. Only homogenous data elements can be stored in a linear array. The array’s components are organised into a linear list or sequence that can contain the same kind of data. Each element of the array has an associated index number.
Array can be one dimensional, two dimensional or multi dimensional in Python.
Data Structures Class 12 Notes
Stacks
A stack is an arranged group of objects where new objects are always added and old objects are always removed from the same end. Stack is also known as LIFO (Last in, first out) for example If several plates are kept one after another, this indicates that a stack of plates is being maintained. Only one plate can be taken off the top of the stack and one plate can be put on top of the stack.
Queues
First In First Out (FIFO) order is used for performing operations on a queue, which is described as a linear data structure with open ends. In our definition of a queue, a list is one in which all additions are made at one end and all deletions are made at the other.
Linked Lists
A linked list is a type of linear data structure used to hold a set of elements. The linked list can also be used to contain a variety of objects that are similar in type. The list’s components are each denoted by a node. Each node has its own data as well as the following node’s address.
Tree
A tree is a non-linear, hierarchical data structure made up of a number of nodes, where each node holds a value as well as a list of pointers to other nodes. Topmost node is called the root of the tree and bottommost nodes are called leaves of the tree.
Data Structures Class 12 Notes
Operations on Data Structures
The basic operations that are performed on data structures are as follows –
1. Insertion – Insertion in a data structure refers to the adding of a new data element.
2. Deletion – A data element is deleted when it is taken out of a data structure. Before removing the data element, a search is conducted.
3. Searching – Searching involves searching for the specified data element in a data structure.
4. Traversal – A data structure must be traversed in order to process each data element individually.
5. Sorting – Sorting is the process of arranging data items in a data structure in a predetermined order.
6. Merging – Combining is the process of combining components from two comparable data structures to create a brand-new data structure of the same type.
Data Structures Class 12 Notes
Linear Search or Sequential Search
Algorithm
Step 1 : Set ctr = L
Step 2 : Repeat steps 3 through 4 until ctr > U
Step 3 : IF AR[ctr] == ITEM then
{
print(“Search Successful”)
print(ctr, “is the location of”, ITEM)
break
}
Step 4 : ctr = ctr + 1
Step 5 : IF ctr > U then
print(“Search Unsuccessful!”)
Step 6 : END
Program
def Lsearch(AR, ITEM) :
i = 0
while i < len(AR) and AR[i] != ITEM :
i = i + 1
if i < len(AR) :
return i
else :
return False
N = int(input(“Enter desired linear list size(max.50)…”))
print(“\n Enter elements for Linear List \n”)
AR = [0] * N
for i in range(N) :
AR[i] = int(input(“Element” + str(i) + “:”))
ITEM = int(input(“\n Enter to be searched for …”))
index = Lsearch(AR, ITEM)
if index :
print(“\nElement forund at index : “, index, “, Position :”,(index + 1))
else :
print(“\nSorry!! Given element could not be found. \n”)
Data Structures Class 12 Notes
Binary Search
Step 1: Set BEG=LB, END=UB LOC = -1
Step 2: While(BEG <= END)
MID = (BEG+END)/2
if ( ELE = A [ MID ] ) then
LOC = MID
Goto Step 3
else
if( ELE < A[MID])
END=MID-1;
else
BEG=MID+1;
[End if]
[End if]
[End of While loop]
Step 3: if ( LOC >= 0 ) then
Print Element, “Found in Location”, LOC
else
Print Element, “Search is Unsuccessful”
Step 4: Exit
Computer Science Class 12 Notes
- Python Revision tour – 1 Class 12 Notes
- Python Revision tour – 2 Class 12 Notes Notes
- Working with Functions Class 12 Notes
- Using Python Libraries Class 12 Notes
- File Handling Class 12 Notes
- Recursion Class 12 Notes
- Idea of Algorithmic Efficiency Class 12 Notes
- Data Visualization using Pyplot Class 12 Notes
- Data Structure Class 12 Notes
- Computer Network Class 12 Notes
- More on MySQL Class 12 Notes
MCQ for Class 12 Computer Science Python
- Python Revision tour – 1 Class 12 MCQs
- Python Revision tour – 2 Class 12 MCQs
- Working with Functions Class 12 MCQs
- Using Python Libraries Class 12 MCQs
- File Handling Class 12 MCQs
- Recursion Class 12 MCQs
- Data Visualization using Pyplot Class 12 MCQs
- Data Structure Class 12 MCQs
- Computer Network Class 12 MCQs
- More on MySQL Class 12 MCQs
Computer Science Class 12 Questions and Answers
- Python Revision tour – 1 Class 12 Questions and Answers
- Working with Functions Class 12 Questions and Answers
- Using Python Libraries Class 12 Questions and Answers
- File Handling Class 12 Questions and Answers
- Recursion Class 12 Questions and Answers
- Idea of Algorithmic Efficiency Class 12 Questions and Answers
- Data Structure Class 12 Questions and Answers
- More on MySQL Class 12 Questions and Answers
- Computer Network Class 12 Questions and Answers
- More on MySQL Class 12 Questions and Answers