marking scheme fragment-2 examination(2019-20)...
Post on 17-Mar-2020
4 Views
Preview:
TRANSCRIPT
XII/CS(283)/FRAGMENT-2-EXAM. PAGE 1 OF 18
MARKING SCHEME
FRAGMENT-2 EXAMINATION(2019-20)
CLASS-XII
SUBJECT: COMPUTER SCIENCE(283)
TIME: 3 Hrs M.MARKS:70 General Instructions:
(a) All questions are compulsory.
(b) Programming Language : C++
(c) Read the questions before writing answers.
1 a) What is the output of this program? Select the correct option.
#include <iostream.h>
void main()
{
intarr[] = {4, 5, 6, 7};
int *p = (arr + 1);
cout<<arr;
}
A. 4,5,6,7
B. 5
C. address of 4
D. 7
1
Answer: C. address of 4
1 Mark for correct option
b) Which of the following declaration(s) are illegal?
A. char *str[ ]={“hello”};
B. char *str = “hello”;
C. char str = “hello”;
D. char *str=[“hello”];
1
Answer: C. char str = “hello”;
D.char *str=[“hello”];
½ Mark for each correct option
c) Give difference between the following:
i) int *n=new int(5);
ii) int *n=new int[5];
1
Answer: In i) case n pointer address is initialized by value 5 where as
in ii) array of 5 integer pointers is created and represented by n.
1 Mark for correct difference
XII/CS(283)/FRAGMENT-2-EXAM. PAGE 2 OF 18
½ Mark for only explaining one part
d) Find the output of the following program :
#include<iostream.h>
void main ( )
{
int X[ ] = {10, 25, 30, 55, 100};
int *p = X ;
while ( *p < 110)
{
if (*p%3!=0)
*p = *p + 1 ;
else
*p = *p + 2 ;
p++;
}
for(int I = 4 ;I>= 1 ;I--)
{
cout<< X[I] << “*” ;
if ( I%3 = = 0) cout<<endl ;
}
cout<<X[0]*3<<endl ;
}
2
Answer: 101*56*
32*26*33
1 Mark for each correct output(line)
½ Mark is deducted if ‘*’ not printed
½ Mark deducted if output is displayed in same line
e) Find and write the output of the following C++ program code
Note: Assume all required header files are already being included in the
program.
void main( )
{
char P[ ]=”google”;
int points[ ]={100,200,101,201};
char *K=P;
int *G=points;
cout<<*K<<”<<”<<*G%4<<endl;
K=K+2;
G+=2;
cout<<K<<”::”<<*G<<endl;
3
XII/CS(283)/FRAGMENT-2-EXAM. PAGE 3 OF 18
*K=*K+1;
*G+=10;
cout<<K<<”==”<<*G;
}
Answer:
g<<0
ogle::101
pgle==111
1 Mark for each correct output(line)
½ Mark deducted if output is displayed in same line
f) Find and write the output of the following C++ program code :
Note : Assume all required header files are already included in the program.
#define Modify(N) N*3+10
void main()
{
int LIST[ ]={10,15,12,17};
int *P=LIST, C;
for(C=3; C>=0; C--)
LIST[C]=Modify(LIST[C]);
for (C=0; C<=3; C++)
{
cout<<*P<<":";
P++;
}
}
2
Answer:
40:55:46:61:
1 Mark for correct output
½ Mark deducted for output without ‘:’
2 a) Write the definition of a member function DeletePacket( ) only, of a class
QUEUE in C++, remove/delete Packet information from a dynamically
allocated QUEUE of Packets considering the following code is already written
as a part of the program.
struct Packet {
int PID;
char Address[20];
Packet *LINK;
4
XII/CS(283)/FRAGMENT-2-EXAM. PAGE 4 OF 18
};
class QUEUE {
Packet *Front, *Rear;
public:
QUEUE( )
{
Front=NULL;
Rear=NULL;
}
void AddPacket( );
void DeletePacket( );
void TRAVERSE( );
~QUEUE();
};
Answer:
void QUEUE ::DeletePacket( )
{
if(Front==NULL)
cout<<”empty”;
else
{
Packet *T=Front;
Front=Front->LINK;
delete T;
T=NULL;
}
}
1 Mark for checking if Queue is Empty
1 Mark for assigning Front to T
1 Mark for changing Front value
1 Mark for deleting T
Marks can be given for any other similar answer
b) Write functions in C++ to perform insert operation in a static circular Queue
containing Book‟s information (represented with the help of an array of
structure BOOK).
struct BOOK
{ long Accno; // Book Accession Number
char Title [20]; // Book Title
};
void insertCQ(BOOK CQ[ ],BOOK T,int&rear, int&front,int size)
{
if(front==0&&rear==size-1||front==rear+1)
3
XII/CS(283)/FRAGMENT-2-EXAM. PAGE 5 OF 18
cout<<”full”;
else if(rear==-1)
{
front=rear=0;
CQ[rear]=T;
}
else if(rear==size-1)
{
rear=0;
CQ[rear]=T;
}
else
CQ[++rear]=T;
}
3Marks for correct function definition
1 Mark for each for checking for overflow
½ Mark for each for checking for empty
1 Mark for reset rear to0 condition
½ Mark for inserting for normal case
o Note:Parameters can be globally declared
c) Write the definition of a member function PUSH( )in C++, to add a new book
in a dynamic stack of TEXTBOOK considering the following code is already
included in the program :
struct TEXTBOOK
{ char ISBN[20], TITLE[80];
TEXTBOOK *Next;
};
class STACK
{ TEXTBOOK *Top;
public:
STACK( ){Top=NULL;}
void PUSH();
void POP( );
~STACK( );
};
4
Answer:
void STACK::PUSH()
{
//create a Textbook
XII/CS(283)/FRAGMENT-2-EXAM. PAGE 6 OF 18
TEXTBOOK *R=new TEXTBOOK;
gets(R->ISBN);
gets(R->TITLE);
R->Next=NULL;
if(Top==NULL)
Top=R;
else
{
R->Next=Top;
Top=R;
}
}
1 Mark for creating a new node and assigning/entering appropriate
values in it
1 Mark for checking if Queue is Empty)
1 Mark for assigning Rear and Front as Temp - if Queue is Empty)
1 Mark for assigning Rear->Link as Front and Rear as Temp
Marks can be given for any other similar answer
d) Write the definition of insertQ(int ) and deleteQ( ) to insert and delete elements
for the statically allocated queue as per following code.
#include<iostream.h>
#define size 4
class QUEUE
{
int data[size];
int front,rear;
public: QUEUE( );
void insertQ( int);
void deleteQ( );
void display( );
};
4
Answer:
void QUEUE::insertQ(int n)
{
if(rear==size-1)
cout<<”full”
else if(rear==-1)
{
rear=front=0;
data[rear]=n;
}
else
XII/CS(283)/FRAGMENT-2-EXAM. PAGE 7 OF 18
data[++rear]=n;
}
void QUEUE::deleteQ()
{
if(front==-1)
cout<<”empty”;
elseif(front==rear)
front=rear=-1;
else
front++;
}
2 Marks for each correct function definition
½ Mark for each if condition(for full/empty)
1 ½ Mark for each insert/delete part
No deduction if :: is missing
Marks can be given for any other similar answer
3 a) A Queue is a linear list implemented in____ form.
A. LIFO
B. FIFO
C. SIFO
D. FISO
1
Answer: B. FIFO
1 Mark correct answer
b) Write two applications of Stack in computer System.
1
Answer:
To evaluate mathematical expression.
For execution of various nested functions.
½ Mark for each application
Any other applications can also be accepted
c) Write the definition of PUSH(int) and POP() to insert and delete element from a
statically allocated stack represented by the following code.
const int size=10;
class STACK
{
int STK[size];
int top;
public:
STACK(){top=-1;}
void PUSH(int);
void POP();
void traverse();
4
XII/CS(283)/FRAGMENT-2-EXAM. PAGE 8 OF 18
};
Answer:
void STACK::PUSH(int n)
{
if(top==size-1)
cout<<”full”;
else
STK[++top]=n;
}
void STACK::POP( )
{
if(top==-1)
cout<<”empty”
else
top--;
}
2 Marks for each correct function definition
1 Mark for each if condition(for full/empty)
1 Mark for each insert/delete part
No deduction if :: is missing
Marks can be given for any other similar answer
d) Convert the following infix expression to its equivalent postfix expression
showing stack contents for the conversion:
X – Y / (Z + U) * V
OR
Convert the following infix expression into postfix. show the stack status after
execution of each operation:
(TRUE OR FALSE )AND NOT FALSE OR FALSE
2
Answer:
Mark start and end of expression by enclosing in between [ ]
[X – Y / (Z + U) * V ]
Read
character
stack Postfix expression
[ [
X [ X
- [- X
Y [- XY
/ [-/ XY
( [-/( XY
Z [-/( XYZ
XII/CS(283)/FRAGMENT-2-EXAM. PAGE 9 OF 18
+ [-/(+ XYZ
U [-/(+ XYZU
) [-/ XYZU+
* [-* XYZU+/
V [-* XYZU+/V
] EMPTY XYZU+/V*-
Postfix expression: XYZU+/V*-
ORPart
Mark start and end of expression by enclosing in between [ ]
[(TRUE OR FALSE) AND NOT FALSE OR FALSE]
Read
character
stack Postfix expression
[ [
( [(
TRUE [( TRUE
OR [(OR TRUE
FALSE [(OR TRUE FALSE
) [ TRUE FALSE OR
AND [AND TRUE FALSE OR
NOT [AND NOT TRUE FALSE OR
FALSE [AND NOT TRUE FALSE OR FALSE
OR [OR TRUE FALSE OR FALSE NOT AND
FALSE [OR TRUE FALSE OR FALSE NOT AND FALSE
] Empty TRUE FALSE OR FALSE NOT AND FALSE
OR
Postfix expression : TRUE FALSE OR FALSE NOT AND FALSE OR
2 Marks for correct solution(any one)
1 Marks if only correct answer is written
½ Mark for each 4 steps shown correctly in sequence
e) Evaluate the following postfix expression and show the status of the stack after
every step .
12, 7, 3, – , /, 2, 1, 5, +, *, +
OR
TRUE, FALSE, NOT, AND, NOT,FALSE,OR
2
Answer:
12, 7, 3, – , /, 2, 1, 5, +, *, +
Steps Read
character
Action
performed
Stack Intermediate operations
1 12 PUSH 12
2 7 PUSH 12,7
3 3 PUSH 12,7,3
4 - POP 12,7 OP2=3
XII/CS(283)/FRAGMENT-2-EXAM. PAGE 10 OF 18
POP
PUSH
12
12,4
OP1=7
RESULT=OP1-OP2=4
5 / POP
POP
PUSH
12
Empty
3
OP2=4
OP1=12
RESULT=OP1/OP2=3
6 2 PUSH 3,2
7 1 PUSH 3,2,1
8 5 PUSH 3,2,1,5
9 + POP
POP
PUSH
3,2,1
3,2
3,2,6
OP2=5
OP1=1
RESULT=OP1+OP2=6
10 * POP
POP
PUSH
3,2
3
3,12
OP2=6
OP1=2
RESULT=OP1*OP2=12
11 + POP
POP
PUSH
3
EMPTY
15
OP2=12
OP1=3
RESULT=OP1+OP2=15
ANSWER:15
OR part
TRUE, FALSE, NOT, AND, NOT,FALSE,OR
Steps Read
character
Action
performed
Stack Intermediate operations
1 TRUE PUSH TRUE
2 FALSE PUSH TRUE, FALSE
3 NOT POP
PUSH
TRUE
TRUE,TRUE
OP=FALSE
RESULT =NOT
OP=TRUE
4 AND POP
POP
PUSH
TRUE
EMPTY
TRUE
OP2=TRUE
OP1=TRUE
RESULT=OP1 AND
OP2=TRUE
5 NOT POP
PUSH
EMPTY
FALSE
OP=TRUE
RESULT =NOT
OP=FALSE
6 FALSE PUSH FALSE,FALSE
7 OR POP
POP
PUSH
FALSE
EMPTY
FALSE
OP2=FALSE
OP1=FALSE
RESULT=OP1 OR
OP2=FALSE
ANSWER:FALSE
2 Marks for correct solution(any one)
XII/CS(283)/FRAGMENT-2-EXAM. PAGE 11 OF 18
½ Marks if only correct answer is written
½ Mark for each 2/3 steps shown correctly in sequence
Intermediate operation may not be written
4 a) According to Commutative law , which of the following options is correct
(a) A+B = B+A (b) A.B = B.A
(c) Both (a) & (b) (d) None of these
1
Answer: (c)
1 Mark for correct answer
½ mark for only writing (a) or (b)
b) Any Boolean expression that is either in the form of sum of minterms or
product of maxterms is said to be in _______________
(a) Standard form (b) Non standard form
(c) Canonical form (d) None of the above
1
Answer: (c) Canonical form
1 Mark for correct answer
c) Given the truth table of a function F(X, Y, Z). Write the S-O-P and P-O-S
expression from the following truth table:
X Y Z F
0 0 0 0
0 0 1 1
0 1 0 1
0 1 1 1
1 0 0 0
1 0 1 0
1 1 0 0
1 1 1 1
1
Answer:
SOP:
F(X, Y, Z)=X‟Y‟Z+X‟YZ‟+X‟YZ+XYZ
POS:
F(X, Y, Z)=(X+Y+Z)(X‟+Y+Z)(X‟+Y+Z‟)(X‟+Y‟+Z)
½ Mark each for correct SOP and POS
d) State the principle of duality in Boolean Algebra and give the dual of the
Boolean expression
(X + Y) . (X‟ + Z‟) . (Y + Z)
2
Answer:
It states that from a given Boolean expression another expression can be formed
by carrying out following steps:
XII/CS(283)/FRAGMENT-2-EXAM. PAGE 12 OF 18
Change all AND’s with OR’s
Change all OR’s with AND’s
Change all 0 to 1 or vice-versa
Dual of (X + Y) . (X‟ + Z‟) . (Y + Z)
is (X.Y) +(X‟.Z‟)+(Y.Z)
1 Mark for defining principle of duality
1 Mark for dual of given expression
e) State and prove any one De Morgan‟s law with the help of Truth Table.
2
Answer:
De Morgan‟s Law: (X.Y)‟=X‟+Y‟
X Y X‟ Y‟ X.Y (X.Y)‟ X‟+Y‟
0 0 1 1 0 1 1
0 1 1 0 0 1 1
1 0 0 1 0 1 1
1 1 0 0 1 0 0
Values Of columns (X.Y)‟ and X‟+Y‟ are same hence (X.Y)‟=X‟+Y‟
OR
De Morgan‟s Law: (X+Y)‟=X‟.Y‟
X Y X‟ Y‟ X+Y (X+Y)‟ X‟.Y‟
0 0 1 1 0 1 1
0 1 1 0 1 0 0
1 0 0 1 1 0 0
1 1 0 0 1 0 0
Values Of columns (X+Y)‟ and X‟.Y‟ are same hence (X+Y)‟=X‟.Y‟
1 Mark for Writing any one of the De Morgan’s Law
1 Mark for showing proofing using Truth Table.
f) State and prove Absorption law algebraically. 2
Answer:
X+XY=X
L.H.S
= X+XY
=X(1+Y) [as 1+Y=1]
=X(1) [as 1.x=x]
=X =R.H.S
OR
XII/CS(283)/FRAGMENT-2-EXAM. PAGE 13 OF 18
X.(X+Y)=X
LHS
X.(X+Y)
=X.(X+Y)
=X.X+X.Y
=X+XY [X.X=X]
=X(1+Y) [1+Y=1]
=X(1) [1.X=X]
=X RHS
1 Mark for writing any one of the Absorption law
1 Mark for its Proofing
5 a) Find the complement of the following Boolean expression:
(a + b)(c' + a')(b + d)
1
Answer:
Answer:
(a‟.b‟)+(c.a‟)+(b‟.d‟)
1 Mark for correct answer
½ Mark for any two correct term in the expression
b) Draw the logic circuit for : A‟B+AB‟ 2
Answer:
1 Mark for correct answer
½ Mark for circuit for A’Bor AB’ only
c) Write the Boolean function/expression for the following logic circuits:
2
XII/CS(283)/FRAGMENT-2-EXAM. PAGE 14 OF 18
Answer:
(A.B+C).D‟
2 Mark for correct answer
½ Mark only for partial correct answer.
d) Reduce the following Boolean expression using K-map:
F(A,B,C,D)=∑(0,1,3,4,5,6,7,8,9,10,12,13)
3
Answer:
AB CD
Octet : m0+m1 m4+m5+m12+m13+ m8+m9 reduces to C’
Quad 1: m1+m3 m5+m7 reduces to A‟D
Quad 2: m4+m5 m6+m7 reduces to A‟B
Pair :m8+m10 reduces to A‟BD‟
Therefore final reduced expression:
F(A,B,C,D)=C‟+A‟D+A‟B+A‟BD‟
½ Mark for placing all 1s at correct positions in K-Map
½ Mark for each grouping
(1 Mark for writing final expression in reduced/minimal form)
Note: Deduct ½ mark if wrong variable names are used
Marks can be given for any other solution following K-Map reduction method
C’D’ C’D CD CD’
00 01 11 10
A’B’
00
1
0
1
1
1
3
2
A’B
01
1
4
1
5
1
7
1
6
AB
11
1
12
1
13
15
14
A’B
10
1
8
1
9
11
1
10
XII/CS(283)/FRAGMENT-2-EXAM. PAGE 15 OF 18
e) F(W, X, Y,Z) = π (0,1, 2, 4, 5, 8, 9, 10,15) 3
WX YZ
Quad 1: M0.M1.M4.M5 reduces to W+Y
Quad 1: M0.M1.M8.M9reduces to X+Y
Quad 1: M0.M2.M8.M10reduces to X+Z
Single :M15: W‟+X‟+Y‟+Z‟
Therefore final reduced expression:
F(W,X,Y,Z)= (W+Y)( X+Y)( X+Z)( W‟+X‟+Y‟+Z‟)
½ Mark for placing all 1s at correct positions in K-Map
½ Mark for each grouping
(1 Mark for writing final expression in reduced/minimal form)
Note: Deduct ½ mark if wrong variable names are used
Marks can be given for Any other solution following K-Map reduction
method
Y+Z Y+Z’ Y’+Z’ Y’+Z
00 01 11 10
W+X
00
0
0
0
1 3
0
2
W+X’
01
0
4
0
5 7
6
W’+X’
11 12 13
0
15
14
W’+X
10
0
8
0
9
11
0
10
6 a) Give one difference between:
i. Cardinality and Degree.
ii. Candidate key and Alternate key.
2
Answer:
i. Cardinality is number of records or tuples in a Table and Degree is
number of fields or columns in a table.
ii. Candidate is(are) the attribute(s) in a table that is(are) eligible to
XII/CS(283)/FRAGMENT-2-EXAM. PAGE 16 OF 18
become primary key in a table whereas alternate key is the candidate
key(s) that did not become the primary key.
1 Marks for each correct part
½ Mark for each part for partially answer
Marks can be given for another answer for similar meaning
b) Consider the following tables Stationery.
Table: Stationery
S_ID StationeryName Company Price
BP01 Ball Pen Reynolds 10
PL02 Pencil Natraj 5
ER05 Eraser Natraj 3
PL01 Pencil Apsara 6
GP02 Gel Pen Reynolds 15
Write SQL statements for (i) to (vi) (6)
(i) To display the Stationery detail in descending order of their company name.
(ii) To display the Name and Price of Stationery whose Price is in the range 10
to 15.
(iii) To display the StationeryName,S_id for Stationery where company is
either "Reynolds" or „Apsara‟.
(iv) To increase the Price of all Stationery by 20 Rupees where Stationery name
contains letter „c‟.
(v) To delete the items for „Reynolds‟ where price is below 10.
(vi) To insert the record: C101,‟file‟,‟faber‟,NULL
Write the output of SQL queries for (vii) to (x) on the basis of original table.(2)
(vii) SELECT * FROM Stationery WHERE Stationery Name Like 'B%'
(viii) SELECT DISTINCT Company FROM Stationery;
(ix) SELECT Company, S_ID as “code” from Stationery where NOT
price<10;
(x) SELECT StationeryName, Price FROM Stationery where price>=10
order by price desc;
8
Answer:
(i) SELECT * from Stationery order by company;
1 Mark for correct answer
½ Mark for answer without order by clause.
(ii) Select stationery Name,price from stationery where price between 10
and 15;
Or
Select stationery Name,price from stationery where price >= 10 and price<=15;
1 Mark for correct answer
XII/CS(283)/FRAGMENT-2-EXAM. PAGE 17 OF 18
½ Mark for answer without order by clause.
(iii) SELECT StationaryName, S_id FROM Stationery WHERE company
IN(„REYNOLDS‟,‟APSARA‟)
Or
SELECT StationaryName, S_id FROM Stationery WHERE company
=„REYNOLDS‟ or company =‟APSARA‟;
1 Mark for correct answer
½ Mark for answer without PROPER CONDITION.
(iv) UPDATE STATIONERY SET PRICE=PRICE+20 WHERE
StationaryName LIKE „%C%‟;
1 Mark for correct answer
½ Mark for answer without proper condition.
(v) DELETE from STATIONERY WHERE PRICE BELOW<10 and
company=‟ Reynolds‟;
1 Mark for correct answer
½ Mark for answer without proper condition.
(vi) INSERT INTO STATIONERY
VALUES(„C101‟,‟file‟,‟faber‟,NULL);
(vii)
S_ID StationaryName Company Price
BP01 Ball Pen Reynolds 10
½ Mark for correct output with or without headings
(viii)
Company
Reynolds
Natraj
Apsara
½ Mark for correct output with or without headings
(ix)
Company code
Reynolds BP01
Reynolds GP02
½ Mark for correct output with headings
(x)
StationeryName Price
Gel Pen 15
Ball Pen 10
½ Mark for correct output with or without headings
XII/CS(283)/FRAGMENT-2-EXAM. PAGE 18 OF 18
7 a) Give two differences between DDL and DML commands. 2
Answer:
DDL( Data definition Language commands) are used to create and modify
structure of database whereas DML (Data manipulation language commands)
are used for reecord maintenance like to insert ,delete,modify and access
records
DDL examples are Create table,altertable and DML examples are Update,select
2 Mark for correct answer
1 mark for partial correct answer
½ mark for each correct difference point.
b) Which of the following SQL Command is used to display the structure of a
table?
(a) DROP TABLE (b) ALTER TABLE
(c ) CREATE TABLE (d) DESC
1
Answer: (d) DESC
1 Mark for correct answer
c) RDBMS stands for _________________.
1
Answer: Relational Database Management
1 Mark for correct answer
d) Which of the following is an example of open source RDBMS?
(a) Oracle (b) Microsoft SQL Server
(c ) My SQL (d) MS-Access
1
Answer: (c) MySQL
1 Mark for correct answer
top related