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: 24/09/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.
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
2.
Write a function in C++, which accept an integer array and its size as arguments and swap the elements of every even location with its following odd location.
Example : if an array of nine elements initially contains the elements as
2,4,1,6,5,7,9,23,10
Then the function should rearrange the array as 4,2,6,1,7,5,23,9,10
3.
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
4.
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();
};
5.
Write a function in C++ to perform push operation on a dynamically allocated stack containing real numbers.
6.
Write function PUSHBOOK() in C++ to perform insert operation on adynamic stack,which contains Book_no and Book_Titile.Consider the following defination of NODE,while writing your C++code.
struct NODE
{
char Book_No;
char Book_Title[20];
NODE *Next;
};
7.
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;
};
8.
Write a function QUEINS() in C++to insert an element in a dynamically allocated queue containing nodes of the following given structure.
struct Node
{
int Pid; //Product id
char Pname[20]; //Product name
Node *Next;
};
9.
Write a function in C++ to perform insert operation in a dynamic queue containing DVD's information (represented with the help of an array of structureDVD).
struct DVD
{
long No;
char title[20];
DVD *Link;
};
10.
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;
};
1.
If (x[i]%2==0)
{
x[i]=x[i]/2;
}
else
{
x[i]=x[i]*2;
}
2.
In this problem you have to take care of two situation.
1. Even number of elements in the array
In the above case x[0] and x[1] are replacing, x[2] and x[3] are replacing and x[4] and x[5] are replacing. Ie exact pair of elements are in the array. 2. Odd number of elements in the array
In the above case x[0] and x[1] are replacing, x[2] and x[3] are replacing and x[4] and x[5] are replacing. Ie exact pair of elements are in the array. 2. Odd number of elements in the array
In the above case x[0] and x[1] are replacing, x[2] and x[3] are replacing and x[4] and x[5] are replacing and last one need not to be replaced because it has no pair. ie. in the case of odd number of elements the limit of the for loop is one less than the loop for the even number of elements
void ChangeOrder(int x[ ], int N)
{
int i,j,temp,limit;
if(N%2!=2)
{
limit=N-1;
} else
{
limit=N;
}
for(i=0;i<limit,i+=2)
{
temp=x[i]
x[i]=x[i+1];
x[i+1]=temp;
}
for(i=0;i<N;i++)
{
cout << x[i];
}
}
3.
The function is:
void stack:: pop()
{
if(top==0)
err_rep(1);
else
cout<
4.
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;
}
5.
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";
}
6.
void PUSHBOOK()
{
NODE *NEW=new NODE;
cout<<"Enter the Book Number:";
cin>>NEW->Book_No;
cout<<"Enter the Book Title:";
gets(NEW->Book_Title);
NEW->Next=top;
top=NEW;
}
7.
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;
}
}
8.
void QUEINS()
{
Node *temp=new Node;
cout<<"Enter the PID and Name";
cin>>temp->pid;
gets(temp->Pid;
temp->Next=NULL;
rear->Next=temp;
rear=temp;
if(front==NULL)
front=temp;
}
9.
void Insert()
{
DVD *p=new DVD;
count<<"Enter the DVD Number and Title";
cin>>p->No;
gets(p->title);
p->Link = NULL);
if((front == NULL )&& (rear == NULL))
{
front = rear = p;
}
else
{
rear->Link=p;
rear = p;
}
}
10.
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;
}
}
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