Download CBSE Class 12 Computer Science Useful Resources
Access comprehensive study materials and useful resources for Arrays Stacks Queues And Linked List using the Class 12 Arrays Stacks Queues And Linked List Revision Notes. Designed to align with the 2026-27 CBSE academic guidelines, these advanced resources help Class 12 Computer Science students reinforce core concepts beyond standard textbooks.
Access CBSE Study Guides and Summaries
Navigate directly to the advanced Computer Science study materials using the digital viewer below. Each resource pack includes detailed conceptual summaries and solved practice questions, allowing students to instantly reinforce their learning.
Class 12 Computer Science revision notes on Chapter 6 Arrays, Stacks, Queues and Linked List from Unit II Data Structure, covering simple and compound data structures, linear and binary search in an array with C++ code, bubble sort, the array questions on reversing, pairing and merging arrays and on two dimensional arrays, and the address calculation of elements in row major and column major order.
Unit-II Data Structure
In Computer Science, a data structure is a particular way of storing and organising data in a computer so that it can be used efficiently. Different kinds of data structures are suited to different kinds of applications, and some are highly specialised to specific tasks.
Simple Data Structure: These data structures are normally built from primitive data types like integers, floats and characters. For example, arrays and structures.
Compound Data Structure: Simple data structures can be combined in various ways to form more complex structures called compound structures. Linked lists, stacks, queues and trees are examples of compound data structures.
Searching Methods in Array
Linear Search: In this method each element of the array is compared with the number to be searched in linear order (from first to last). Where the number is matched, the position is displayed.
#include<iostream.h>
#include<conio.h>
void main()
{
int lsearch(int[],int,int);
int a[50],item,n,index;
clrscr();
cout<<"\n Enter size of array";
cin>>n;
cout<<"\n Enter array elements";
for(int i=0;i<n;i++)
cin>>a[i];
cout<<"Enter the item to be searched";
cin>>item;
index=lsearch(a,n,item);
if(index==-1)
cout<<"\n Element not found";
else
cout<<"\n Element found at position "<<index+1;
getch();
}
int lsearch(int a[],int size,int item)
{
int found=0;
for(int i=0;i<size;i++)
{
if(a[i]==item)
{
return i;
found=1;
break;
}
}
if(found==0)
return -1;
}
Binary Search Method: The binary search algorithm is applicable only for an already sorted array. In this algorithm, to search for the given item from the sorted array (in ascending order), the item is compared with the middle element of the array. If the middle element is equal to the item, then the index of the middle element is returned. Otherwise, if the item is less than the middle element, the item is present in the first half segment of the array (i.e., between 0 to middle-1), so the next iteration will continue for the first half only. If the item is larger than the middle element, the item is present in the second half of the array (i.e., between middle+1 to size-1), so the next iteration will continue for the second half segment only. The same process continues until either the item is found (search successful) or the segment is reduced to a single element and the item is still not found (search unsuccessful).
#include<iostream.h>
#include<conio.h>
void main()
{
int bsearch(int[],int,int);
int a[50], item, n, index;
clrscr();
cout<<"\n Enter total elements";
cin>>n;
cout<<"\n Enter array elements in sorted form:";
for(int i=0;i<n;i++)
cin>>a[i];
cout<<"Enter the item to be searched";
cin>>item;
index=bsearch(a, n, item);
if(index==-1)
cout<<"\n Element not found";
else
cout<<"\n Element found at position "<<index+1;
getch();
}
int bsearch(int a[], int size, int item)
{
int beg, med, last;
int found=0;
beg=0;
last=size-1;
while(beg<=last)
{
med=(beg+last)/2;
if(item==a[med])
{
return med;
found=1;
break;
}
else if(item>a[med])
beg=med+1;
else
last=med-1;
}
if(found==0)
return -1;
}
Sorting Operation in the Array
Sorting means to arrange the array elements in ascending order or in descending order. There are various methods to do this, but for ease, the bubble sort method is shown here.
#include<iostream.h>
#include<conio.h>
void bubblesort (int[],int);
void main()
{
int a[50],n;
clrscr();
cout<<"\nHow many elements do you want to create array with? ";
cin>>n;
cout<<"\nEnter array elements\n";
for(int i=0;i<n;i++)
cin>>a[i];
bubblesort(a,n);
cout<<"\n\nThe sorted array is as shown below\n";
for(int i=0;i<n;i++)
cout<<a[i]<<"\n";
getch();
}
void bubblesort(int a[],int n) //Function to perform bubble sort
{
int temp;
for(int i=0;i<n-1;i++)
{
for(int j=0;j<n-i-1;j++)
if(a[j]>a[j+1])
{
temp=a[j];
a[j]=a[j+1];
a[j+1]=temp;
}
}
}
Some Questions Based on Array
Q1. Write a function in C++ which accepts an integer array and its size as arguments/parameters and reverses the array.
Example: if the array is 1,2,3,4,5 then rearrange the array as 5,4,3,2,1
Ans:
void reverse(int arr[ ], int n)
{
int temp;
for(int i=0,j=n-1; i<=j; i++,j--)
{
temp= arr[i];
arr[i] = arr[j];
arr[j] = temp;
}
}
Q2. Write a function in C++ which accepts an integer array and its size as arguments/parameters and exchanges the elements of the array in the given manner.
Example: if the array is 1,2,3,4,5,6,7,8,9,10 then rearrange the array as 2,1,4,3,6,5,8,7,10,9
Ans:
void change(int arr[ ], int n)
{
int temp;
for(int i=0; i<n; i=i+2)
{
temp= arr[i];
arr[i] = arr[i+1];
arr[i+1] = temp;
}
}
Q3. Write a function in C++ to merge the contents of two sorted arrays A and B into a third array C. Assuming array A is sorted in ascending order, B is sorted in descending order, the resultant array is required to be in ascending order.
Ans:
void merge(int A[], int M, int B[], int N, int C[])
{
int i=0, j=N-1, k=0;
while(i<M && j>=0)
{
if(A[i]<=B[j])
C[k++]=A[i++];
else
C[k++]=B[j--];
}
while(i<M)
C[k++]=A[i++];
while(j>=0)
C[k++]=B[j--];
}
Q4. Write a function in C++ which accepts an integer array and its size as arguments and assigns the elements into a two dimensional array of integers in the following format.
If the array is 1,2,3,4,5,6 the resultant 2D array is:
123456
012345
001234
000123
000012
000001
If the array is 1,2,3 the resultant 2D array is:
123
012
001
Ans: In row i, column j holds a[j-i] when j is greater than or equal to i, and 0 otherwise.
void makeMatrix(int a[], int n, int B[][20])
{
for(int i=0; i<n; i++)
for(int j=0; j<n; j++)
if(j>=i)
B[i][j]=a[j-i];
else
B[i][j]=0;
}
Questions Based on Two Dimensional Array
Q1. Write a function in C++ that will accept a 2-D array and its row and column size as arguments and find the sum of rows and columns.
Ans:
void rowcolsum(int A[ ][ ],int N, int M)
{
for (int i=0;i<N;i++)
{
int SumR=0;
for (int j=0;j<M;j++)
SumR+=A[i][j];
cout<<SumR<<endl;
}
for (int i=0;i<N;i++)
{
int SumC=0;
for (int j=0;j<M;j++)
SumC+=A[j][i];
cout<<SumC<<endl;
}
}
Q2. Write a function in C++ to find the sum of both left and right diagonal elements from a two dimensional array (matrix).
Ans:
void DiagSum(int A[ ][ ], int N)
{
int SumD1=0,SumD2=0;
for (int I=0;I<N;I++)
{
SumD1+=A[I][I];
SumD2+=A[N-I-1][I];
}
cout<<"Sum of Diagonal 1:"<<SumD1<<endl;
cout<<"Sum of Diagonal 2:"<<SumD2<<endl;
}
Address Calculation in Two Dimensional Array
A two dimensional array can be stored in two manners:
1. Row Major Order
2. Column Major Order
To find the address of a particular row and column in Row Major Order, the formula is:
Address of A[row][column] = B + w × (n × row + column)
Where B = Base address of the array, w = Word size, and n = total number of columns in the array.
To find the address of a particular row and column in Column Major Order, the formula is:
Address of A[row][column] = B + w × (n × column + row)
Where B = Base address of the array, w = Word size, and n = total number of rows in the array.
Q1. An array x[30][10] is stored in the memory with each element requiring 4 bytes of storage. If the base address of x is 4500, find out the memory location of x[12][8] if the contents are stored along the row.
Ans: Here the array is stored in Row Major Order, so
1. B = 4500, w = 4, n = 10
2. Address of A[row][column] = B + w × (n × row + column)
3. = 4500 + 4 × (10 × 12 + 8)
4. = 4500 + 4 × 128 = 4500 + 512
5. = 5012
Q2. An array P[20][30] is stored in the memory along the column with each of the element occupying 4 bytes. Find out the base address of the array, if the element P[2][20] is stored at the memory location 5000.
Ans:
1. Given: w = 4, n (number of rows) = 20, M (number of columns) = 30, Loc(P[2][20]) = 5000
2. Column Major Formula: Loc(P[I][J]) = B + w × (n × J + I)
3. Loc(P[2][20]) = B + 4 × (20 × 20 + 2)
4. 5000 = B + 4 × 402 = B + 1608
5. B = 5000 - 1608 = 3392
Q3. An array S[40][30] is stored in the memory along the row with each of the element occupying 2 bytes. Find out the memory location for the element S[20][10], if the element S[15][5] is stored at the memory location 5500.
Ans:
1. Given: w = 2, n (number of rows) = 40, M (number of columns) = 30, Loc(S[15][5]) = 5500
2. Row Major Formula: Loc(S[I][J]) = B + w × (M × I + J)
3. Loc(S[15][5]) = B + 2 × (30 × 15 + 5)
4. 5500 = B + 2 × 455 = B + 910, so B = 5500 - 910 = 4590
5. Loc(S[20][10]) = 4590 + 2 × (30 × 20 + 10)
6. = 4590 + 2 × 610 = 4590 + 1220 = 5810
Free study material for Computer Science
Free CBSE Study Guides: Class 12 Computer Science Arrays Stacks Queues And Linked List
Essential Notes for Class 12 Computer Science
Access comprehensive study material for Arrays Stacks Queues And Linked List, including revision notes, concept maps, and high-probability questions. These resources are designed in alignment with the latest 2026 CBSE syllabus for Class 12 Computer Science to support effective exam preparation.
Verified Solutions for Class 12 Computer Science
Built using official NCERT guidelines for Class 12 Computer Science, these materials provide reliable academic support. Integrating past examination questions and step-by-step solutions helps students understand official CBSE grading criteria.
Enhance Accuracy with Online Tests
Maximize your grade potential by utilizing Class 12 Computer Science practice papers in tandem with these structured notes. All printable assignments and interactive mock tests on our platform are updated for the 2026 session and available free of charge.
FAQs
Our advanced study package for Arrays Stacks Queues And Linked List includes detailed concepts, diagrams, Mind Maps, and explanation of complex topics to ensure Class 12 students learn as per syllabus for 2026 exams.
The Mind Maps provided for Arrays Stacks Queues And Linked List act as visual anchors which will help faster recall during high-pressure exams.
Yes, teachers use our Class 12 Computer Science resources for lesson planning as they are in simple language and have lot of solved examples.
Yes, You can download the complete, mobile-friendly PDF of the Computer Science Arrays Stacks Queues And Linked List advanced resources for free.
Yes, our subject matter experts have updated the Arrays Stacks Queues And Linked List material to align with the rationalized NCERT textbooks and have removed deleted topics and added new competency-based questions.