ISC Computer Science Previous Year Question Paper 2010 Solved for Class 12
Maximum Marks: 70
Time allowed: 3 hours
Part – I
Answer all questions
While answering questions in this Part, indicate briefly your working and reasoning, wherever required.
Question 1.
(a) If X = A’BC + AB’C + ABC + A’BC’ then find the value of X when A = 1; B = 0; C = 1 [2]
(b) Verify if, P. (~ P + Q’) = (P = > Q) using truth table. [2]
(c) Draw the logic circuit of NOR and NAND gate only. [2]
(d) Convert the following function into its Canonical sum of products form: [2]
F(X, Y, Z) = Σ(0, 1, 5, 7).
(e) Show that dual of P’QR’ + PQ’R + P’Q’R is equal to the complement of: [2]
PQ’R + Q. (P’R’+PR’)
Answer:
Question 2.
(a) State the difference between an Interface and a Class. [2]
(b) Convert the following infix notation to postfix notation: [2]
(A + B) / C * (D + E)
(c) A character array B[7] [6] has a base address 1046 at 0, 0. Calculate the address at B[2] [3] if the array is stored Column Major wise. Each character requires tw o bytes of storage. [2]
(d) State the use of exceptional handling. Name the two types of exceptions. [2]
(e) (i) What is the worst-case complexity of the follow ing code segment: [2]
for (int i = 0; i < N; i++) { sequence of statements } for (int j=0 ; j < M; j++) { sequence of statements }
(ii) How would the complexity change if the second loop went to N instead of M?
Answer:
(a) (i) Class can be extends in another class.
(ii) Interface is implemented in another class.
(b) (A + B) / (C * (D + E))
= (AB +) / (C * (DE +))
= (AB +) / (CDE + *)
= AB + CDE + */
(c) B + W [(I – LBR) + M (J – LBC)]
= 1046 + 2 [(2 – 0) + 7(3 – 0)]
= 1046 + 2(2 + 21)
= 1046 + 2(23)
= 1046 + 46
= 1092
(d) Exception: It refers to some contradictory or unusal situation which can be encountered while executing a program.
(i) IO Exception
(ii) Array out of Bound Exception
(e) (i) for (i = 0; i < N ; i + +) This loop gets executed N times thus take time C1 * N
for (i = 0; j < M ; j ++) This loop gets executed M times thus take time C2 * M
Total Time = C1 * N + C2 * M = 0 (N + M)
(ii) It becomes = O(2N)
Question 3.
(a) The following functions numbers (int) and numbers1 (int) are a part of some class. Answer the questions given below showing the dry run/working:
public void numbers (int n) { if (n > 0) { System.out. print(n + " " ); numbers (n-2); System.out.print(n + " "); } } public String numbers1 (int n) { if (n < = 0) return " "; return numbersl(n-1) + n + " "; }
(i) What will be the output of the function numbers (int n) when n = 5? [2]
(ii) What will the function numbersl (int n) return when n = 6? [2]
(iii) State in one line what is the function numbersl (int) doing apart from recursion? [1]
(b) The following function is a part of some class. It sorts the array a[ ] in ascending order using insertion sort technique. There are some places in the code marked by ?1?, ?2?, ?3?, ?4?, ?5? which must be replaced by expression / statement so that the function works correctly.
void insertsort (int a [ ]) { int m = ?1?; int b, i, t; for (i = ?2? ; i < m; i++) { t = a[i]; b = i - I; while (?3? > = 0 && t < a [ b ]) { a[b+1] = a[b]; ?4?; } ?5? = t; } }
(i) What is the expression or statement at ?1? [1]
(ii) What is the expression or statement at ?2? [1]
(iii) What is the expression or statement at ?3? [1]
(iv) What is the expression or statement at ?4? [1]
(v) What is the expression or statement at ?5? [1]
Answer:
(a) (i) 5 3 1 1 3 5
(ii) “1 2 3 4 5 6”
(iii) It display all number from 1 to that number.
(b) (i) a length
(ii) 1
(iii) b
(iv) b = b – 1;
(v) a[b+1]
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 F(P,Q,R,S) = Σ (0, 2, 5, 7, 8, 10, 11, 13, 14, 15)
(i) Reduce the above expression by using 4 – Variable K-Map, showing the various groups (i.e., octal, quads and pairs). [4]
(ii) Draw the Logic gate diagram of the reduced expression using NAND gate only. [1]
(b) Given F(A, B, C, D) = (A + B + C + D). (A + B + C + D’). (A + B + C’ + D’). (A + B + C’ + D). (A + B’ + C + D’). (A + B’ + C’ + D’). (A’ + B + C + D). (A’ + B + C’ + D).
(i) Reduce the above expression by using 4 – Variable K-Map, showing the various groups (,i.e., octal, quads and pairs). [4]
(ii) Draw the Logic gate diagram of the reduced expression using NOR gate only. [1]
Answer:
Question 5.
A Government Institution intends to award a medal to a person who following criteria:
The person should have been an Indian citizen and had lost his/her completed 25 years of service.
OR
The person must be an Indian citizen and has served the nation for a continuous period of 25 years or more but has not lost his/her life in a war.
OR
The person is not an Indian citizen but has taken an active part in activities for the upliftment of the nation.
The inputs are:
A | The person is/was an Indian citizen |
B | Has a continuous service of more than 25 years |
C | Lost his/her life in a war |
D | Taken part in activities for the upliftment of the nation |
Output: X – Denotes eligible for Medal [1 indicates YES and 0 indicates NO in all cases]
(a) Draw the truth table for the inputs and outputs given above and write the POS expression for X (A, B, C, D). [5]
(b) Reduce X (A, B, C, D) using Karnaugh’s Map. [5]
Draw the logic gate diagram for the reduced POS expression for X (A, B, C, D).
You may use gates with two or more inputs. Assume that the variable and their complements are available as inputs.
Answer:
Question 6.
(a) What are Maxterms? Convert the following function as a product of Maxterms: [3]
F(P, Q, R) = (P + Q).(P’ + R)
(b) State whether the following expression is a Tautology or Contradiction with the help of Truth Table: [3]
(X⇔Z) . [(X⇒Y). (Y⇒Z)]
(c) What is Multiplexer? Draw the truth table and logic diagram of an 8 : 1 Multiplexer. [4]
Answer:
(a) Maxterm It is a sum of all the literals (with or without the bar) within the logic system.
F(P, Q, R) = (P + Q). (P’ + R’)
= (P + Q + RR’). (P’ + QQ’ + R’)
= (P + Q + R).(P + Q + R’).(P’ + Q + R’) ,(P’ + Q’ + R’)
It is neither Tautology nor contradiction.
(c) Multiplexer: It is a combinational circuit that selects binary information from one of many input lines and directs it to a single output line.
Question 7.
(a) Draw the circuit diagram for a 3 to 8 Decoder. [3]
(b) Draw the truth table for a Half Adder. Also, derive a POS expression for the Half Adder and draw its logic circuit. [3]
(c) Simplify the following expression and also draw the circuit/gate for the reduced expression.
[Show the stepwise working along with the laws used.] [4]
F = X.(Y + Z.(X.Y + X.Z)’)
Answer:
Section – B
Answer any two questions
- Each program should be written in such a way that it clearly depicts the logic of the problem.
- This can be achieved by using mnemonic names and comments in the program.
- Flowcharts and Algorithms are not required
- The Programs must be written in C/Java
Question 8.
The coordinates of a point P on a two-dimensional plane can be represented by P(x, y) with x as the x-coordinate and y as the y-coordinate. The coordinates of the midpoint of two points P1(x1, y1) and P2(x2, y2) can be calculated as P(x, y) where: [10]
\(x=\frac{x_{1}+x_{2}}{2}, y=\frac{y_{1}+y_{2}}{2}\)
Design a class Point with the following details:
Class name: Point
Data Members/instance variables:
x: stores the x-coordinate
y: stores the y-coordinate
Member functions:
Point (): constructor to initialize x = 0, y = 0
void readpoint (): accepts the coordinates x and y of a point
Point midpoint (Point A, Point B): calculates and returns the midpoint of the two points A and B
void displaypoint (): displays the coordinates of a point
Specify the class Point giving details of the constructor (), member functions void readpoint ( ), Point midpoint (Point, Point) and void displaypoint () along with the main () function to create an object and call the functions accordingly to calculate the midpoint between any two given points.
Answer:
import java.io.*; class Point { int x; inty; public Point () { x = 0; y = 0; } public void read point () throws IOException { Buffered Reader br = new BufferedReader(new InputStreamReader(Systemin); System.out.println("Enter the value of x''); x = Integer.parselnt (br. readLine()); System.out.printing'Enter the value of y "); y = Integer.parselnt(br. readLine ( )); } public Point midpoint(Point A, Point B) { x = (A.x+B.x)/2; y = (A.y + B.y)/2; } public void displaypoint() { System.out.println(x); System. out.println(y); } public void main() { Point obj 1 = new Point(); obj1.readpoint(); Point obj 2 = new Point(); obj2.readpoint(); Point obj 3 = new Point(); Point obj4 = obj3.midpoint(obj 1, obj2); obj4.displayPoint(); } }
Question 9.
Input a word in uppercase and check for the position of the first occurring vowel and perform the following operation. [10]
(i) Words that begin with a vowel are concatenated with “Y”.
For example, EUROPE becomes EUROPEY.
(ii) Words that contain a vowel in-between should have the first part from the position of the vowel till the end, followed by the part of the string from beginning till the position of the vowel and is concatenated by “C”.
For example, PROJECT becomes OJECTPRC.
(iii) Words which do not contain a vowel are concatenated with “N”.
For example, SKY becomes SKYN.
Design a class Rearrange using the description of the data members and member functions given below:
Class name: Rearrange
Data Members/instance variables:
Txt: to store a word
Cxt: to store the rearranged word
len: to store the length of the word
Member functions:
Rearrange (): constructor to initialize the instance variables
void readword (): to accept the word input in UPPER CASE
void convert (): converts the word into its changed form and stores it in string Cxt
void display(): displays the original and the changed word
Specify the class Rearrange giving the details of the constructor (), void readword ( ), void convert () and void display (). Define a main () function to create an object and call the function accordingly to enable the task.
Answer:
import java.io.*; class Rearrange { String Txt; String Cxt; intLen; public Rearrange () { Txt= " ''; Cxt = '' " ; Len = 0; } public void readword () { BufferedReader br = new BufferedReaderfnew InputStreamReader(Systemin)): System.out.println( "Enter the String"); Txt = br. readLinef); { public void convert)) { String str1 = " ", str 2 = " " ; boolean check = false; char ch1, ch2, ch3; ch1 = Txt char A+(0); if (ch1 == 'A' || ch1 == 'E' || ch1 == T || ch1 == 'O' || ch1 == 'U') { Cxt = Txt + "Y''; } else { for (i = 0; i < Txt. length (); i ++) { ch2 = TxtcharAt (i); if(ch2 ! = 'A' || ch2 ! = 'E' || ch2 ! = 'I' || ch2 ! = 'O' || ch2 ! = 'U') { Strl = str1 + ch2; } else { check = true; for (j = i; j < Txt.length 0; j++) { ch3 = Txt.charAt (j); str2 = str2 + ch3 ; } Str2 = Str2 + "C"; } Cxt=Str2 + Str1; } if (found = = false) { Cxt = Txt + "N"; } } public void display() { System.out.println("The original string is" + Txt); System.out.println(" The new String is"+ Cxt); } public void main() { Rearrange obj = new Rearrange() obj.readword( ); obj.convert( ); obj.display(); } }
Question 10.
Design a class Change to perform string related operations. The details of the class are given below:
Class name: Change
Data Members/instance variables:
str: stores the word
newstr: stores the changed word
len: store the length of the word
Member functions:
Change(): default constructor
void inputword( ): to accept a word
char caseconvert (char ch): converts the case of the character and returns it
void recchange (int): extracts characters using recursive technique and changes its case using caseconvert () and forms a new word
void display (): displays both the words
(a) Specify the class Change, giving details of the Constructor ( ), member functions void inputword (), char caseconvert (char ch), void recchange (int) and void display (). Define the main () function to create an object and call the functions accordingly to enable the above change in the given word. [8]
(b) Differentiate between an infinite and a finite recursion. [2]
Answer:
(a) import java.io.*; Class change { String str; String newstr; int len; public change() { str = " " ; newstr = " "; len = 0; } public void inputword() { BufferedReader br = new BufferedReader (new InputStreamReader (System.in)); System.out.println ("Enter the number"); Str=br.readLine(); } public char caseconvert (char ch) { if (ch > = 'A' &&. ch<= 'Z') { ch=(char) ((int) ch + 32); return ch; } if (ch > = 'a' && ch < = 'z') { return (char) ((int) ch - 32); } if (ch = = ' ') return ch; } public void recchange (int a) { if(a<0) return; else recchange (a-1);
(b) Finite recursion has the same stopping condition on which the recursive function does not call itself. Infinite recursion has no stopping condition and hence go on infinitely.
Section – C
Answer any two questions
- Each program /Algorithmshould is written in such a way that it clearly depicts the logic of the problem stepwise.
- This can be achieved by using pseudo-codes.
- Flowcharts are not required
- The programs must be written in Java.
- The Algorithm must be written in general/standard form.
Question 11.
A superclass Worker has been defined to store the details of a worker. Define a subclass Wages to compute the monthly wages for the worker. The details/specifications of both the classes are given below:
Class name: Worker
Data Members/instance variables:
Name: to store the name of the worker
Basic: to store the basic pay in decimals
Member functions:
Worker (…): Parameterised constructor to assign values to the instance variables
void display (): display the worker’s details
Class name: Wages
Data Members/instance variables:
hrs: stores the hours worked
rate: stores rate per hour
wage: stores the overall wage of the worker
Member functions:
Wages (…): Parameterised constructor to assign values to the instance variables of both the classes
double overtime (): Calculates and returns the overtime amount as (hours*rate)
void display (): Calculates the wage using the formula wage = overtime amount + Basic pay and displays it along with the other details
Specify the class Worker giving details of the constructor () and void display ( ). Using the concept of inheritance, specify the class Wages giving details of constructor ( ), double-overtime () and void display (). The main () function need not be written.
Answer:
importjava.io.*; class worker { String Name; double Basic; public worker (String n, double b) { Name = n; Basic = b; } public void display ( ) { System.out.println (Name); System.out.println (Basic); } } class wages extends worker { int hrs, rate; double wage public wage (string n, double b, int h, int r, double w) { super (n, b); hrs = h; rate = r; wage = w; } public double overtime () { return (hours*rate); } public void display ( ) { super.display (); wage = overtime () + Basic; System.out.prinln(wages); } }
Question 12.
Define a class Repeat which allows the user to add elements from one end (rear) and remove elements from the other end (front) only.
The following details of the class Repeat are given below:
Class name: Repeat
Data Members/instance variables:
st[]: an array to hold a maximum of 100 integer elements
cap: stores the capacity of the array
f: to point the index of the front
r: to point the index of the rear
Member functions:
Repeat (int m): constructor to initialize the data members cap = m, f = 0, r = 0 and to create the integer array
void pushvalue (int v): to add integer from the rear index if possible else display the message (“OVERFLOW”)
int popvalue (): to remove and return element from the front. If array is empty then return -9999
void disp (): Displays the elements present in the list
(a) Specify the class Repeat giving details of the constructor (int), member function void pushvalue (int). int popvalue () and void disp (). The main ( ) function need not be written. [8]
(b) What is the common name of the entity described above? [1]
(c) On what principle does this entity work? [1]
Answer:
import java.io.*; Class Repeat { intan []; int cap, f, r; public Repeat (int m) { cap = m; f=0; r=0; an [ ] = new int[100]; } public void pushvalue (int v) { if (r = = cap) { Systemout.println ("OVERFLOW"); } else if (f = = 0) { f = 1; } else { an [r++] = v; } } public int popvalue ( ) { if (f == 0) { System.out.println (-9999); } elseif(f=r) { f=0; r = 0; } else { return (an [f++]); } } public void display ( ) { for (i = f; i< = r; i ++) System.outprintln (an [ i ]; }
(b) Queue
(c) It works on first in first out Principle(FIFO).
Question 13.
(a) A linked list is formed from the objects of the class, [4]
class ListNodes { int item; ListNodes next; }
Write a method OR an algorithm to compute and return the sum of all integers items stored in the linked list. The method declaration is specified below:
int listsum(ListNodes start);
(b) What is Big ‘O’ notation? State its significance. [2]
(c) Answer the following from the diagram of a Binary Tree given below:
(i) Name the parent of node E. [1]
(ii) Write the postorder tree traversal. [1]
(iii) Write the internal nodes of the tree. [1]
(iv) State the level of the root of the tree. [1]
Answer:
(a) Algorithm
Let P be a pointer of type listNodes.
- P = start, sum = 0
- Repeat steps 3, 4 while (P! = NULL)
- sum = sum + P → item
- P = P → next (end of step 2 loop)
- Return sum (Print sum)
(b) Big ‘O’ notation: It is used to represent the complexity of algorithms e.g. O(n), O(n log n)
Significance: By using this notation one can compare the complexities of algorithms and can select the best algorithms under time or memory limitations.
(c) (i) C is a parent of E
(ii) Postorder: FGDBHECA
(iii) internal nodes: A B C D E
(iv) level 1