Sei sulla pagina 1di 49

MODEL SPECIMEN PAPER–3 (Solution)

PART–I
Answer 1.
(a) Commutative Law states the following :
(i) X + Y = Y + X
(ii) X . Y = Y . X
Prove :
X Y X+Y Y+X X.Y Y.X
0 0 0 0 0 0
0 1 1 1 0 0
1 0 1 1 0 0
1 1 1 1 1 1 Hence Proved.
(b) Dual of G6 = (p’+1) . (q+1) . r’
(c) Complement of G5 = (p.q’ + p + p.q)’
= (p.q’)’ . p’ . (p.q)’
= (p’+ q). p’ . (p’+q’)
= (p’ + p’.q) . (p’+q’)
= (p’+q) . (p’+q’)
= p’.p’ + p’.q + p’.q’ + q.q’
= p’ + p’.q + p’.q’
= p’
Hence, it is not a contradiction as the answer does not equals to 0.
(d) Logic circuit :

(e) G3 = (P.Q)’ . R
Answer 2.
(a) The ‘return’ keyword signifies that the function will return the control back to the caller
function and helps in exiting a function prematurely. If the return keyword is suffixed by
any value then the function will return the same value to the caller function along with the
control. For example : return true;
(b) (A + B ) * (C – D) / (E * F + G)
(AB+)*(CD –)/(EF* + G)
(AB+)*(CD –)/(EF*G+)
(AB+CD –*)/(EF*G+)
AB+CD –*EF*G+/
(c) In computer programming, unreachable code is part of the source code of a program
which can never be executed because there exists no control flow path to the code from the
rest of the program.
For example :
int for (int X, int Y)
2 | ISC Model Specimen Papers, XII

{
return X + Y;
int Z = X * Y;
}
In the above example the error “Unreachable code” will be displayed as the statement int
Z=X*Y; is written after the return statement and thus, the control cannot reach the
statement to execute it because the return statement causes the control to exit the function.
(d) Formula for the address in column major order is A = B + W * ((I – I 0 ) + R*( J – J0))
Given : B = 3000; W = 4; I0,J0 = 0,0; I,J = 0,0; R = 30;
Address of DATA[0][0] is already given as 3000.
(e) Big ‘O’ notation is one of the units of measurement of complexity of any algorithm. It is a
theoretical measure of the execution of an algorithm for a given problem of size n, equation
f(n) =O(g(n)) means it is less than some constant multiple of g(n). The notation is read as, "f
of n is big oh of g of n".
Two factors that determine the complexity of an algorithm are :
(i) Time.
(ii) Memory (Space).
Answer 3.
(a) P = ABCD
P = ABC
P = AB
P=A
(b) P = ?+
P=?
(c) No
PART–II
SECTION–A
Answer 4.
(a) G2 (P, Q, R, S) = π (0, 2, 4, 6, 8, 9, 10, 11)

Quad 1 (M0 + M2 + M4 + M6) = P + S


Quad 2 (M8 + M9 + M10 + M11) = P′ + Q
Reduced expression, G2 (P, Q, R, S) = (P + S), (P′ + Q)
Logic Gate Diagram :
Computer Science | 3

(b) (i) Truth Table :


G C S D E Designation Minterm
0 0 0 0 0 0
0 0 0 1 0 1
0 0 1 0 0 2
0 0 1 1 1 3 G’C’SD
0 1 0 0 0 4
0 1 0 1 1 5 G’CS’D
0 1 1 0 0 6
0 1 1 1 1 7 G’CSD
1 0 0 0 0 8
1 0 0 1 0 9
1 0 1 0 0 10
1 0 1 1 0 11
1 1 0 0 1 12 GCS’D’
1 1 0 1 1 13 GCS’D
1 1 1 0 0 14
1 1 1 1 1 15 GCSD
(ii) E(G,C,S,D) = G’.C’.S.D + G’.C.S’.D + G’.C.S.D + G.C.S’.D’ + G.C.S’.D + G.C.S.D
= ∑( 3, 5, 7, 12, 13, 15)
Answer 5.
(a) G1 = ((A . (A.B)’)’.B)’
= (A.(A.B)’)’’ + B’
= A.(A.B)’ + B’
= A.A’ + A.B’ + B’
= B’.(A+1)
= B’
(b) (p.q)’ . q’
= (p’ + q’).q’
= p’.q’ + q’.q’
= p’.q’ + q’
= q’
(c) p.q.1 + p’.1.r’
= p.q.(r+r’) + p’.(q+q’).r’
= p.q.r + p.q.r’ + p’.q.r’ + p’.q’.r’
Answer 6.
(a) A multiplexer or MUX is a combination circuit that selects one of the 2 n input lines and
pass that to a single output line, where n is the number of select lines or address
lines whereas decoder is a combination circuit that produces 2 n output lines for n number
of input lines.
4 | ISC Model Specimen Papers, XII

(b)
B2 B1 B0

Oc0

Oc1

Oc2

Oc3

Oc4

Oc5

Oc6

Oc7

(c)

Truth Table for the 4-input multiplexer


Select Lines Output (X)
A B
0 0 X0
0 1 X1
1 0 X2
1 1 X3

X0

X1
X

X2

X3
Computer Science | 5

SECTION–B
Answer 7.
import java.util.Scanner;
class SHADE
{
int N;
SHADE()
{
N = 0;
}
void fnInput()
{
Scanner sc = new Scanner(System.in);
System.out.println("Enter the value of N");
N = sc.nextInt();
}
int fnCountDigits(int m)
{
int c=0;
while(m > 0)
{
c++;
m/=10;
}
return c;
}
void fnAction()
{
int count = fnCountDigits(N);
int p = (int)Math.pow(10, count-1);
System.out.println(N);
int dupl = N;
while(count > 1)
{
int a = dupl/p;
int b = dupl%p;
dupl = b*10+a;
System.out.println(dupl);
count– –;
}
}
}
Answer 8.
import java.util.Scanner;
class STICH
6 | ISC Model Specimen Papers, XII

{
String sc;
STICH()
{
sc = null;
}
void fnGet()
{
Scanner x = new Scanner(System.in);
System.out.println("Enter a string");
sc = x.nextLine();
}
void fcShow()
{
System.out.println("Original string:"+sc);
int len = x.length();
char ar[] = new char[len];
ar = fnMove();
for(int i = 0; i < len; i++)
System.out.print(ar[i]);
}
char[] fnMove()
{
int len = x.length();
char tp[] = new char[len];
for(int i = 0, j = 0; i < len; i ++)
{
char c = x.charAt(i);
if(!(Character.isLetter(c)) && !(Character.isSpace(c)))
tp[j++] = c;
}
return tp;
}
}
Answer 9.
import java.util.*;
class CLCK
{
int tma[][];
int M;
CLCK( int m1)
{
M = m1;
tma = new int[M][M];
}
Computer Science | 7

public void fnGet()


{
Scanner x = new Scanner(System.in);
System.out.println("Enter the elements for the array");
for(int i = 0; i < M; i++)
{
for (int j = 0; j < M; j++)
tma[i][j] = x.nextInt();
}
}
public void fnShow()
{
System.out.println("ORIGINAL MATRIX");
for(int i = 0; i < M; i++)
{
for(int j = 0; j < M; j++)
System.out.print(tma[i][j]+"\t");
System.out.println();
}
}
public void fnRotate()
{
int a[][] = new int[M][M];
int i, j;
for( i = 0; i < M; i++)
{
for( j = 0; j < M; j++)
a[j][M–1–i] = tma[i][j];
}
for(i = 0; i < M; i++)
{
for(j = 0; j < M; j++)
tma[i][j] = a[i][j];
}
}
public static void main(String args[])
{
Scanner sc = new Scanner(System.in);
System.out.print(“\nEnter the size :”);
int m=Integer.parseInt(sc.readLine());
CLCK ob = new CLCK(m);
ob.fnGet();
ob.fnRotate();
ob.fnShow();
}
}
8 | ISC Model Specimen Papers, XII

SECTION–C
Answer 10.
class MARKS extends STUDENT
{
int avg;
char grade;
MARKS(String s, int a, int b)
{
super(s, a, b);
avg = 0;
}
void Calculate()
{
avg = (m1+m2)/2;
if(avg < 40)
grade = ‘F’;
else if (avg>= 40 && avg < 60)
grade = ‘C’;
else if (avg >= 60 && avg < 80)
grade = ‘B’;
else
grade = ‘A’;
}
void Show()
{
Calculate();
super.Show();
System.out.println(“Average marks:”+avg);
System.out.println(“Grade:”+grade);
}
}
Answer 11.
class REARRANGE
{
int ac[];
int n, p;
int front, rear;
REARRANGE(int size)
{
n = size;
ac = new int[n];
front = rear = p = 0;
}
void fcShow()
{
Computer Science | 9

if(front == rear)
System.out.println("Array is empty");
else
{
for(int i = front; i < rear; i++)
System.out.print(ac[i]+" ");
}
}
void fnInsert(int val, int p)
{
if(rear == n–1)
System.out.println("Array is full");
else if(p > rear)
System.out.println("Invalid position");
else
{
int i;
for(i = rear; i > p; i– –)
ac[i] = ac[i–1];
ac[i] = val;
rear++;
}
}
}
Answer 12.
(a) Method :
int fnAverageEach(NODE begin)
{
int avg = 0, c = 0;
NODE s = begin;
if(s == null)
return 0;
while(s! = null)
{
avg += (s.at + s.bt);
c++;
s = s.next;
}
return (avg/c);
}
Algorithm :
Step 1 : Start.
Step 2 : declare a temporary node, s←begin.
Step 3 : if s = null then return 0.
Step 4 : repeat steps 5 and 6 until s != null.
10 | ISC Model Specimen Papers, XII

Step 5 : add s.at and s.bt to avg.


Step 6 : increment a counter.
Step 7 : increment s to next node.
Step 8 : divide avg by counter.
Step 9 : return avg.
(b) (i) Node P does not exists, if it is R, then In-degree of R = 0 and Out-degree of R = 2
(ii) 4
(iii) R, A, I, N, B, O, W.
●●
MODEL SPECIMEN PAPER–6 (Solution)

PART–I
Answer 1.
(a) Distributive law states the following :
(i) X + X.Y = (X+Y).(X+Z)
(ii) X.(Y+Z) = X.Y + X.Z
(b) F1(A,B,C) = (A’+B+C).(A+B’+C).(A+B+C’).(A’+B’+C’)
(c) p q p⇒q p⇔q
0 0 1 1
0 1 1 0
1 0 0 0
1 1 1 1
Answer 2.
(a) Abstract class is a class declared with abstract keyword and it contains at least one abstract
method.
Abstract method is a method that has only the declaration and not a body.
(b) ( / ( + ( * ( – A B)C)D)E)
( / ( + ( * (A – B) C) D) E)
( / ( + ( (A – B) * C) D) E)
( / ( (A – B) * C + D) E)
( (A – B) * C + D) / E
(c) Similarity : Both stack and queue are concepts of operations of array to store or extract
data.
Difference : Stack works on Last In First Out principal whereas, Queue works on First In
First Out principal.
(d) A = B + W × ( ( I – I0 ) + ( J – J0) × R)
B = 1046
W = 2
I0 , J0 = 0, 0
I,J = 2, 3
R = 7
A = 1046 + 2 × ( (2 – 0) + (3 – 0) × 7)
= 1046 + 2 × 23
= 1046 + 46
= 1092
(e) Since an array traversal requires a loop, hence total time taken, T(n) = C.n
Hence complexity will be O(n).
Answer 3.
(i) fnS (20,5) => 20 > 5 => x = 20 – 5 = 15 => fnS (15, 5)
fnS (15,5) => 15 > 5 => x = 15 – 5 = 10 => fnS (10, 5)
fnS (10,5) => 10 > 5 => x = 10 – 5 = 5 => fnS (5, 5)
fnS (5,5) => 5 = 5 => x = 5 – 5 = 0 => fnS (0, 5)
fnS (0,5) => return 5
2 | ISC Model Specimen Papers, XII

(ii) fnS (15,6) => 15 > 6 => x = 15–6 = 9 => fnS (9, 6)
fnS (9,6) => 9 > 6 => x = 9–6 = 3 => fnS (3, 6)
fnS (3,6) => return 3
(iii) The function is returning the remainder of the division.
PART–II
SECTION–A
Answer 4.
(a) F2 ( P, Q, R, S ) = (0, 1, 4, 5, 6, 7, 8, 9, 10, 11, 14, 15)

. . . .

.
.
.

Quad1 (m0.m1.m4.m5) = P’.R’


Quad2 (m6.m7.m14.m15) = Q.R
Quad3 (m8.m9.m10.m11) = P.Q’
F2 ( P, Q, R, S ) = P’.R’ + Q.R + P.Q’
Logic Gate Diagram :

F2

(b) (i) Truth Table


A B C D H Designation Minterm
0 0 0 0 0
0 0 0 1 1
0 0 1 0 1 2 A’B’CD’
0 0 1 1 1 3 A’B’CD
0 1 0 0 4
0 1 0 1 5
0 1 1 0 1 6 A’BCD’
0 1 1 1 1 7 A’BCD
1 0 0 0 8
1 0 0 1 9
1 0 1 0 10
1 0 1 1 1 11 AB’CD
1 1 0 0 1 12 ABC’D’
1 1 0 1 1 13 ABC’D
1 1 1 0 1 14 ABCD’
1 1 1 1 1 15 ABCD
Computer Science | 3

(ii) H(A,B,C,D) = A’B’CD’ + A’B’CD + A’BCD’ + A’BCD + AB’CD + ABC’D’ + ABC’D


+ ABCD’ + ABCD
= (2, 3, 7, 11, 12, 13, 14, 15)
Answer 5.
(a) F3 = ((A+A)’ + A)’
= (A + A )’’ . A’
= (A + A ) . A’
= A . A’
= 0
Since the output is 0, we can conclude that F3 is a contradiction and not a tautology thus,
the above given statement is False.
(b) p q p^q ~(p^q) ~q ~(p^q)^(~q)
0 0 0 1 1 1
0 1 0 1 0 0
1 0 0 1 1 1
1 1 1 0 0 0
(c) F5 = (p + 0) . (q+1) . (p’+q’)
(d) When S 0 and S1 both are 1 then N3 will be selected for output, and since N3 = 0 then the
result will be 0.
Answer 6.
(a) Both Full Adder and Half Adder add binary digits. Adding any two binary bits always
results in two outputs one as Sum bit and another as Carry bit. Thus, adding two bits or
three bits will result in only two outputs – Sum and Carry. Thus, a full adder has 3 inputs
and a half adder has 2 inputs but both of them have two outputs – Sum and Carry.
(b) SUM = A.B’ + A’.B
CARRY = A.B
A
B′ SUM

A′
B

A CARRY
B
(c) A full adder circuit using half adders :
A
A⊕B
SOUT
A⊕B⊕C

(A ⊕ B).C
C
COUT
(A ⊕ B).C + A.B

A.B
4 | ISC Model Specimen Papers, XII

SECTION–B
Answer 7.
import java.util.Scanner;
class STYLE
{
long W, N;
public STYLE( )
{
W = N = 0;
}
void fnInput( )
{
Scanner sc = new Scaner(System.in);
System.out.println(“Enter a long number”);
W = sc.nextLong( );
}
void fnDisplay( )
{
System.out.println(“Original number:”+W);
System.out.println(“Changed number:”+N);
}
void fnChange( )
{
int t, r, P = 0;
for( t = W; t > 0; t = t/10)
{
int r = t%10;
if(r%2 == 0)
P = P*10+(r+1);
else
P = P*10+(r –1);
}
for(int t = P; t > 0; t = t/10)
{
N = N*10+t%10;
}
}
}
Answer 8.
import java.util.Scanner;
import java.io.*;
class EQUIDB
{
int N;
String B;
Computer Science | 5

public EQUIDB(int i)
{
N = i;
B = “”;
}
void fnShow( )
{
System.out.println(“Decimal Number: ”+N);
System.out.println(“Binary Equivalent: ”+B);
}
void fnInput( )
{
Scanner sc = new Scanner(System.in);
System.out.println(“Enter the decimal number”);
N = sc.nextInt( );
}
void fnConvert( )
{
for(int i = N; i > 0; i = i/2)
{
int r = i %2;
B = Integer.toString(r)+B;
}
}
public static void main(String a[])
{
EQUIDB ob = new EQUIDB(0);
ob.fnInput( );
ob.fnConvert( );
ob.fnShow( );
}
}
Answer 9.
class JULIAN
{
int dd, mm, yy;
int jd;
int endm[ ];
public JULIAN(int i, int j, int k)
{
dd = i;
mm = j;
yy = k;
jd = 0;
endm = new int[12];
6 | ISC Model Specimen Papers, XII

endm = {31,28,31,30,31,30,31,31,30,31,30,31};
}
int fnLeap( )
{
if(yy%400 == 0 | | yy%4 == 0 && yy%100 != 0)
{
endm[1] = 29;
return 1;
}
else
{
endm[1] = 28;
return 0;
}
}
boolean fnIsValid( )
{
int t = fnLeap( );
if(dd <= 0 || mm <= 0 || yy <= 0)
return false;
else if(t == 0 && mm == 2 && dd >= 1 && dd <= 28)
return true;
else if(t == 1 && mm == 2 && dd >= 1 && dd <= 29)
return true;
else if(mm == 1||mm == 3|| mm == 5 || mm == 7|| mm == 8 || mm == 10 || mm == 12
&& dd >= 1 && dd <= 31)
return true;
else if(mm == 4 || mm == 6 || mm == 9 || mm == 11 && dd >= 1 && dd <= 30)
return true;
else
return false;
}
void fnJD( )
{
int t = mm – 1;
for(int i = 0; i < t; i++)
jd += endm[i];
jd += dd;
return;
}
void fnShow( )
{
System.out.println(“Julian day is”+jd);
}
}
Computer Science | 7

SECTION–C
Answer 10.
class SORT extends DATA
{
char choice;
public SORT(int a, char c)
{
super(a);
choice = c;
}
void SortA( )
{
for(int i = 0; i < n–1; i++)
{
for(int j = i+1; j < n; j++)
{
if(sep[i] > sep[j])
{
int t = sep[i];
sep[i] = sep[j];
sep[j] = t;
}
}
}
}
void SortB( )
{
for(int i = 0; i < n–1; i++)
{
for(int j = i+1; j < n; j++)
{
if(sep[i] < sep[j])
{
int t = sep[i];
sep[i] = sep[j];
sep[j] = t;
}
}
}
}
void show( )
{
System.out.println(“Array elements before sorting”);
for(int i = 0; i < n; i++)
{
8 | ISC Model Specimen Papers, XII

System.out.print(sep[i]+” “);
System.out.println( );
}
switch(choice)
{
case ‘a’: SortA();
break;
case ‘d’: SortB();
break;
default: System.out.println(“Invalid choice”);
}
System.out.println(“Array elements after sorting”);
for(int i = 0; i < n; i++)
{
System.out.print(sep[i]+“ “);
System.out.println( );
}
}
}
Answer 11.
class HIFI
{
int a, b;
int f;
public HIFI( int i, int j)
{
a = i;
b = j;
f = 0;
}
void fnShow( )
{
int i = a;
int j = b;
f = fnHCF( );
System.out.println(“HCF of ”+i+ “ and ”+j+ “ is ”+f);
}
int fnHCF( )
{
if(b == 0)
return a;
else
{
a = a%b;
return fnHCF( );
Computer Science | 9

}
}
}
Answer 12.
(a) Method :
void fnDeleteLastNode( NODE start)
{
NODE s, t;
if(start == null)
System.out.println(“Empty list”);
else
{
s = start;
t = s.next;
while(t.next != null)
{
t = s.next;
s = s.next;
}
s.next = null;
t = null;
}
}
Algorithm:
Step 1 : Start.
Step 2 : Declare two objects of NODE, s and t.
Step 3 : If start = null then Print “Empty list”: return.
Step 4 : s.next ← null : t ← null.
Step 5 : repeat steps 6 and 7 until t.next != null.
Step 6 : move t to next node.
Step 7 : move s to next node.
Step 8 : set s.next to null.
Step 9 : return.
(b) (i) 5
(ii) 5
(iii) S, L, A, T, E
●●
MODEL SPECIMEN PAPER–9 (Solution)

PART–I
Answer 1.
(a) DeMorgan’s law states that :
(i) (A+B)’ = A’ . B’
(ii) (A.B)’ = A’ + B’
(i) A B A+B (A+B)’ A’ B’ A’.B’
0 0 0 1 1 1 1
0 1 1 0 1 0 0
1 0 1 0 0 1 0
1 1 1 0 0 0 0 Hence Proved.

(ii) A B A.B (A.B)’ A’ B’ A’+B’


0 0 0 1 1 1 1
0 1 0 1 1 0 1
1 0 0 1 0 1 1
1 1 1 0 0 0 0 Hence Proved.
(b) Dual of F1 = (p+1) . (p’+0) . 1
(c) p q p.q p + p.q
0 0 0 0
0 1 0 0
1 0 0 1
1 1 1 1 Hence Verified.
(d) The XOR and XNOR gates are :

(XOR)

(XNOR)

(e)
X X.Y
Y
Answer 2.
(a) (i) new.
(ii) super.
(b) =(A (B (C (D E *) +) –) /)
=(A (B (C (D*E) +) –) /)
=(A (B (C + D*E) –) /)
=(A (B – C + D*E) /)
=A / (B – C + D*E)
(c) It means the program is trying to access an index position in an array which is out of the
range or is invalid.
(d) A = B + W × ( ( I – I0 ) + ( J – J0) × R)
2 | ISC Model Specimen Papers, XII

B = 1840
W = 4, R = 10
I0 , J0 = 0, 0
I, J = 4, 8
A = 1840 + 4 ((4 – 0) + 10 × (8 – 0))
= 1840 + 4 × 84
= 2176
(e) O(N2)
Answer 3.
(a) n = 99 S = 99
n=9 S = 108
(b) n = 604 S = 604
n = 60 S = 664
n=6 S = 670
PART–II
SECTION–A
Answer 4.
(a) F2( P, Q, R, S ) = π ( 0, 3, 4, 8, 9, 11, 14, 15 )

Pair 1 (M0+M4) = P+R+S


Pair 2 (M3+M11) = Q+R’+S’
Pair 3 (M14+M15) = P’+Q’+R’
Pair 4(M8+M9) = P’+Q+R
F2 (P, Q, R, S) = (P+R+S) . (Q+R’+S’) . (P’+Q’+R’) . (P’+Q+R)
Logic Gate Diagram :
Computer Science | 3

(b) (i) Draw the truth table for the inputs and outputs given above.
N P G H A Designation Minterm
0 0 0 0 0
0 0 0 1 1
0 0 1 0 2
0 0 1 1 1 3 N’P’GH
0 1 0 0 4
0 1 0 1 5
0 1 1 0 6
0 1 1 1 1 7 N’PGH
1 0 0 0 8
1 0 0 1 1 9 NP’G’H
1 0 1 0 10
1 0 1 1 1 11 NP’GH
1 1 0 0 1 12 NPG’H’
1 1 0 1 1 13 NPG’H
1 1 1 0 1 14 NPGH’
1 1 1 1 1 15 NPGH
(ii) A(N,P,G,H) = N’P’GH + N’PGH + NP’G’H + NP’GH + NPG’H’ + NPG’H +
NPGH’ + NPGH
Answer 5.
(a) F = ((p’ + N’)’ + (p + M)’ ) . M’
= (p.N + p’.M’) . M’
= p.M’.N + p’.M’.M’
= p.M’.N + p’.M’
= M’. (p.N + p’)
= M’.(p’+N)
(b) Verify the following using truth table :
(i) P ( ~ P Q ) = P Q
P Q ~P ~P^Q Pv(~P^Q) P Q
0 0 1 0 0 0
0 1 1 1 1 1
1 0 0 0 1 1
1 1 0 0 1 1 Verified.
(ii) ( P →Q ) = ( Q’ → P’ )
P Q P’ Q’ P →Q Q’ → P’
0 0 1 1 1 1
0 1 1 0 1 1
1 0 0 1 0 0
1 1 0 0 1 1 Verified.
4 | ISC Model Specimen Papers, XII

Answer 6.
(a) (i) Tautologies : The propositions that have all 1’s in their truth table output. For
example, P+P’ is a Tautology.
P P’ P + P’
0 1 1
0 1 1
1 0 1
1 0 1
(ii) Contigencies : The propositions that have some combination of 1’s and 0’s in their
truth table output column are called contingencies. For example, P→Q.
P Q P →Q
0 0 1
0 1 1
1 0 0
1 1 1
(iii) Contradiction : The propositions that have all 0’s in their truth table output. For
example, P.P’
P P’ P.P’
0 1 0
0 1 0
1 0 0
1 0 0
(b) Satisfiability is the problem of determining if there exists an interpretation that satisfies a
given Boolean formula. In other words, it asks whether the variables of a given Boolean
formula can be consistently replaced by the values TRUE or FALSE in such a way that the
formula evaluates to TRUE. If this is the case, the formula is called satisfiable. On the other
hand, if no such assignment exists, the function expressed by the formula is FALSE for all
possible variable assignments then the formula is unsatisfiable. For example, the formula
"a AND NOT b" is satisfiable because one can find the values a = TRUE and b = FALSE,
which make (a AND NOT b) = TRUE. In contrast, "a AND NOT a" is unsatisfiable.
a b b' a.b’ a' a.a’
0 0 1 0 1 0
0 1 0 0 1 0
1 0 1 1 0 0
1 1 0 0 0 0
Hence, a.b’ is satisfiable whereas a.a’ is unsatisfiable.
(c)
A B

F1
Computer Science | 5

F1 = ((A.B’)’ . (A’.B)’)’
= A.B’ + A’.B = A⊕B
SECTION–B
Answer 7.
import java.util.Scanner;
class SEQ
{
int m;
SEQ()
{
m = 0;
}
void fnGet( )
{
Scanner sc = new Scanner (System.in);
System.out.println(“Enter a number:”);
m = sc.nextInt();
}
void fnDisplay( )
{
System.out.println(“Result=”+ fnCalculate());
}
long fnCalculate( )
{
long s=0;
for(int i = 1; i <= m; i++)
{
s += fnSumFactors(i);
}
return s;
}
int fnSumFactors(int n)
{
int s = 0, i = 1;
while(i <= n)
{
if(n% i == 0)
s += i;
++i;
}
return s;
}
}
6 | ISC Model Specimen Papers, XII

Answer 8.
import java.util.Scanner;
class POINT
{
int x, y;
POINT(int a, int b)
{
x = a;
y = b;
}
voidfnShow( )
{
System.out.println( x +“,”+ y);
}
POINT fnMidPoint(POINTp1, POINTp2)
{
POINT t = new POINT(0,0);
t.x = (p1.x+p2.x)/2;
t.y = (p1.y+p2.y)/2;
return t;
}
public static void main(String a[])
{
Scanner sc = new Scanner(System.in);
System.out.println(“Enter the 2 coordinates of Point 1”);
int i = sc.nextInt();
int j = sc.nextInt();
POINT p1 = new POINT(i, j);
System.out.println(“Enter the 2 coordinates of Point 2”);
i = sc.nextInt();
j = sc.nextInt();
POINT p2 = new POINT(i, j);
POINT mid = new POINT(0, 0);
mid = p1.fnMidPoint(p1, p2);
mid.fnShow();
}
}
Answer 9.
import java.util.Scanner;
class CABLE
{
String cd;
CABLE( )
{
cd = “”;
Computer Science | 7

}
void fnInput( )
{
Scanner sc = new Scanner(System.in);
System.out.println(“Enter a string”);
cd = sc.nextLine();
}
void fnShow( )
{
System.out.println(“String:”+cd);
System.out.println(“Output:”+fnModify(cd));
}
String fnModify(String w)
{
intlen = cd.length();
String res = “”:
for(int a = 0; a < len; a++)
{
char c = cd.charAt(Ia);
if(fnIsVowel(c))
c = (char)(c+1);
res += c;
}
return res;
}
boolean fnIsVowel(char ch)
{
if(ch == ‘a’||ch == ‘e’||ch == ‘i’|| ch == ‘o’|| ch == ‘u’)
return true;
else
return false;
}
}
SECTION–C
Answer 10.
class COVER extends RECORD
{
int sp;
COVER(String s, String t, int c)
{
super(s,t,c);
sp = 0;
}
double AvailDisc( )
{
8 | ISC Model Specimen Papers, XII

double d = 0;
if(cp <= 500)
d = cp*0.05;
else if(cp > 500 && cp < 1000)
d = cp*0.1;
else
d = cp*0.2;
return d;
}
void Print( )
{
super.Print( );
int d = (int) AvailDisc();
System.out.println(“Discount:”+d);
sp = cp – d;
System.out.println(“Selling price:”+sp);
}
}
Answer 11.
class DISTINCTIVE
{
int List[] = new int[100];
boolean IsD;
int n;
DISTINCTIVE (int k)
{
n = k;
IsD = false;
for(int i = 0; i < 100; i++)
List[i] = 0;
}
boolean fnIsDistin( )
{
IsD = true;
int i;
for(i = 0; i < n; i++)
{
if(List[i] != 0)
break;
}
while(i<n)
{
if(List[i] == 0)
break;
i++;
Computer Science | 9

}
while(i < n)
{
if(List[i] != 0)
{
IsD = false;
break;
}
i++;
}
return IsD;
}
}
Answer 12.
(a) Method :
int fnSmallest( NODE start)
{
int s;
NODE t;
if(start == null)
return –1;
s = start.at;
for(t = start; t != null; t = t.next)
{
if(t.at < s)
s = t.at;
}
return s;
}
Algorithm :
Step 1 : Start.
Step 2 : declare a temporary node, t.
Step 3 : if start = null then return –1.
Step 4 : s←start.at.
Step 5 : t←start.
Step 6 : repeat steps 7 and 8 until t != null.
Step 7 : if t.at < s then s←t.at.
Step 8 : move t to next node.
Step 9 : return s.
(b) (i) P, U
(ii) Depth of P = 3
Depth of V = 1
(iii) P, K, R, U, V, M
●●
MODEL SPECIMEN PAPER–12 (Solution)
PART–I
Answer 1.
(a) Associative law states that :
(i) (X + Y) + Z = X + (Y + Z)
(ii) (X .Y) . Z = X . (Y . Z)

X Y Z X+Y (X+Y)+Z Y+Z X+(Y+Z) X.Y (X.Y).Z Y.Z X.(Y.Z)


0 0 0 0 0 0 0 0 0 0 0

0 0 1 0 1 1 1 0 0 0 0

0 1 0 1 1 1 1 0 0 0 0

0 1 1 1 1 1 1 0 0 1 0
1 0 0 1 1 0 1 0 0 0 0

1 0 1 1 1 1 1 0 0 0 0

1 1 0 1 1 1 1 1 0 0 0

1 1 1 1 1 1 1 1 1 1 1
Hence Proved.
(b) F1’ = (p .q’ .r’ + p’ . q’ .r’ + q . r)’
= (p .q’ .r’)’ . (p’. q’ .r’)’ . (q . r)’
= (p’+q+r) . (p+q+r) . (q’+r’)
(c)
p q p+q p' p'.q p+p’.q
0 0 0 1 0 0
0 1 1 1 1 1
1 0 1 0 0 1
1 1 1 0 0 1 Hence Proved.

(d) F2 = ( p OR q’ ) NOR q
p

q′
F2

(e) The final expression is : F3 = ((P’ + Q).R)’


Answer 2.
(a) Keyword ‘void’ signifies that the function will not return anything.
(b) ((A /(B +C))+(( D + E )*((A / B) * C )))
2 | ISC Model Specimen Papers, XII

((A/(+BC))+((+DE)*((/AB)*C)))
((/A+BC)+((+DE)*(*/ABC)))
(/A+BC)+(*+DE*/ABC)
+/A+BC*+DE*/ABC
(c) Base case in a recursive method is the segment that ends the recursion process and the
control returns to the caller method.
(d) A = B + W × ( ( I – I0 ) + ( J – J0) × R)
B = 1500
W = 1, R = (10 – (–15)+1) = 26
I0 , J0 = – 15, 15
I, J = 5, 20
A = 1500 + 1 ( (5 – (–15) +(20–15) × 26)
= 1500 + (20 + 5 × 26)
= 1500 + 150
= 1650
(e) O(m2 )
Answer 3.
(a) P=9 Q = 14
P = 23 Q = 37
(b) P = 18 Q = 26
P = 44 Q = 70
P = 114 Q = 184
PART–II
SECTION–A
Answer 4.
(a) G4(P, Q, R, S) = π (0, 3, 4, 5, 7, 8, 10, 13, 14)

Pair 1 (M0 + M4) = P+R+S


Pair 2 (M3 + M7) = P + R′ + S′
Pair 3 (M5 + M13) = Q′ + R + S′
Pair 4 (M14 + M10) = P′ + R′ + S
Pair 5 (M9 + M8) = Q+R+S
G4 (P, Q, R, S) = (P + R + S).(P + R′ + S′).(Q′ + R + S′).(P′ + R′ + S).(Q + R + S)
Computer Science | 3

Logic Gate Diagram :

(b) (i) Truth table for the inputs and outputs given above.
C G Y M E Designation Minterm
0 0 0 0 0
0 0 0 1 1
0 0 1 0 2
0 0 1 1 3
0 1 0 0 4
0 1 0 1 1 5 C’GY’M
0 1 1 0 1 6 C’GYM’
0 1 1 1 1 7 C’GYM
1 0 0 0 8
1 0 0 1 9
1 0 1 0 1 10 CG’YM’
1 0 1 1 1 11 CG’YM
1 1 0 0 12
1 1 0 1 1 13 CGY’M
1 1 1 0 1 14 CGYM’
1 1 1 1 1 15 CGYM
(ii) The SOP expression for E (C, G, Y, M) is :
E(C,G,Y,M) = C’GY’M + C’GYM’ + C’GYM + CG’YM’ + CG’YM + CGY’M + CGYM’
+ CGYM
Answer 5.
(a) (i) Output : F4 = 1
(ii) Output : F4 = 1
(iii) Output : F4 = 1
(b) F5 = p' . q' + p + q
= (p + p’.q’) + q
= p + q’ + q (by applying distributive law, (p+p’).(p+q’))
4 | ISC Model Specimen Papers, XII

= p+1 (by applying complements law)


= 1
Hence, it is a tautology.
(c) (i) F6 = p'.q' + p.q
= ∑(0, 3)
= π (1, 2)
= (p+q’) . (p’+q)
(ii) F7 = p'.q + p.q'
= ∑(1, 2)
= π (0, 3)
= (p+q) . (p’+q’)
Answer 6.
(a) A gate is simply an electronic circuit which operates on one or more signals to produce an
output signal. There are three elementary gates at the lowest level, they are – AND gate, OR
gate and NOT gate.
(i) AND gate–It has two or more input lines and only one output line. When all the input
lines are at 1, then only the output shows 1 otherwise 0.
(ii) OR gate–It has two or more input lines and only one output line. If any one of the
input line, or any combination of input line or all of them are at 1, then the output
shows 1 and if all the input lines are at 0 then only the output is 0.
(iii) NOT gate–It has only one input line and one output line. The output line always
shows the opposite of the input line i.e., when input is at 1 then the output is 0 and
when the input is at 0 then the output is 1.
(b) The two derived gates, NAND and NOR are called universal gates because, by using these
gates we can create any of the basic or elementary gates – AND, OR and NOT and thus any
form of logic circuit can be made with the help of these two gates only.
(i) NOT using NAND

—— —
Q = A . A = A. (by Idempotent Law)
(ii) AND using NAND

—–———
—— —— ——
——
Q = A.B . A.B = A.B = A.B (by Involution Rule)
(iii) OR using NAND

——
— — — — — —
Q = A . B = A + B (by DeMorgan’s Law)
Q = A + B (by Involution Rule)
(iv) NOT using NOR

—— —
Q = A . A = A. (by Idempotent Law)
Computer Science | 5

(v) OR using NOR

—–————
—— —— ——
——
Q = A+B + A+B = A+B = A+B
(by Involution Rule)
(vi) AND using NOR

———
— — — —— —
Q = A + B = A . B (by DeMorgan’s Law)
Q = A.B (by Involution Rule)
(c) XOR Gate :

XNOR Gate :

SECTION–B
Answer 7.
import java.util.Scanner;
class CONVERT
{
String bin;
long dec;
CONVERT( )
{
bin = "";
dec = 0;
}
void fnGet( )
{
Scanner sc = new Scanner(System.in);
System.out.println("Enter a binary number");
bin = sc.next( );
}
void fnDisplay( )
{
System.out.println("Binary number"+bin);
System.out.println("Decimal equivalent"+dec);
}
void fnActivate( )
{
6 | ISC Model Specimen Papers, XII

int len = bin.length( );


if(fnIsValid())
{
for(int i = len–1, j = 0; i >= 0; i– –, j++)
{
char c = bin.charAt(i);
int b = ((int) c–48) * (int) Math.pow(2, j);
dec += b;
}
}
}
boolean fnIsValid( )
{
intlen = bin.length();
for(int i = 0; i < len; i++)
{
if(!(bin.charAt(i) == '0' || bin.charAt(i) == '1'))
return false;
}
return true;
}
}
Answer 8.
import java.util.Scanner;
class FRACTION
{
int n, d;
FRACTION(int a, int b)
{
n = a;
d = b;
}
void fnShow( )
{
System.out.println(“Fractional number: ”+n+”/”+d);
}
FRACTION fnReduce( FRACTION f1)
{
FRACTION t = new FRACTION(0, 0);
int h = fnHCF(n,d);
t.n = n/h;
t.d = d/h;
return t;
}
int fnHCF(int a, int b)
Computer Science | 7

{
int h;
int l = (a > b)? a:b;
int s = (a < b)? a:b;
while(l%s != 0)
{
int c = l%s;
if(c == 0)
return s;
l = s;
s = c;
}
return 1;
}
public static void main(String a[])
{
Scanner sc = new Scanner(System.in);
System.out.println(“Enter the value of numerator”);
int x = sc.nextInt();
int y = sc.nextInt();
FRACTION ob = new FRACTION(x, y);
FRACTION cd = new FRACTION(0, 0);
cd = ob.fnReduce( );
cd.fnShow( );
}
}
Answer 9.
class ERA
{
int dd, mm, yy;
int mnt_end[] = {31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
public ERA(int a, int b, int c)
{
dd = a; mm = b; yy = c;
}
public boolean isValid( )
{
if(dd <= 0 || mm <= 0 || yy <= 0)
return false;
else if(mm == 2 && dd >= 1 && dd <= 28)
return true;
else if(mm == 2 && dd >= 1 && dd <= 29)
return true;
else if (mm == 1 || mm == 3 || mm == 5 || mm == 7 || mm == 8 || mm == 0 || mm ==
12 && dd >= 1&& dd <= 31)
8 | ISC Model Specimen Papers, XII

return true;
else if(mm == 4 || mm == 6 || mm == 9 || mm == 11 && dd >= 1 && dd <= 30)
return true;
else
return false;
}
public void fnNextDate()
{
int a = dd+1;
int i = mm–1;
if(i == 1 && a > 28)
{
dd = 1;
mm++;
}
else
{
for(int j = 0; j < 10; j += 2)
{
if(a > 31 && i == j)
{
dd = 1;
mm++;
}
}
for(int j = 3; j < 12; j += 2)
{
if(a > 30 && i == j)
{
dd = 1;
mm++;
}
}
if(i == 11 && a > 31)
{
dd = 1;
mm = 1;
yy++;
}
}
}
}
Computer Science | 9

SECTION–C
Answer 10.
class WAGON extends AUTOMOBILE
{
double Weight;
double duty;
public WAGON(String s, int n, double d)
{
super(s, n);
Weight = d;
duty = 0;
}
public double CalEx( )
{
if(s.equalsIgnoreCase(“North”))
duty = 1.2 * Weight/100;
else if(s.equalsIgnoreCase(“East”))
duty = 1.6 * Weight/100;
else if(s.equalsIgnoreCase(“West”))
duty = 1.4 * Weight/100;
else
duty = 1.3*Weight/100;
}
public void print( )
{
super.print( );
System.out.println(“Capacity of the Wagon:”+Weight);
System.out.println(“Duty charge to be levied:”+duty);
}
}
Answer 11.
class DEQ
{
int D[];
int n;
int rear, front;
DEQ(int size)
{
n = size;
D = new int[n];
front = rear = n/2;
}
public void fnShow( )
{
for(int i = front; i <= rear; i++)
10 | ISC Model Specimen Papers, XII

System.out.print(D[i]+“ ”);
System.out.println();
}
public void fnPush(intval, char ch)
{
if(ch == ‘F’ || ch == ’f’)
{
if(front == 0)
System.out.println(“Overflow at Front”);
else
{
D[front – –] = val;
}
}
else if(ch == ‘R’ || ch == ‘r’)
{
if(rear == n–1)
System.out.println(“Overflow at Rear”);
else
{
D[rear++] = val;
}
}
else
System.out.println(“invalid choice”);
}
}
Answer 12.
(a) Method :
int fnEvenLargest( NODE start)
{
int s;
NODE t;
if(start == null)
return –1;
large = 0;
for( t = start; t != null; t = t.next )
{
if(t.at > large && t.at%2 == 0)
large = t.at;
}
returnlarge;
}
Computer Science | 11

Algorithm :
Step 1 : Start.
Step 2 : declare a temporary node, t.
Step 3 : if start = null then return –1.
Step 4 : large←0.
Step 5 : t←start.
Step 6 : repeat steps 7 and 8 until t !=null.
Step 7 : if t.at > large AND t.at% 2 = 0 then large← t.at.
Step 8 : move t to next node.
Step 9 : return large.
(b) (i) Yes, the given tree is a complete binary tree as all the parent nodes have both the
children.
(ii) S
/ \
I H
(iii) E, N, G, L, I, S, H
●●
MODEL SPECIMEN PAPER–15 (Solution)
PART–I
Answer 1.
(a) Absorption law states that :
(i) A + A.B = A
(ii) A.(A + B) = A
(b) Law of duality states that from a given Boolean expression, we can derive another Boolean
expression by changing all the ANDs to OR and vice-versa and all the 1s to 0 and vice-versa
but the complements must remain the same.
(c) p q p' q' p'+q p.q’ (p.q’)’
0 0 1 1 1 0 1
0 1 1 0 1 0 1
1 0 0 1 0 1 0
1 1 0 0 1 0 1 Hence Verified.
(d) The Logic Circuit for : H1 = ( p AND q' ) OR q

(e) From the Logic Gate Diagram : H2 = ((A+A)’.A)’


Reduced expression :
H2 = ((A+A)’.A)’
= (A+A)’’+A’
= (A+A)+A’
= A+A’
= 1
Answer 2.
(a) An Interface in java is a blueprint of a class. It has static constants and abstract methods
only. A class implements an interface, thereby inheriting the abstract methods of the
interface. Writing an interface is similar to writing a class, but they are two different
concepts. A class describes the attributes and behaviours of an object. An interface contains
behaviours that a class implements.
(b) (( P – Q ) / ( (R * S) – T)) + (R * S)
((PQ –)/((RS*) – T)) + (RS*)
(PQ – RS*T–/) + (RS*)
PQ – RS*T–/RS*+
(c) Stack overflow occurs when there is no empty cell in the stack to store an element i.e., the
stack becomes full.
Stack underflow occurs when there is no more element to be deleted from the stack i.e., the
stack is empty.
2 | ISC Model Specimen Papers, XII

(d) A = B + W × ((I – I0) × C + (J – J0 ))


B = 3000
I0 , J0 = 0, 0
I, J = 3, 2
C = 4
W = 4
A = 3000 + 4 × ((3 – 0) × 4 + (2 – 0))
= 3000 + 4 × (12 + 2)
= 3000 + 56
= 3056
(e) Big O notation is used in computer science to describe the performance or complexity of an
algorithm. Big O notation specifically describes the worst-case scenario and can be used to
describe the execution time required or the space used (e.g., in memory or on disk) by
an algorithm.
O(1) means that, no matter how much data an algorithm contains, it will execute in the
given constant time of 1 minute. O(1) is the smallest complexity of any algorithm.
Answer 3.
(a) SC = e wr et r
(b) SC = t r
(c) Initial condition is to check if the input value is out of the range (array index out of bound)
or not.
PART–II
SECTION–A
Answer 4.
(a) H3 (P, Q, R, S) = ∑(1, 2, 5, 6, 7, 10, 12, 13)

Pair 1 (m1 . m5) = P′ . R′ . S

Pair 2 (m6 . m7) = R′ . Q . R

Pair 3 (m12 . m13) = P . Q . R′

Pair 4 (m2 . m10) = Q′ . R . S′

H3 (P, Q, R, S) = (P′ . R′ . S) + (P′ . Q . R) + (P . Q . R′) + (Q′ . R . S′)


Computer Science | 3

Logic Gate Diagram :

(b) (i) The truth table for the inputs and outputs given above :
H R B S V Designation Minterm
0 0 0 0 0
0 0 0 1 1
0 0 1 0 2
0 0 1 1 1 3 H’R’BS
0 1 0 0 4
0 1 0 1 5
0 1 1 0 6
0 1 1 1 1 7 H’RBS
1 0 0 0 1 8 HR’B’S’
1 0 0 1 1 9 HR’B’S
1 0 1 0 1 10 HR’BS’
1 0 1 1 1 11 HR’BS
1 1 0 0 12
1 1 0 1 13
1 1 1 0 1 14 HRBS’
1 1 1 1 1 15 HRBS
(ii) V(H,R,B,S) = H’R’BS + H’RBS + HR’B’S’ + HR’B’S + HR’BS’ + HR’BS + HRBS’ +
HRBS
Answer 5.
(a) (i) H5 = p . q . r' + p' . q . r' + p . q' . r + p' . q . r
H5 = ∑(6, 2, 5, 3)
H5’ = ∑(0, 1, 4, 7)
H5 = π(0, 1, 4, 7)
H5 = (p+q+r) . (p+q+r’) . (p’+q+r) . (p’+q’+r’)
4 | ISC Model Specimen Papers, XII

(b) p → (q → r) and (p → q) → r
p → (q → r) = p’ + (q’+r) [Since, A→B = A’+B]
p → (q) → r = (p’+q)’ + r
= p.q’ + r
Hence, it is proved both are not equivalent.
(c) (i) Converse of p⇒q is q⇒p.
(ii) Inverse of p⇒q is p’⇒q’
(iii) Contrapositive of p⇒q is q’⇒p’
(iv) In propositional logic, hypothetical syllogism is the name of a valid rule of inference
(often abbreviated HS) and sometimes also called the chain argument or chain rule.
The rule may be stated as if P⇒Q, Q⇒R then it is possible P⇒R.
Answer 6.
(a) NAND and NOR GATES are called universal gates because, by using these gates we can
create any of the basic gates – AND, OR and NOT and thus, any form of logic circuit can be
made with the help of these two gates only.
(b) (i) NOT using NAND

—— —
Q = A . A = A. (by Idempotent Law)
(ii) AND using NAND

—–———
—— —— ——
——
Q = A.B . A.B = A.B = A.B (by Involution Rule)
(iii) OR using NAND

———
—— — — — —
Q = A . B = A + B (by DeMorgan’s Law)
Q = A + B (by Involution Rule)
(c) (i) NOT using NOR

—— —
Q = A . A = A. (by Idempotent Law)
(ii) OR using NOR

—–————
—— —— ——
——
Q = A+B + A+B = A+B = A+B
(by Involution Rule)
(iii) AND using NOR

———
— — — —— —
Q = A + B = A . B (by DeMorgan’s Law)
Q = A.B (by Involution Rule)
Computer Science | 5

(d) A NOR gate is simply an inverted OR gate. Output is high when neither input A nor input
B is high.

SECTION–B
Answer 7.
import java.util.Scanner;
class AMEND
{
int M;
AMEND( )
{
N = 0;
}
void fnAcquire( )
{
Scanner sc = new Scanner(System.in);
System.out.println(“Enter a number”);
N = sc.nextNext( );
}
void fnDisplay( )
{
System.out.println(“Inputed number”+N);
System.out.println(“Digits in words:”+fnConvert( ));
}
String fnConvert( )
{
String res = “ ”;
for(int a = N; a > 0; a = a/10)
{
int r = a%10;
switch(r)
{
case 0 : res = “ZERO ”+res;
break;
case 1 : res = “ONE ”+res;
break;
case 2 : res = “TWO ”+res;
break;
case 3 : res = “THREE ”+res;
break;
6 | ISC Model Specimen Papers, XII

case 4 : res = “FOUR ”+res;


break;
case 5 : res = “FIVE ”+res;
break;
case 6 : res = “SIX ”+res;
break;
case 7 : res = “SEVEN ”+res;
break;
case 8 : res = “EIGHT ”+res;
break;
case 9 : res = “NINE ”+res;
break;
default : res = “”;
}
return res;
}
}
public static void main(String a[])
{
AMEND obj = new AMEND();
obj.fnAcquire();
obj.fnDisaplay();
}
}
Answer 8.
public class FISSION
{
int M[], P[], K[];
int sk, sm, sp;
public FISSION(int a)
{
sk = a;
K = new int[sk];
}
public void fnPrint( )
{
int i;
System.out.println(“Original array elements:”);
for(i = 0; i < sk; i++)
System.out.print(K[i]+“ ”);
System.out.println(“\nSingle digit array elements:”);
for(i = 0; i < sm; i++)
System.out.print(M[i]+“ ”);
System.out.println(“\nMulti digit array elements:”);
Computer Science | 7

for(i = 0; i < sp; i++)


System.out.print(P[i]+“ ”);
}
public int fnCountOneDigit( )
{
int c = 0;
for(int i = 0; i < sk; i++)
{
if(K[i] >= 0 && K[i] <= 9)
c++;
}
return c;
}
public fnSplit( )
{
sm = fnCountOneDigit( );
sp = sk–sm;
M = new int[sm];
P = new int[sp];
for(int i = 0, j = 0, t = 0; i < sk; i++)
{
if(K[i] >= 0 && K[i] <= 9)
M[j++] = K[i];
else
P[t++] = K[i];
}
}
}
Answer 9.
import java.util.Scanner;
public class YARN
{
String ys;
public YARN( )
{
ys = “ ”;
}
public void fnInput( )
{
Scanner sc = new Scanner(System.in);
ys = sc.nextLine();
}
public String fnMake( )
{
int len = ys.length();
8 | ISC Model Specimen Papers, XII

String res = “ ”;
ys = ys.toUpperCase();
for(int i = 0; i < len; i++)
{
char c = ys.charAt(i);
if(c >= ‘A’ && c <= ‘Z’)
{
if(c == ‘A’ || c == ‘E’ || c == ‘I’ || c == ‘O’ || c == ‘U’)
c++;
else
c– –;
}
res += c+“ ”;
}
return res;
}
public void fnShow( )
{
System.out.println(“Original String:”+ys);
System.out.println(“Modified String:”+fnMake( ));
}
}
SECTION–C
Answer 10.
class DETAILS extends FACTS
{
int sv;
DETAILS(int a, int b)
{
super(a);
sy = b;
}
boolean BinSearch( )
{
int lb = 0, ub = n–1;
while(lb <= ub)
{
int mid = (lb+ub)/2;
if(nov[mid] == sy)
return true;
else if(nov[mid] < sy)
lb = mid–1;
else
ub = mid+1;
Computer Science | 9

}
return false;
}
void Show( )
{
boolean b;
super.Show();
b = BinSearch( );
if(b == true)
System.out.println(“Member data is present in the array”);
else
System.out.println(“Member data is not present in the array”);
}
}
Answer 11.
class REVES
{
String s, rs;
public REVES(String a)
{
s = a;
}
public void fnShow( )
{
int len = s.length();
fnRecRev(len–1);
System.out.println(“Original string:”+s);
System.out.println(“Reversed string:”+rs);
if(s.equalIgnoreCase(rs))
System.out.println(“Palindrome”);
else
System.out.println(“Non palindrome”);
}
public void fnRecRev(int p)
{
if(p >= 0)
{
rs += s.charAt(p);
fnRecRev(p-1);
}
}
}
10 | ISC Model Specimen Papers, XII

Answer 12.
(a) Method :
boolean fnIsAllEven(NODE start)
{
NODE t = start;
if(start == null)
return false;
while(t.next != null)
{
if(t.at%2 != 0)
return false;
t = t.next;
}
return true;
}
Algorithm:
Step 1 : Declare a temporary node, t←start.
Step 2 : If start = null then return false.
Step 3 : While t != null repeat step 4 and 5.
Step 4 : If t.at%2 != 0 then return false.
Step 5 : Move t to next node.
Step 6 : Return true.
(b) (i) U→P→S→M
(ii) No, the given tree is not a complete binary tree. It is because, a tree will be a complete
binary tree only when all its parent nodes must have two sub nodes and all the leaf
nodes should be at the same level.
(iii) Q, U, P, T, S, M, N, V
●●

Potrebbero piacerti anche