Computer Science
Computer Science
A. STATISTICS AT A GLANCE
Mark Range
0-20 21-40 41-60 61-80 81-100
Number of candidates 10 87 1383 5065 11473
Percentage of candidates 0.06 0.48 7.68 28.11 63.68
Cumulative Number 10 97 1480 6545 18018
Cumulative Percentage 0.06 0.54 8.21 36.32 100
140
B. ANALYSIS OF PERFORMANCE
PART I
Answer all questions.
While answering questions in this Part, indicate briefly your working and reasoning,
wherever required.
Question 1
(a) From the logic circuit diagram given below, find the output F and simplify it. [2]
Also, state the law represented by the logic diagram.
Q
P F
(b) Write the truth table for a 2-input conjunction and disjunction in a proposition. [2]
(c) Find the complement of XYZ + XY + YZ [2]
(d) Convert the following expression into its canonical POS form : [2]
F(A,B) = (A + B) . A
(e) Minimise the following Boolean expression using the Karnaugh map: [2]
F(A,B,C) = A BC ABC + ABC ABC
Comments of Examiners
(a) This part was well answered by most of the Suggestions for teachers
candidates. Some candidates did not mention the law, Practice should be given to
but wrote the expression correctly. Some wrote only candidates in deriving an
the intermediate expression. expression from a logic circuit and
(b) Some candidates were confused with the terms also recognizing the law used. Step
conjunction and disjunction and interchanged their by step solving of a circuit should
truth tables. be practiced.
Proposition logic should be taught
(c) Most of the candidates answered this part correctly. A
few simplified the expression, without finding the using all the terms that
complement. Some only reduced the expression. are required, especially the
(d) Some candidates were not clear with the POS form of terms conjunction, disjunction,
expression and wrote the SOP expression. Actual negation, implications and
meaning and features of canonical expression were bi conditional.
More practice should be given to
not clear to many candidates.
(e) Almost all candidates answered this part correctly students to complement a
except for a few who did not use the k-map for Boolean expression using
reducing but used the laws instead. K-Map plotting de Morgans law. Each and every
was not correct in some cases. law must be practiced with
examples. All related terms and
symbols used for each gate should
be explained.
141
More practice should be given in
solving SOP and POS type of
Boolean expressions. Both
canonical and cardinal forms
should be practiced.
More practice should be given in
minimizing Boolean expressions
using k-maps. 3 variable k-maps
should also be practiced for short
answers.
MARKING SCHEME
Question 1.
(a) (P+Q) (P+R) = P+Q.R Distributive Law
(b) A B Conjunction A B Disjunction
0 0 0 0 0 0
0 1 0 0 1 1
1 0 0 1 0 1
1 1 1 1 1 1
0 1 3 2
A 0 0 1 1
4 5 7 6
A 0 0 1 1
Quad ( m2 + m3 + m6 + m7 ) = B
142
Question 2
(a) State two advantages of using the concept of inheritance in Java. [2]
(b) An array AR [ 4 . 6, 2.12 ] , stores elements in Row Major Wise, with [2]
the address AR[2][3] as 4142. If each element requires 2 bytes of storage, find the
Base address.
(c) State the sequence of traversing a binary tree in: [2]
(i) preorder
(ii) postorder
(d) Convert the following infix expression into its postfix form: [2]
(A/B+C)*(D/ (E-F))
(e) State the difference between the functions int nextInt( ) and boolean hasNextInt( ). [2]
Comments of Examiners
(a) A number of candidates were not aware of the Suggestions for teachers
advantages of inheritance. Some used examples while OOPs concepts must be
others explained in their own words. A few candidates explained with advantages and
wrote the definition instead of the advantages. examples. Real world examples
(b) Candidates who had the knowledge of the formula to may be used to explain these
find the address of a cell in an array could solve and get terms.
the correct answer. Others gave vague answers. Some Practice should be given in
calculated using memory cell diagram. understanding the formula using
(c) In parts (i) and (ii), some candidates explained with the row major and column major
help of a diagram. A few used the term vertex or an and making the subject of
operator to represent root. formula that is required in the
(d) Some candidates wrote the correct answer without question.
showing the working. Others applied the postfix Students should be given more
correctly, but could not derive the final answer. practice in binary trees and
(e) Several candidates wrote the functions with syntax while various terms used.
others wrote in their own language. Examples need to be practiced
with conversion of Infix to
Postfix notation, the order of
precedence; the Polish stack
method should be explained
clearly.
143
MARKING SCHEME
Question 2.
(a) (i) Reusability (ii) Transitive nature.
(b) Address of AR[i,j] = B + W [ Nc ( i - Lr ) + ( j - Lc ) ]
Address of AR[i,j] = 4142
B=?
W=2
Nc = Uc - Lc + 1 = 12 ( -2) +1 = 15
i=2 j=3
Lr = -4 Lc = -2
4142 = B + 2 [ 15 ( 2 (-4) ) + ( 3 (-2)) ]
4142 = B + 2 [ 90 + 5 ]
B = 4142 190 = 3952
(c) (i) root left right (+LR) (ii) left right root ( LR+)
(d) ( A / B+C ) * ( D / ( E-F )
= (AB/ +C ) * ( D / (EF-) )
= (AB/C+) * ( DEF-/)
= AB/C+ DEF-/ *
(e) nextInt( ) Returns next token as an integer
hasNextInt ( ) Returns true if the input has another token and that token can be interpreted as an
integer.
Question 3
(a) The following functions are part of some class:
void fun1(char s[ ],int x)
{ System.out.println(s);
char temp;
if(x<s.length/2)
{ temp=s[x];
s[x]=s[s.length-x-1];
s[s.length-x-1]=temp;
fun1(s,x+1);
}
}
144
void fun2(String n)
{ char c[ ]=new char[n.length( )];
for(int i=0;i<c.length; i++)
c[i]=n.charAt(i);
fun1(c,0);
}
(i) What will be the output of fun1( ) when the value of s[ ]={J,U,N,E} [2]
and x=1?
(ii) What will be the output of fun2( ) when the value of n =SCROLL ? [2]
(iii) State in one line what does the function fun1( ) do apart from recursion. [1]
(b) The following is a function of some class which sorts an integer array a[ ] in
ascending order using selection sort technique. There are some places in the code
marked by ?1?, ?2?, ?3?, ?4?, ?5? which may be replaced by a
statement/expression so that the function works properly:
for(int k=0;k<a.length;k++)
System.out.println(a[k]);
}
145
(i) What is the expression or statement at ?1? [1]
MARKING SCHEME
Question 3.
(a) (i) JUNE (ii) SCROLL (iii) It reverses the character array
JNUE LCROLS Swaps, Interchanges etc.
LLROCS
LLORCS
146
(b) (i) a.length OR a.length-1
(ii) i+1 Or i OR minpos + 1 OR minpos
(iii) minpos
(iv) a[j]
(v) t
PART II
Answer seven questions in this part, choosing three questions from
Section A, two from Section B and two from Section C.
SECTION - A
Answer any three questions.
Question 4
(a) Given the Boolean function F(A, B, C, D) = (0, 1, 2, 3, 5, 6, 7, 10, 13, 14, 15)
(i) Reduce the above expression by using 4-variable Karnaugh map, showing [4]
the various groups (i.e. octal, quads and pairs).
(ii) Draw the logic gate diagram for the reduced expression. Assume that the [1]
variables and their complements are available as inputs.
(b) Given the Boolean function P(A, B, C, D) = (0, 1, 2, 3, 5, 6, 7, 10, 13, 14, 15 )
(i) Reduce the above expression by using 4-variable Karnaugh map, showing [4]
the various groups (i.e. octal, quads and pairs).
(ii) Draw the logic gate diagram for the reduced expression. Assume that the [1]
variables and their complements are available as inputs.
Comments of Examiners
(a) (i) Several candidates made errors in place value and Suggestions for teachers
putting variables in K-Map. In some cases, the Emphasize on arranging the
groups were reduced by laws. A number of variables in proper order and the
candidates drew the K-Map incorrectly. Many importance of cell values
candidates included the redundant group in the final corresponding with the variables.
expression. Explain clearly how the groups
(ii) Some candidates drew the logic circuit using are framed and reduced.
universal gates while some others drew vague Redundant groups are not to be
diagrams. included in the final reduced
(b) (i) A number of candidates were not able to draw the expression.
K-Map for the POS expression correctly. For many More practice should be given in
candidates the Map rolling concept was not very drawing logic circuits using basic
clear. Some converted the canonical form to cardinal gates and also with universal
form and then reduced it. gates.
147
(ii) Some candidates drew the logic circuit using Make students reduce POS and
universal gates while some others drew vague SOP expressions using K-Map
diagrams. simultaneously. Students should
be told not to include the
redundant group in the final
expression.
MARKING SCHEME
Question 4.
(a) (i) F(A,B,C,D) = (0 , 1 , 2 , 3 , 5 , 6 , 7 , 10 , 13 , 14 , 15 )
CD CD CD CD
0 1 3 2
AB 1 1 1 1
4 5 7 6
AB 0 1 1 1
12 13 15 14
AB 0 1 1 1
8 9 11 10
AB 0 0 0 1
148
(b) (i) P(A,B,C,D) = (0 , 1 , 2 , 3 , 5 , 6 , 7 , 10 , 13 , 14 , 15 )
4 5 7 6
A+B 1 0 0 0
12 13 15 14
A+B 1 0 0 0
8 9 11 10
A+B 1 1 1 0
Question 5
A school intends to select candidates for the Inter-School Athletic Meet, as per the criteria
given below:
The candidate is from the Senior School and has participated in an Inter-School
Athletic Meet earlier.
OR
The candidate is not from the Senior School, but the height is between 5 ft. and 6 ft.
and weight is between 50 kg. and 60 kg.
OR
The candidate is from the senior school and has height between 5 ft. and 6 ft., but the
weight is not between 50 kg. and 60 kg.
149
The inputs are:
INPUTS
S Student is from the Senior School
W Weight is between 50 kg. and 60 kg.
H Height is between 5 ft. and 6 ft.
A Taken part in Inter-School Athletic Meet earlier
150
MARKING SCHEME
Question 5.
(a) X
S W H A
(OUTPUT)
0 0 0 0 0
0 0 0 1 0
0 0 1 0 0
0 0 1 1 0
0 1 0 0 0
0 1 0 1 0
0 1 1 0 1
0 1 1 1 1
1 0 0 0 0
1 0 0 1 1
1 0 1 0 1
1 0 1 1 1
1 1 0 0 0
1 1 0 1 1
1 1 1 0 0
1 1 1 1 1
HA HA HA HA
0 1 3 2
SW 0 0 0 0
4 5 7 6
SW 0 0 1 1
12 13 15 14
SW 0 1 1 0
8 9 11 10
SW 0 1 1 1
151
Question 6
(a) With the help of a logic diagram and a truth table explain a Decimal to Binary [4]
encoder.
(b) Derive a Boolean expression for the logic diagram given below and simplify it. [3] Name
A A
B
B B
output
C
A C
B
152
MARKING SCHEME
Question 6.
(a)
153
Question 7
(a) Differentiate between XNOR and XOR gates. Draw the truth table and logic [4]
diagrams of 3 input XNOR gate.
(c) Define Half Adder. Construct the truth table and a logic diagram of a Half Adder. [4]
Comments of Examiners
(a) Some candidates were confused between XNOR and Suggestions for teachers
XOR gates and interchanged the answers. Some were More practice should be given
confused with the 3 input XNOR truth table. for understanding the various
(b) A number of candidates gave the full form of wff. Some gates (AND, OR, NOT, XOR,
candidates wrote the same definition for both. XNOR, NAND and NOR).
(c) Several candidates drew the block diagram instead of Students should be told that in
the logic circuit diagram. In some cases, the definition odd number of inputs, XOR and
was not clear and vague answers were given. XNOR outputs are same and in
even number of inputs XOR is
the complement of XNOR.
More practice should be given in
the chapter on Propositional logic
and the various terms used must
be explained with examples.
Application of logic gates should
be explained along with
definition, truth table, logic
diagram and expressions.
MARKING SCHEME
Question 7.
(a) XNOR XOR
1. Logically equivalent to an 1. Logically equivalent to an
inverted XOR, i.e., XOR gate exclusive OR. i.e. if both inputs
followed by a NOT gate are 1 then output is 0 (reverse of
inclusive OR)
2. Produces 1 (high) as output when 2. Produces 1 (high) as output when
the input combination has even the inputs combination has odd
number of 0s number of 1s.
154
Logic Diagram of a 3 input XNOR gate :
Expression : X = A B C
(b) Proposition: A statement that can have only two possible answer (True or false)
wff: It is a proposition which is satisfiable or valid.
(c) Half adders are combinational circuits which adds two input binary bits and output two binary
bits.
Truth table of half adder :
155
SECTION B
Question 9
(a) Specify the class SeriesSum, giving details of the constructor(int, int), [8]
double findfact(int), double findpower(int, int), void calculate( ) and
void display( ). Define the main( ) function to create an object and call the
functions accordingly to enable the task.
(b) State the two differences between iteration and recursion. [2]
158
Comments of Examiners
(a) A number of candidates answered this part correctly. Suggestions for teachers
Common errors made were: the concept of recursion More practice should be given in
was not clear to some candidates; some used the inbuilt solving programs using recursive
mathematical functions; some wrote the function techniques. Knowledge of base
findfact() and findpower() without using the recursive case and recursive case should be
technique. Several candidates did not invoke the given to the students for every
functions findfact() and findpower() to calculate the sum program using recursive
of the series. In some cases, return statement was technique. Practice should be
missing. The other function including the constructor given in invoking function within
was well answered. Some candidates did not write the another function.
main() function. More examples must be given to
(b) In some cases, only one difference was given by explain the difference between
candidates. iteration and recursion using
memory blocks and time factor.
MARKING SCHEME
Question 9.
(a) class SeriesSum
{
int x,n;
double sum;
SeriesSum(int xx,int nn)
{ x=xx;
n=nn;
sum=0.0;
}
double findfact(int a)
{ return (a<2)? 1:a*findfact(a-1);
}
double findpower(int a, int b)
{ return (b==0)? 1:a*findpower(a,b-1);
}
void calculate()
{ for(int i=2;i<=n;i+=2)
sum += findpower(x,i)/findfact(i-1);
}
void display()
{ System.out.println("sum="+ sum);
}
static void main()
{ SeriesSum obj = new SeriesSum(3,8);
obj.calculate();
obj.display();
159
}
}
(b) Iteration: Fast process and less memory.
Recursion: Slow process and more memory.
Question 10
S0= a, S1= b, Sn = S(n-1) + S(n -2) where + denotes concatenation. Thus the sequence is:
a, b, ba, bab, babba, babbabab, n terms.
Design a class FiboString to generate fibonacci strings. Some of the members of the class
are given below:
160
Comments of Examiners
Different methods / logic were used to concatenate the Suggestion for teachers
words and swap them. The loop was not proper in some of Different methods /logic should
the cases along with its swapping. Interchanging and be adopted so that wider
concatenating was not done properly in many cases. exposure to string manipulation
Several candidates did the entire program without answering related programs is given to
the generate() function. The main() function and constructor students.
were not answered by some candidates. Knowledge of constructors to
initialize a string and other data
members should be given.
MARKING SCHEME
Question 10.
import java.util.*;
class FiboString
{ String x,y,z;
int n;
FiboString( )
{
x="a";
y="b";
z="ba";
}
void accept ()
{
Scanner Sc = new Scanner (System.in);
System.out.println ("Enter number of terms") ;
n = Sc.nextInt( );
}
void generate()
{ System.out.print(x+","+y);
for(int i=0;i<=n-2;i++)
{ System.out.print(","+z);
x=y;
y=z;
z=y+x; OR z= y.concat(x);
}
}
static void main( )
{ FiboString obj=new FiboString( );
obj.accept( );
obj.generate();
}
}
161
SECTION C
Answer any two questions.
Each program should be written in such a way that it clearly depicts the logic of the problem stepwise.
This can be achieved by using comments in the program and mnemonic names or pseudo codes for
algorithms. The programs must be written in Java and the algorithms must be written in general /
standard form, wherever required / specified.
(Flowcharts are not required.)
Question 11
A super class Stock has been defined to store the details of the stock of a retail store. Define [10]
a subclass Purchase to store the details of the items purchased with the new rate and updates
the stock. Some of the members of the classes are given below:
Class name : Stock
Data members/instance variables:
item : to store the name of the item
qty : to store the quantity of an item in stock
rate : to store the unit price of an item
amt : to store the net value of the item in stock
Member functions:
Stock () : parameterized constructor to assign values to the
data members
void display( ) : to display the stock details
Class name : Purchase
Data members/instance variables:
pqty : to store the purchased quantity
prate : to store the unit price of the purchased item
Member functions / methods
Purchase() : parameterized constructor to assign values to the
data members of both classes
void update ( ) : to update stock by adding the previous quantity by
the purchased quantity and replace the rate of the
item if there is a difference in the purchase rate.
Also update the current stock value as:
(quantity * unit price)
void display( ) to display the stock details before and after
updation
Specify the class Stock, giving details of the constructor() and void display( ). Using
concept of inheritance, specify the class Purchase, giving details of the constructor(),
void update( ) and void display( ).
The main function and algorithm need not be written.
162
Comments of Examiners
The concept of Inheritance was not clear to a number of Suggestions for teachers
candidates. In several cases, the amount was not calculated, Instruct students to read the
but passed as parameter/argument. Constructor with question properly and answer
inheritance was not answered correctly by some candidates. accordingly.
Accessing the members of the super class by the derived Use of constructor using the base
class was not clear to many candidates. Keywords extends class member should be made
and Super were found to be missing in some cases. clear.
A number of candidates declared the base class data The different visibility modes
members as private. Double data members were not and their accessing capability
declared properly by some students. Invoking the update () should be explained. Calling the
function in the display() function of the derived class was member function from the super
not answered properly. In a few cases, the algorithm was class to the derived class must be
written instead of a program. explained clearly.
More practicals based on
inheritance, involving functions
from super class must be done.
MARKING SCHEME
Question 11.
class Stock
{ String item;
double qty,rate,amt;
Stock(String a,double b,double c)
{ item=a;
qty=b;
rate=c;
amt=qty * rate;
}
void display()
{ System.out.println("Name of the item : "+item);
System.out.println("Quantity: "+qty);
System.out.println("Rate per unit: "+rate);
System.out.println("Net value: "+amt);
}
}
class Purchase extends Stock
{
int pqty;
double prate;
Purchase(String a, double b, double c, int d, double e)
{ super(a,b,c);
pqty=d;
prate=e;
163
}
void update()
{ qty += pqty;
if(prate!=rate)
rate=prate;
amt = qty * rate;
}
void display()
{ super.display();
update();
super.display();
}
}
Question 12
A stack is a linear data structure which enables the user to add and remove integers from [10]
one end only, using the concept of LIFO(Last In First Out). An array containing the marks
of 50 students in ascending order is to be pushed into the stack.
164
Specify the class Array_to_Stack, giving the details of the constructor(int),
void input_marks( ), void pushmarks(int), int popmarks( ) and void display( ).
The main function and the algorithm need not be written.
Comments of Examiners
The concept of stack was not clear to most of the Suggestions for teachers
candidates. Common errors made by candidates were: More practice should be given in
(i) incorrect declaration of array; (ii) the condition / logic for data structure programs like the
underflow and overflow was not answered correctly; stacks, queues, dequeues, etc.
(iii) increment / decrement of top index was not done Working as to how the stack or a
properly; Top was initialized to 0 instead of -1 in some queue performs must be shown.
cases; The pushing of marks from array to stack was The concept of LIFO and FIFO
confusing to many candidates; Some sorted the array and must be explained to students
then pushed the values into the stack whereas in other cases with live examples. The concept
it was directly done; The methods pushmarks() and of underflow and overflow
popmarks() were found to be difficult by some candidates. must be taught. The importance
The class declaration and constructors were well answered. of top subscript must be
explained. Implementation of
stacks, queues and dequeue using
arrays should be emphasized.
Only the concept has to be
explained taking the base as an
array. It should be made clear to
students that it is not an array
related program which can be
manipulated by shifting /
inserting or initializing by any
value since these data structures
require pointers and pointers are
not supported in java. So, the
array is used to show the working
of a stack, queue or a dequeue.
MARKING SCHEME
Question 12.
import java.util.*;
class Array_to_Stack
{ int m[], st[];
int cap, top;
static Scanner sc=new Scanner(System.in);
Array_to_Stack(int n)
{ cap = n;
top = -1;
m=new int[cap];
165
st=new int[cap];
}
void input_marks( )
{ System.out.println("Enter "+cap+" elements in ascending order");
for(int i=0;i<cap;i++)
{ m[i]=sc.nextInt();
pushmarks(m[i]);
}
}
void pushmarks(int v)
{ if (top<cap-1)
st[++top]=v;
else
System.out.println("stack is full");
}
int popmarks()
{ if(top>=0)
returnst[top--];
else
return -999;
}
void display()
{ for(int i=top;i>=0;i--)
System.out.println(st[i]);
}
}
Question 13
:
(a) A linked list is formed from the objects of the class: [4]
class Node
{
int number;
Node nextNode;
}
Write an Algorithm OR a Method to add a node at the end of an existing linked list.
The method declaration is as follows:
void addnode ( Node start, int num )
166
(c) Answer the following from the diagram of the Binary Tree given below:
B
J
C F
K
D G L
E H
GENERAL COMMENTS:
(a) Topics found difficult by candidates in the Question Paper:
Truth table of conjunction and disjunction in a proposition.
Advantages of using the concept of inheritance.
Difference between int nextInt() and boolean hasNextInt() functions
Output of a character array without mentioning subscript.
K-MAPS (Labeling , Grouping , map-rolling , place value)
Passing objects to functions.
168
Recursive technique and invoking function within another function (Nesting of functions).
Pushing marks from array to stack.
Size of a binary tree
(b) Concepts in which candidates got confused:
Conjunction and disjunction in a proposition.
Difference between nextInt() and hasNextInt() functions.
Representing a single gate after reducing a logic circuit diagram.
Truth table of a 3 input XNOR gate.
Passing of objects in the mix() function.
Invoking function within function.
Concatenation of strings.
(c) Suggestions for students:
Apart from Text book learning, look up other reliable resources to gather comprehensive
knowledge of the subject.
Prepare summary for each chapter or use highlighters to recognize important terms and
definitions. Knowledge of the prescribed syllabus and its scope is very important.
Answers and definitions should be short and precise and according to marks allotted. Important
words and terms should be underlined or highlighted.
Working should be shown at the side of each question wherever required.
Laws must be mentioned while reducing a Boolean Expression.
Practice one form of K-Map with proper place value for both SOP and POS.
In programming, documentation is compulsory and should be mentioned with each program.
Declare the class with data members and member functions. Expand or define each function
according to the instructions given by the side of each function.
Do not memorize the program, try to understand the logic.
Practice constructors with every program.
Treat each function of a class as separate program.
169