ISC 2008

COMPUTER SCIENCE

PAPER-I

(THEORY)

(Three hours)

(Candidates are allowed additional 15 minutes for only reading the paper. They must not start writing during this time)

------------------------------------------------------------------

Answer all Question in Part I (compulsory) and seven questions from Part II, choosing three questions from Sections A and four questions from

Section B. All working, including rough work, should be done on the same sheet as the rest of the answer. The intended marks for questions or for parts of questions are given in brackets[].

------------------------------------------------------------------

PART I

while answering questions in this part indicate briefly your working reasoning wherever required.

Question 1.                                                           [10]

(a) State the two complement properties of Boolean Algebra. Verify any one of them using the truth table.

(b) Simplify the following Boolean expression starting clearly the laws used for the simplification at each step. x.y + x.z + x.y.z

(c) Find the complement of x.(y'.z' + y.z)

(d) Convert the following product-of-sum from onto its corresponding sum-of-products form:

F(x,y,z) = PI(2,4,6,7)

(e) Draw the truth table of the proportional logic p=>q and p<=>q

Question 2.

(a) Mention two points which distinguish a static data member from an ordinary data member of a class.

 Ans:

(b) Convert the following infix expression to its postfix form.

A/(B+C)+D*(E-F)

 =((a/(b+c))+(d*(e-f))) =

(c) What do LIFO and FIFO stand for? Name a data structure that follows LIFO principle and one that follows FIFO principle.

(d) A two dimensional array defines as X [3...6,-2...2] requires 2 bytes of storage space for each element. If the array is stored in Row major order, determine the address of X[5,1], Given the base address as 1200.

 Ans:

(e) List the nodes in the Tree given below in.
(i) Preorder
(ii) Postorder
60

/  \

40    70

/  \     \

20   45    80
/ \   / \   / \

10 25 41 50 75 85

 Ans: (i) Preorder 60 40 20 10 25 45 41 50 70 80 75 85      (ii) Postorder 10 25 20 41 50 45 40 75 85 80 70 60      (iii) Inorder 10 20 25 40 41 45 50 60 70 75 80 85

Question 3.

(a) The following is a function of some class. it returns 1 if the number is a perfect number otherwise it returns 0.

int perfectNo(int n)

{

int ?1?

for(int j=1;?2?;j++)

{

if(?3?)

sum?4?;

}

if(?5?)

return 1;

else

return 0;

}

(i) What is the expression/value at ?1?                         [1]
(ii) What is the expression/value at ?2?                         [1]

(iii) What is the expression/value at ?3?                         [1]

(iv) What is the expression/value at ?4?                         [1]

(v) What is the expression/value at ?5?                         [1]

 Ans: (i) sum=0   (ii) j

(b) State the final value of q at the end of following program segment:[5]

void caling()

{

int f=2;

show(n,f);

}

int show(int n, int f)

{

if(n==f)

return 1;

if(n%f==0 || n==1)

return 0;

else

return show(n,f+1);

}

(i) What will the function show() return when the value of n is 11? [2]
(ii) What will the function show() return when the value of n is 27? [2]
(iii) In one line state what the function show() is doing            [1]

 Ans: (i) 1  (ii) 0  (iii) check whether the number is prime or not.

PART II

Answer seven questions in this Part, choosing three questions from Section A and four from Section B.

SECTION A

Question 4.

(a) Given the Boolean function F(A,B,C,D) = E (5,6,7,8,9,10,14)

Use Karnaugh's map to reduce the function F, using the SOP form. Draw a logic gate diagram for the reduced SOP form. You may use gates with more than two inputs. Assume that the variables and their complements are available as inputs.                                                 [5]

 AB\CD [00]C'D' [01]C'D [11]CD [10]CD' [00]A'B' 0 1 3 2 [01]A'B 4 1 5 1 7 1 6 [11]AB 12 13 15 1 14 [10]AB' 1 8 1 9 11 1 10

Pair 1 is m5+m7

Pair 2 is m6+m14

Pair 3 is m8+m9

Pair 4 is m14+m8

Reduce Expression for Quad 1 is A'D'

Reduce Expression for Quad 1 is A'C
Reduce Expression for Pair 1 is AC'D

Final SOP expression is A'D'+A'C+AC'D

(b) Given: X(A,B,C,D) = II(2,3,4,5,12,14)

Use Karnaugh's map to reduce this function X using the given POS form. Draw a logic gate diagram for the reduced POS form. You may use gates with more than two inputs. Assume that the variables and their complements are available as inputs.                                                [5]

 AB\CD [00]C+D [01]C+D' [11]C'+D' [10]C'+D [00]A+B 0 1 0 3 0 2 [01]A+B' 0 4 0 5 7 6 [11]A'+B' 0 12 13 15 0 14 [10]A'+B 8 9 11 10

Pair 1 is m2+m3

Pair 2 is m4+m5

Pair 2 is m12+m14

Reduce Exp. for Pair 1 is A+B+C'

Reduce Exp. for Pair 2 is A+B'+C

Reduce Exp. for Pair 3 is A'+B'+D

Question 5.

The inaugural function of the newly constructed flyover has been organized by the Public Works Department. Apart from a few special invitees, entry is permitted only if,

* The person is an employee of the PWD of Class I category with more than 10 years of working experience.

OR

* The person is an employee of any other government or authorized private organization either at the managerial level or with more than 10 years of working experience.

The inputs are:

A The person is a Class I employee of PWD
B The person is an employee of any other government or authorized

private organization.
C: The person has more than 10 years of working experience.
D: The person is holding a managerial post

output:

X- Denotes eligible for entry

[ 1 indicates Yes and 0 indicates No in all cases ]

(a) Draw the truth tables for the inputs and outputs given above and write the Sop expression for X(A,B,C,D).                                 [5]

 Input Output A B C D R 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 1 0 1 1 0 1 0 1 1 1 1 1 0 0 0 0 1 0 0 1 0 1 0 1 0 1 1 0 1 1 1 1 1 0 0 0 1 1 0 1 1 1 1 1 0 1 1 1 1 1 1

The Function value is: R(A,B,C,D)=E(5,6,7,10,11,13,14,15)

The SOP Expression for R(A,B,C,D) is A'BC'D + A'BCD' + A'BCD + AB'CD' + AB'CD + ABC'D + ABCD' + ABCD

(b) Reduce X(A,B,C,D) using Karnaugh's map. Draw the logic gate diagram for the reduced SOP expression for X(A,B,C,D) using AND & OR gates. You may use gates with two or more inputs. Assume that the variables and their complements are available as inputs.                                [5]

 AB\CD [00]C'D' [01]C'D [11]CD [10]CD' [00]A'B' 0 1 3 2 [01]A'B 4 1 5 1 7 1 6 [11]AB 12 1 13 1 15 1 14 [10]AB' 8 9 1 11 1 10

Simplified Exp. for Quad 1 is BD

Simplified Exp. for Quad 1 is BC

Simplified Exp. for Quad 1 is AC

So final Reduced Expression is BD+BC+AC

Question 6.

a) How XOR gate different from an OR gate? Draw a truth table representing a 3 input XOR operation. Derive its SOP expression and draw the logic gate diagram for the SOP expression. [4]

b) What is the purpose of a Multiplexer? Mention any two application of Multiplexer. [3]

c) Draw the logic gate diagram for the following three input function F(x,y,z) using NOR gates only. F(x,y,z)=E(0,1,3,4,7) [3]

Question 7.

(a) Reduce the following expression usin the laws of Boolean Algebra. Draw the logic gate diagram for the simplified expression. F(A.(A'+B).C.(A+C)                             [4]

(b) State the principle of duality. Give the example.                      [3]

(c) Convert A.B+B.C' to its canonical SOP form using Boolean Algebra.      [3]

Questions 8.

(a) Draw the truth table and logic circuit diagram for a 3x8 decoder. State the difference between a Multiplexer and a decoder.      [5]

(b) Reduce the following Boolean expression to the simplest form: A.[B+C.(A.B+A.C)'] [3]

(c) Given : F(x,y,z)=E(1,3,7)     Prove that F(x,y,z)=II(0,2,4,5,6)             [2]

SECTION B

Answer only four 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. (Flow charts and Algorithms are not  required).

(The program must by written in C++ OR Java)

Question 9.

NIC institute's resource manager has decided to network the computer resources like printer, storage media, etc, so that minimum resources and maximum sharing could be availed. Accordingly printers are linked to a centralized system and printing jobs are done on a 'first cum first served ' basis only. This is like the first person's printing job will get done first and the next person's job will be done as the next job in the list

and so on. In order to avoid collision, the restriction is that no more than 20 printing jobs can be added.

Define the class Printjob with the following details:

 Class name printjob Data members/instance variable job[] newjob capacity front  rear array of integers to hold the printing jobs to add a new printing job into array the maximum capacity of the integer array  to point to the index of the front to point to the index of the last member functions/methods printjob() Constructor to initialize data members capacity=20, front=rear=-1 and call the function createjob() void createjob() to create an array to hold the printing jobs. void addjob() adds the new printing job to the end of the last printing job, if possible, otherwise displays the message "Printjob is full, cannot add any more". void removejob() Removes the printing job from the front if the printing jiob is not empty, otherwise displays the message "printjob is empty".

(a) Specify the class Printjob giving details of the constructor and the function void addjob(), void createjob() and void removejob() only. You do not need to write the main function.

(b) What is the common name of the entity described above?

(c) State one of its applications.

Question 10.

A special number is a number in which the sum of the factorial of each digit to the number itself. For example, 145=1!+4!+5!

=1+24+120

Desgin a class Special to check if a given number is a special number. Some of the members of the class are given below:

 Class name special Data members/instance variables n integer Member functions/methods: special() Constructor to assign 0 to n special(int) parameterized constructor to assign a value to 'n' void sum() to calculate and display the sum of the first and the last digit of 'n' void isspecial() check and display if the number 'n' is a special number

Specify the class special giving the details of the constructor ,void sum() and void isSpecial(). You need not write the main function.

 #include #include class special {   public:   int n;   special()   {     n=0;   }   special(int x)   {     n=x;   }   void sum()   {     int d,f,num=n;     f=num%10;     while(num>0)     {       d=num%10;       num=num/10;     }     cout<<"Sum of FIRST & LAST Digit : "<<(f+d)<0)     {       f=1;       d=num%10;       for(int i=1;i<=d;i++)         f=f*i;       sum=sum+f;       num=num/10;     }     if(sum==n)       cout<<"Number is Special no.";     else       cout<<"Number is not Special no.";   } }; void main() {   clrscr();   int n;   cout<<"Enter the number : ";   cin>>n;   special nm(n);   nm.sum();   nm.isspecial();   getch(); }

Questions 11.

A class collection contains an array of 100 integers. Using the following class description create an array with common elements from two integer arrays. Some of the members of the class are given below:

 Class name collection Data members arr[] len integer array length of the array Member functions collection() default constructor collection(int) parameterised constructor to assign the length of the array void inparr() to accept the array collection common(collection) returns a collection containing the common elements of current collection object and the collection object passed as a parameter void arrange() sort the array elements of the object containing common elements in ascending order using any sorting technique void display() displays the array elements.

Specify the class collection giving details of the constructor, void inparr() and void arrange(), collection common(collection). You need not write the main function.

Questions 12.

A class Employee contains employee details and another class Salary calculates the employees net salary.

The details of the class are given below:

 Class name Employee Data members/instance variables empno empname empdesig store the employee no stores the employee name stores the employee designation Member functions/methods: Employee() default constructor. Employee(.....) parameterised constructor to assign value to the employee no, name and designation. void display() display the employee details. Class name Salary Data members/instance variables basic float variable to store the basic pay. Member functions/methods: Salary(...) parameterised constructor to assign value to data members. void calculate() calculate the employee net salary according to the following rules. DA = 10% of BASIC HRA = 15% of BASIC Salary = BASIC + DA + HRA PF = 8% of Salary Net Salary = Salary - PF Display the employee details and net salary.

Specify the class Employee giving the details of constructor and member functions void display() using the concept of inheritance specify the class Salary giving details of constructor and the member functions void calculate(). The main function needs to be written.

 #include #include #include #include class Employee {   int empno;   char empname[30],empdesig[30];   public:     Employee()     {       empno=0;       strcpy(empname,"");       strcpy(empdesig,"");     }     Employee(int emno,char epname[],char epdes[])     {       empno=emno;       strcpy(empname,epname);       strcpy(empdesig,epdes);     }     void display()     {       cout<<"\n Employee Number : "<

Question 13.

A class revstr defines a recursive function to a reverse a string and check whether it is a palindrome. The details of both the classes are given below:

 Class name revstr Data members/instance variables str revst stores the string stores the reverse of the string Member functions/methods void getstr() to accept string void recreverse(int) to reverse the string using Recursive technique. void check() to display the original string, its reverse and whether the string is a palindrome or not.

Specify the class revstr giving the details of the function void getstr(), void recreverse(int) and void check(). the main function need not be written.

 #include #include #include #include class revstr {   char str[30],revstr[30];   public:   void getstr()   {     cout<<"Enter a String : ";     gets(str);   }   void recreverse(int n)   {     if(n>strlen(str)-1)     {       revstr[n]=NULL;       return;     }     else     {       revstr[n]=str[strlen(str)-n-1];       // cout<

Question 14.

A class Modify has been defined with the following details:

 Class name Modify Data members/instance variables St len to store the string to store the length of the given string Member functions/methods void read() to accept the string in Uppercase alphabets void putin(int,char) to insert the character at the specified position in the string and display the changed string void takeout(int) to remove the character from the specified position in the string and display the changed string void change() to replace each character in the original string by the character which is at a distance of 2 moves ahead For example: "ABCD" becomes "CDEF"              "XYZ"  becomes "ZAB"

Specify the class Modify giving the details of the void read(), void putin(int,char), void takeout(int) and void change(). The main function need not be written.

=*=*=*=*=*=