12th Standard CBSE Syllabus & Materials
12th Standard CBSE
CBSE 12th Economics Government Budget and the Economy Previous year Question Papers Study Material - QB365 Set A
NEW12th Standard CBSE
CBSE 12th Computer Science Interface Python with MySQL - New Previous year Question Papers Study Material - QB365 Set A
NEW12th Standard CBSE
CBSE 12th Computer Science Database Concept - New Previous year Question Papers Study Material - QB365 Set A
NEW12th Standard CBSE
CBSE 12th Computer Science Data Communication - New Previous year Question Papers Study Material - QB365 Set A
NEW12th Standard CBSE
CBSE 12th Computer Science Data Structures - New Previous year Question Papers Study Material - QB365 Set A
NEW12th Standard CBSE
CBSE 12th Computer Science Functions - New Previous year Question Papers Study Material - QB365 Set A

Published on: 28/07/2019
Data Structure and Pointers
Download CBSE Class 12th Standard CBSE Computer Science question papers, sample papers, important questions, and previous year solved papers in PDF format. Get free study materials, NCERT solutions, and exam preparation resources for Class 12th Standard CBSE Computer Science
Questions + Answers key
Take MCQ Computer Science Test

1.
An array VAL[1..10][1..10] requires 8 bytes of storage.if the base address of VAL is 1500,determine the location of VAL[4][5], When the array VAL is stored
(i) Row wise
(ii) Column Wise
2.
Write a function in c++, with accept an integer array and its size as parameters and rearrange the array in reverse order.
e.g
if an array contain the elements as
4,2,5,1,6,7,8,12,10
then the function should rearrange the array as
10,12,8,7,6,1,5,2,4
3.
Write a Get2From1() function in c++ to transfer the content from one array ALL[] to two different arrays odd[] and even[].
The odd[] array should contain the value from odd position (1,3,5,...) of ALL[] and Even[] array should contain the values from places(0,2,4,...) of ALL[].
e.g
The ALL[] array should contain
12,34,56,67,89,90
if the odd[] array contains
34,67,90
and the Even[] array contain
12,56,89
4.
Write code for a function void Convert(int T[], int Num) in c++, which reposition all the elements of the array by shifting the element to the last position.
| 0 | 1 | 2 | 3 | 4 |
| 22 | 25 | 70 | 32 | 12 |
The changed content will be:
| 0 | 1 | 2 | 3 | 4 |
| 25 | 70 | 32 | 12 | 22 |
5.
What are the drawbacks of linear queue?
6.
Suppose a circular queue maintained by an array Q with 12 memory locations and Front and Rear are the two pointers.
Find the number of elements in Q when:
(i) Front=4, Rear=8
(ii) Front=10, Rear=3
(iii) Front=5, Rear=6
and then two elements are deleted.
7.
Write a function in C++ which accepts an integer array and its size as arguments and assign 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
| 1 | 2 | 3 | 4 | 5 | 6 |
| 0 | 1 | 2 | 3 | 4 | 5 |
| 0 | 0 | 1 | 2 | 3 | 4 |
| 0 | 0 | 0 | 1 | 2 | 3 |
| 0 | 0 | 0 | 0 | 1 | 2 |
| 0 | 0 | 0 | 0 | 0 | 1 |
if the array is 1,2,3
The resultant 2D array is
| 1 | 2 | 3 |
| 0 | 1 | 2 |
| 0 | 0 | 1 |
8.
Write a function in C++ which accepts an integer array and its size as argument and exchanges the value of first half side elements with the second half side elements of the array.
Example : If an array of eight elements has initial content as
2,4,1,6,7,9,23,10
The function should rearrange the array as 7,9,23,10,2,4,1,6.
9.
Write a function in C++ which accepts an integer array and its size as arguments and replaces elements having even values with its half and elements having odd values with twice its value
10.
Write a function in C++ which accepts an integer array and its size as arguments and replaces elements having odd values with thrice and elements having even values with twice its value.
Example : If an array of five elements initially contains the elements
3,4,5,16,9
Then the function should rearrange the content of the array as 9,8,15,32,27
11.
Write a function in C++ to perform push operation on a synamically allocated stack considering the following:
struct Node
{
int X<Y;
Node *Link;
};
class STACK
{
Node *Top;
public:
STACK(){Top=NULL:}
void PUSH();
void POP();
STACK();
};
12.
Write a function in C++ to insert an element in a dynamically allocated queue,where each node contains a Name(char) as data.Assume the following definition of THENODE for the same:
structTHENODE
{
char Name[20];
THENODE *Link;
};
13.
Write a function QDELETE() in C++ to perform delete operation on a Linked Queue, which contains Passenger number and Passenger name.Consider the following definition of node in the code:
struct node
{
long int Pno;
char Pname[20];
node *Link;
};
14.
How wil you know that a linear queue is full?
15.
An array circular queue[10] of integers exixt,where currently
Rear=0, Front=1
Answer the following questions based on the above given data:
(i) How many values arte there in queue?
(ii) If five valuesare deleted,whatwould be the new value of Front?
16.
What will be the output of the following program?
#include<iostream.h>
#include|<ctype.h>
#include<conio.h>
#include<string.h>
void changestring(char Text[],int&Counter)
{
char *ptr=Text;
int Length=strlen(Text);
for(;Counter<Length-2;Counter+=2,ptr++)
{
*(ptr+counter)=toupper(*ptr+counter);
}
void main()
{
int position=0;
char Message[]="pointers Fun:;
changestring(Message,position);
cout<<Message<<"@"<<position;
}
17.
Find the output of the following program:
#include<iostream.h>
#include<ctype.h>
typedef char Txt80[80];
void main()
{
char*PText;
Txt80 Tet="Ur2GReAt";
int N=6;
PText=Txt;
while(N>=3)
{
Txt[N]=isupper(Txt[N])?tolower(Txt[N]):toupper(Tet[N]);
cout<<PText<<end1;
N--;
PText;
}
}
18.
Obtain the output from the following C++ program as expected to appear on the screen after its exection.
Important note
All the desired header files are alraedy included in the code, which are required to run the code.
void main()
{
char *Text="AJANTA";|
int *P.Num[]=[1,5,7,9];
P=Num;
cout<<*P<
P++;
cout<<*P<
1.
Given
base = 1500
W = 8 bytes
N = 10
M = 10
I = 4
J =5
(i) To find row major order
VAL[i][j] = B+[I-1)*N+(J-1)]*W
VAL[4][5] = 1500+[(4-1)*10+(5-1)*8
= 1500+(34)*8
= 1500+272
= 1772
(ii) To find column major order
VAL[i][j] = B+[J-1)*N+(I-1)]*W
VAL[4][5] = 1500+[(5-1)*10+(4-1)*8
= 1500+(43)*8
= 1500+344
= 1844
2.
void RevArray(int A[],int size)
{
int i=0, j=ize-1,temp;
for(; i<=j; i++,j--)
{
temp = A[i];
A[i] = A[j];
A{j} = temp;
}
}
3.
void Get2from1(int ALL[],int N)
{
int j=0,k=0;
int odd[10],Even[10];
{
if ((i%2) == 0)
{
Even[j++] =ALL[i];
}
else
{
Odd[k++] = ALL[i];
}
}
}
4.
#include
void Cnver(int T[], int Num)
{
int temp = t[0];
for(int i=0;i<(Num-1);i++)
{
T[i]=T[i+1];
}
5.
Drawbacks of linear queue are:
By the definition of a queue, when we add an element in queue, Rear pointer is increased by 1 whereas, when we remove an element, Front pointer is increased by 1.
But, in array implementation of queue this may cause problem as follows:
Consider the operations performed on a queue(with SIZE=5) as follows:
(i) Initially, empty queue is there so, Front=-1 and Rear=-1
Front=-1
Rear=-1
0 1 2 3 4
(ii)When we add 5 elements in queue, the state of the queue becomes as follows with Front=0 and Rear=4
Front=0
Rear=4
0 1 2 3 4
| 2 | 6 | 5 | 1 | 9 |
(iii) Now suppose, we delete 2 elements from queue,then the state of the queue becomes as follows, with Front=2 and Rear=4
Front=2
Rear=4
0 1 2 3 4
| 5 | 1 | 9 |
(iv) Now, actually we have deleted 2 elements from queue so, there should be space for another 2 elements in the queue, but as Rear pointer is pointing at last position. So, queue overflow condition is reached.
(Rear==SIZE-1) is true, we can't insert new element in the queue even if it has an empty space.To overcome this problem, there is another variation of queue called circular queue.
6.
(i) Front=4, Rear=8
Here, Front<Rear
So, number of elements=Rear-Front+1
=8-4+1=5
(ii) Front=10, Rear=3
Here, Front>Rear
So, number of elements=N+(Rear-Front)+1
=12+(3-10)+1=6
(iii)Front=5, Rear=6
Here, Front<Rear
So, number of elements=Rear-Front+1
=6-5+1=2
Now, when first element is deleted from Front it will point to 6 index, i.e. Front becomes equal to Rear.
Then, after deleting one more element, queue will become empty and both Front and Rear becomes equal to -1.
7.
Condition for putting the value is the position (i<=j) of 2D array otherwise put zero
void Change2Darray(int x[ ],int size)
{
for(i=0;i < size;i++)
{
int k=0;
for(intj=0;j<size;j++)
{
if(i<=i)
{
y[i][j]=x[k];
k++;
}
else
{
y[i][j]=0;
}
}
}
for(i=0;i< size;i++)
{
for(int j=0;j< size;j++)
{
cout<< y[i][j] <<" ";
}
cout << end1;
}
}
8.
The exchanging is happening between the elements indicated by the line
i.e. first element with next element from the middle point, second element with second element from the middle point etc.
If i for representing the first element and j for representing the element after the middle point then initially i=0 and j=N/2 and both will increment in each step(i++ and j++).
void ChangeValue(int x[],int N)
{
int temp;
for(int i =0,j=N/2;i<N/2;j++)
{
temp=x[i]
x[i]=x[i];
x[j]=temp;
}
cout<< end1;
for(i=0;i<N;++)
{
cout<<x[i]" ";
}
}
9.
If (x[i]%2==0)
{
x[i]=x[i]/2;
}
else
{
x[i]=x[i]*2;
}
10.
void ChangeValue(int x[],int N)
{
for(int i=0;i=0;iN;i++)
{
if(x[i]%2!=0) // Checking the element is Od or not
{
x[i]=x[i]*3:
}
else
{
x[i]=x[i]*2
}
}
cout << endl;
for(i=0;i< N;i++)
{
cout << x[i] << " ";
}
}
Note: If the Question is to make element in the odd position to thrice its value and element in the even position to twice its value, then you have to make only one change in the above program to get the answer ie If( (i+1)%2!=0) instead of if(x[i]%2 !=0)
11.
void STACK::PUSH()
{
Node *ptr=new Node;
cout<<"Enter X and Y for new node:";
cin>>ptr->X>>ptr->Y;
ptr->Link=Top;
Top=ptr;
}
12.
void insert(THENODE *rear)
{
THENODE *newptr=new THENODE;
newptr->Link=NULL;
cout<<"Enter name for new NODE";
gets(newptr->Name);
if(rear==NULL)
{
front=rear=newptr;
}
else
{
rear->Link=newptr;
rear=newptr;
}
}
13.
void QDELETE()
{
if( Front == NULL)
{
cout<<"Stack is empty";
exit(0):
}
else
{
node *temp;
cout<<"Passenger Information\n";
cout<<"Number:"<<Front->Pno<<end1;
cout<<"Name:"<<Front->Pname;
temp = Front;
Front = Front -> Link;
delete temp;
}
}
14.
( )
In a linear queue,if Rear is equal to maximum size then queue is full.
15.
( )
(i) 10
(ii) Front = 6
16.
PoiQteMs Wun@10
17.
Output
Ur2GReat
r2GREeat
2GrEat
grEat
18.
Output
1AJANTA
5JANTA
12th Standard CBSE Syllabus & Materials
12th Standard CBSE
CBSE 12th Computer Science Python Revision Tour I - New Previous year Question Papers Study Material - QB365 Set A
NEW12th Standard CBSE
CBSE 12th Business Studies Planning Important Questions And Answers Study Material - QB365 Set A
NEW12th Standard CBSE
CBSE 12th Business Studies Business Environment Important Questions And Answers Study Material - QB365 Set A
NEW12th Standard CBSE
CBSE 12th Business Studies Principles of Management Important Questions And Answers Study Material - QB365 Set A
CBSE 12th Standard CBSE Subjects
CBSE Standards