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: 30/07/2018
Based on the chapter Data Structure and Pointers, some of the important questions are covered in this question paper. The questions are prepared from the book back and the creative questions.
Students, subscribe and get plenty of question paper with answer key. For subscription please click here.
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.
Write a function in ALTERSUM (int B[][5], int N, int M) in C++ to find and return the sum of elements from all alternates elements of a two dimensional array starting fromB[0][0].
2.
Write a function in c++, with accept an integer array and its size as parameters and replace the elements having odd values with the thrice its value and the element having even with twice its values.
e.g.If an array contains the elements as 3,4,5,16,9. then the function should rearrange the array as 9,8,15,32,27
3.
Write a Get1From2() function in c++ to transfer the content from two array FIRST[] and SECOND[] to array ALL[].the even places(0,2,4...) of array ALL[] should get the content from the array First[] and odd places (1,3,5,...) of the array ALL[] should get the content from the array SECOND[].
e.g if the FIRST[]array contain
30,60,90
and the SECOND[] array contains
10,50,80
The ALL[] array should contain
30,10,60,50,90,80
4.
What are the drawbacks of linear queue?
5.
Write a function in C++ to perform push operation in a dynamically allocated stack containing admission numbers of students. Also,declare the relevant class/structure and points.
6.
Given the following class:
char *msg[]={:overflow"."underflow"};
class stack
{
int top;//the stack pointer
int stk[5];//the elements
void err_rep(int e_num)
{
cout<
//report error message
public:
void init(){top=0;}
//initialise the stack pointer
void push(int);
//put new value in stack
void pop();
//get the pop value
};
Define pop outside the stack.In your definition take care of underflow condition. Function pop should invoke error_rep to report underflow
7.
Write a function in C++ to perform push operation on a dynamically allocated stack containing real numbers.
8.
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;
};
9.
Write a function QINSERT() in C++ to perform insert operation on a linked queue, which contains client no and Client name.Consider the following definition of NODE in the code of QINSERT():
struct NODE
{
long int Cno; //Client number
char Cname[20]; //Client name
NODE *Next;
};
10.
How wil you know that a linear queue is full?
11.
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?
12.
Evaluate the following postfix expression using a stack.Show the contains of stack after execution of each operation.
TRUE,FALSE,TRUE,FALSE,NOT,OR,TRUE,OR,OR,AND
13.
Evaluate the following postfix expression showing the status after execution of each step:
10,40,+,8,2,+,*,10,-
14.
Evaluate the following postfix notation of expression:
True,False,NOT,AND,True,True,AND,OR
15.
Why are parentheses needed to specify the order of operations in infix expression but not in postfix expression?
16.
Give the output of the following program segment (assume all required header files are include in the program)
void main()
{
char *NAME="a ProFile";
for(int x=0;x<strlen(NAME);x++)
if(islower(NAME[x]));
else
if(isupper(NAME[x]))
if(x%2!=0)
NAME[x]=tolower(NAME[x-1]);
else
NAME[x]--;
cout<<NAME<<end1;
}
17.
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.
int ALTERSUM (int B[][5], int N,int M)
{
int s=0,c=1;
for(int i=0;i<N;i++)
{
if(C%2 !=0)
s = s+B[i][j];
c++;
}
return s;
}
2.
void Rearrange(int A[],int size)
{
for(int i=0;i<size;i++)
{
if(A[i]%2 == 0)
A[i] *= 2;
else
A[i] *= 3;
}
}
3.
void Get1FRom2(int FIRST[],int ECOND[],
{
int ALL[6];
for(j=1,i=0;j
ALL[i] = FIRST[j];
}
for(j=1,i=0;J
ALL[j] = SECOND[i];
}
}
4.
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.
5.
struct node
{
int admno;
node *link;
};
node *push(node *top,int va1)
{
node *temp=new node;
temp->admno=va1;
temp->link=NULL;
if(top=NULL)
top=temp;
else
{
temp->link=top;
top=temp;
}
return(top);
}
6.
The function is:
void stack:: pop()
{
if(top==0)
err_rep(1);
else
cout<
7.
struct Node
{
float data;
Node *next;
};
Node *Top=NULL;
void Push(float num)
{
Node *nptr=new Node;
nptr->data=num;
nptr->next=NULL;
if(Top==NULL)
Top=nptr;
else
{
nptr->next=Top;
Top=nptr;
}
cout<<"\nItem Inserted";
}
8.
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;
}
}
9.
void QINSERT()
{
NODE *N=new NODE;
cout<<"Enter the client Number and Name";
cin>>N->Cno>>N->Cname;
N->Next = NULL;
if( FRONT == NULL && REAR == NULL )
FRONT = REAR = N;
else
{
REAR->Next = N;
REAR = N;
}
}
10.
( )
In a linear queue,if Rear is equal to maximum size then queue is full.
11.
( )
(i) 10
(ii) Front = 6
12.
In the given, expression true and false are operands and AND, NOT and OR operators.
| Scanned Elements | operation | Stack Status |
| TRUE | PUSH TRUE | TRUE |
| FALSE | PUSH FALSE | TRUE,FALSE |
| TRUE | PUSH TRUE | TRUE,FALSE,TRUE |
| FALSE | PUSH FALSE | TRUE,FALSE,TRUE,FALSE |
| NOT | POP one operand NOT FALSE=TRUE PUSH TRUE |
TRUE,FALSE,tRUE,TRUE |
| OR | POP two operands Evaluate: TRUE OR TRUE=TRUE PUSH TRUE |
TRUE,FALSE,tRUE |
| TRUE | PUSH TRUE | TRUE,FALSE,TRUE,TRUE |
| OR | POP two operands Evaluate: TRUE OR TRUE=TRUE PUSH TRUE |
|
| OR | POP two operands Evaluate: FALSE OR TRUE=TRUE PUSH TRUE |
TRUE,TRUE |
| AND | POP two operands AND TRUE=TRUE PUSH TRUE |
TRUE |
Output TRUE
13.
The stack operation is:
| Scanned Elements | Operation | Stack Status |
| 10 | Push 10 | 10 |
| 40 | Push 40 | 10,40 |
| + | Pop 40,Pop10 Calculate 40+10=50 Push 50 |
50 |
| 8 | Push 8 | 50,8 |
| 2 | Push 2 | 50,8,2 |
| + | Pop 2,Pop 8 Calculate 2+8=10 Push 10 |
|
| * | Pop 10,Pop 50 Calculate 10*50=500 Push 500 |
500 |
| 10 | Push 10 | 500,10 |
| - | Pop 10,Pop 500 Calculate 500-10=490 Push 490 |
490 |
Output 490
14.
| Scanned Elements | Stack Status |
| True | True |
| False | True,False |
| NOT | True,True |
| AND | True |
| True | True,True |
| True | True,True,True |
| AND | True,True |
| OR | True |
Output True
15.
Main advantage of using postifix or prefix expression is that parentheses are not required to enclose the operations. so,the problem of nesting of expression is removed.Every operator in a postfix or prefix expression is placed according to its prexcdence. Therefore, no ambiguity exists in interpreting arithmetic expression.
16.
a Orooile
17.
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