ISC 2007

COMPUTER SCIENCE

PAPER-I

(THEORY)

(Three hours)

Show/Hide Answer

 

(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

Answer all questions.

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

 

Question 1.                                                           [10]

(a) Simplify the following Boolean expression using laws of Boolean Algebra. At each step state clearly the law used for simplification.
    X.Y. (X.Y + Y.Z)

= (X.Y).(X.Y) + (X.Y).(Y.Z)
= (X.Y) + (X.Y.Z)
= XY(1+Z)
= XY

(b) State the De Morgan's Laws. Verify any one of them using the truth table.

Ans: 

(c) Convert the following SOP into its corresponding POS form:

    F(O,V,W) = O'.V'.W' + O'.V'.W + O'.V.W + O.V'.W

 

(d) Find the complement of

    F(a,b,c,d) = [a + {(b + c).(b'+d')}]

 

(e) Draw the logic gate diagram and truth table for XOR gate.

Your Ad Here

 

Question 2.                                                           

(a) Name the Universal Gates.

Ans: NOR and NAND Gates

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

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

=(A + (B * C))/(C -(D*B))

=(A + (BC*))/(C -(DB*))

= (ABC*+)/(CDB*-)

=ABC*+CDB*-/

(c) Each element of an array X[-15...10,15...40] requires one byte of storage. If the array is stored in column major order with the beginning location 1500, determine the location of X[5,20].

 

(d) Explain any two standard ways of traversing a Binary tree.

Ans: Traversal is the act of moving through all the nodes of the binary tree and visiting each one in turn.

There are 3 types of traversals.

  (i) Pre-order :

    (a) Visit the root.

    (b) Traverse the left subtree in pre-order.

    (c) Traverse the right subtree in pre-order.

  (ii) In order :

    (a) traverse left subtree.

    (b) Visit the root.

    (c) traverse right subtree.

  (iii) Post order :

    (a) Traverse left subtree in post-order.

    (b) Traverse right subtree in post-order.

    (c) Visit the root.

(e) What is meant by visibility mode in the definition of derived classes Inheritance? Explain any two visibility modes available.

Ans: Visibility mode controls the inheritance or accessibility of the base class members to the derived class visibility mode may be public or private or protected.
Public Visibility: When public keyword used in class derivation then object of the derived class can access, (i) public function of base class as they are public member of the derived class. (ii) Protected functions of base class become the protected functions of the derived class. (iii) Private functions of the base classed remains private in the derived class

 

Question 3.

(a) In the following, function strange is a part of some class. Assume that arguments x and y are greater than 0 when the function is invoked. Show the dry run/working.

    int strange(int x, int y)

    {

      //Assuming x>=O and y>O

      if(x>=y)

      {

        x=x-y;

        return strange(x,y);

      }

      else

        return x;

    }

(i) What will the function strange(20,5) return?                    [2]
(ii) What will the function strange(15,6) return?                   [2]
(iii) In one line state what the function strange is doing.         [1]

Ans:
(i) 0
(ii) 3
(iii) Finding the REMAINDER of two given numbers.

 

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

    int m, n, p, q = 0;
    for (m = 2; m <= 3; ++m)

    {

        for (n = 1; n <= m; ++n)

        {
            p = m + n;

            if(p%3==0)

                q += p;
            else
                q += p+4;

        }

    }

Ans: 34

              

PART II

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

 

SECTION A

Answer any three questions.

Question 4.

(a) Given the Boolean function F(A,B,C,D) = E (0,2,3,4,6,7,9,13)

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'

1

0

1

1

3

1

2

[01]A'B

1

4

5

1

7

1

6

[11]AB

 

12

1

13

 

15

 

14

[10]AB'

 

8

1

9

11

 

10

Quad 1 is m0+m2+m4+m6

Quad 2 is m3+m2+m7+m6
Pair 1 is m13+m9

Reduce Expression for Quad 1 is A'D'

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

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

Your Ad Here

 

(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

Your Ad Here

 

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

Quad 1 (m5+m7+m13+m15)

Quad 2 (m6+m7+m14+m15)

Quad 3 (m10+m11+m14+m15)

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

 

 
Your Ad Here
 

 

Question 6.

A combinational circuit with 3 inputs A, B, C detects an error during transmission of code and gives the output D as 1 if any two of the inputs are low (0).

i) Write the truth table with Inputs A, B, C and Output D.          [2]
ii) Write the SOP expression for D (A, B, C) using minterms. Implement D using NAND gates only.                                              [4]
iii) Write the POS expression for D(A, B, C) using maxterms. Implement D using NOR gates only.                                               [4]

Your Ad Here

 

Question 7.

(a) Draw the truth table and logic circuit diagram for a Hexadecimal to Binary encoder.                                                     [6]

 

(b) Verify if X'.Y.Z + X.Y'.Z + XYZ' + XYZ = XY + YZ + ZX

At each step state clearly the law used for simplification          [4]

 

 

Questions 8.

(a) Using the truth table verify p.q + p.q' = p                     [2]

 

(b) What is full adder? Write the SOP expressions for sum and carry.
Simplify the expressions algebraically using Boolean Algebra.:      [6]

 

(c) What is meant by a Logic Gate? State any one application of a logic gate circuit.                                                       [2]

Ans: A Logic Gate is a simply an electronic circuit which operates on one or more signal to produce an output signals. The application of a Logic Gate circuit was, ADDERS, ENCODERS, DECODERS

 

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.

A class called EvenSeries has been defined to find the smallest value of integer, n, such that,

     4     8     16               2n   

2 + --- + --- + ---- + ....... + ---- >=S where 2.0 < S < 7.0
     2!    3!    4!               n!

Some of the members of the class EvenSeries are given below:

Class name Evenseries
Data members/instance variable 

n

S

k

long integer type to store number of terms

float variable where 2.0<s<7.0

float variable to store the value of series evaluated

member functions/methods
EvenSeries()

Constructor to initialize data members to 0

void accept()

to accept value of data member S.

long fact(long x)

to compute and return factorial of x.

void disp() calculates and displays the least value of n.

Specify the class EvenSeries giving the details of the constructor and functions void accept(), long fact(long) and void disp(). The main function need not be written.

#include<iostream.h>
#include<conio.h>
#include<math.h>
class EvenSeries
{
  private:
    long int n;
    float s,k;
  public:
    EvenSeries()
    {
      n=0;
      s=0.0;
      k=0.0;
    }
    void accept()
    {
      while(1)
      {
        cout<<"Enter the value of S (2 to 7): ";
        cin>>s;
        if(s>=2 && s<=7)
          break;
        else
          cout<<"Value must be between 2 to 7"<<endl;
      }
    }
    long fact(long x)
    {
      long f=1;
      for(int i=1;i<=n;i++)
        f=f*i;
      return(f);
    }
    void disp()
    {
      n=1;
      while(1)
      {
        k = k + (float) (pow(2,n)/fact(n));
        if(k>=s) break;
        n++;
      }
      cout<<"The least value of the n :"<<n;
    }
};

 

Question 10.

Design a class change to convert a decimal number to its equivalent in base 16 and to convert it back to its decimal form. Eg. (i) The decimal number 35 is 23 in base 16

(ii) The decimal number 107 is 6B in base 16.

Some of the members of the class are given below:

Class name change
Data members/instance variables:

a[]

n

integer type array

integer to be converted to base 16.

Member functions/methods:
change() Constructor to assign 0 to instance variables
void input() accepts integer to be converted to base 16
void hexadeci(int) to convert decimal integer 'n' to hexadecimal form
void decihexa() to convert hexadecimal number back to decimal form.

Specify the class change giving the details of the constructor and the functions void input(), void hexdeci(int) and void decihexa(), The main function need not be written.

 

#include <iostream.h>
#include <conio.h>
class change
{
  int a[10];
  int n;
  public:
    change()
    {
      n=0;
      for(int i=0;i<10;i++)
        a[i]=-1;
    }
    void input()
    {
      cout<<"Enter a decimal value : ";
      cin>>n;
    }
    void hexadeci(int x)
    {
      // To convert from decimal to hexadecimal //
      int d,i=0,j;
      char dig[]={'0','1','2','3','4','5','6', '7','8','9','A','B','C','D','E','F'};
      while(x>0)
      {
        d=x%16;
        a[i]=d;
        i++;
        x=x/16;
      }
      cout<<"Equivalent Hexadecimal value : ";
      for(j=i-1;j>=0;j--)
        cout<<dig[a[j]];
    }
    void decihexa()
    {
      hexadeci(n);
      int h=0,m=1,i=0;
      do
      {
        h=h+a[i]*m;
        m=m*16;
        i++;
      }while(a[i]!=-1);
      cout<<"\nEquivalent Decimal value : "<<h;
    }
};

 

Questions 11.

A class Rearrange has been defined to insert an element and to delete an element from an array. Some of the members of the class are given below:

Class name Rearrange

Data members

a[]

n

pos1

pos2

item

integer type array

size of array (integer)

position of insertion (integer)

position of deletion (integer)

item to be inserted (integer)

Member functions

void enter() to enter size, array elements and to display the
entered elements.
void insert() to accept element (item) to be inserted, position of insertion and insert the element (item) at the position of insertion.
void disp1() to display array after item is inserted.
void disp2() to display array after item is deleted.
void remove() to accept the position of deletion and delete element (item) at the position of deletion.

Specify the class Rearrange giving details of the functions void enter(), void insert(), void displ(), void disp2() and void remov(). The main function need not be written.

 

#include <iostream.h>
#include <conio.h>
class Rearrange
{
  int a[10];
  int n;
  int pos1,pos2;
  int item;
  public:
  void enter()
  {
    cout<<"Enter size of Array : ";
    cin>>n;
    for(int i=0;i<n;i++)
    {
      cout<<"Enter element : ";
      cin>>a[i];
    }
    disp1();
  }
  void insert()
  {
    cout<<"Enter a number : "; cin>>item;
    cout<<"Enter the position : "; cin>>pos1;
    for(int i=n-1;i>=pos1;i--)
      a[i]=a[i-1];
    a[pos1-1]=item;
    disp1();
  }
  void disp1()
  {
    for(int i=0;i<n;i++)
      cout<<a[i]<<endl;
  }
  void disp2()
  {
    for(int i=0;i<n-1;i++)
      cout<<a[i]<<endl;
  }
  void remove()
  {
    cout<<"Enter Position of the number to be deleted : ";
    cin>>pos2;
    for(int i=pos2-1;i<n-1;i++)
      a[i]=a[i+1];
    disp2();
  }
};

 

Questions 12.

A class Convert has been defined to express digits of an integer in words.

The details of the class are given below:

Class name Convert

Data members/instance variables

n integer whose digits are to be expressed in
words

Member functions/methods:

Convert() constructor to assign 0 to n.
void inpnum() to accept the value of n.
void extdigit(int) to extract the digits of n using the
Recursive technique.
void num_to_words(int) to display the digits of an integer n in
words.

Specify the class Convert giving the details of constructor and functions void inpnum(), void extdigit(int) and void num_to_words(int). The main function need not be written.

 

#include<iostream.h>
#include<conio.h>
class convert
{
  int n;
  public:
    convert()
    {
      n=0;
    }
    void inpnum()
    {
      cout<<"Enter a Number : ";
      cin>>n;
      num_to_word(n);
    }
    void extdigit(int x)
    {
    char dig[][10]={"ZERO","ONE","TWO","THREE","FOUR","FIVE","SIX","SEVEN","EIGHT","NINE"};
      if(x==0)
        return;
      else
      {
        cout<<dig[x%10]<<" ";
        extdigit(x/10);
      }
    }
    void num_to_word(int n)
    {
      extdigit(n);
    }
};

 

Question 13.

A class Student defines the personal data of a student while another class Marks defines the register number, name of subject and marks obtained by the student. The details of both the classes are given below:

Class name Student
Data members/instance variables
name[] sex[]

age

array of characters

integer variable

Member functions/methods
void inpdetails1() to accept values for data members
void showl() to display personal data of student
Class name Marks
Data members/instance variables
regnum, marks

subject[]

integer variable

array of characters

void inpdetails2() to accept values for data members
void show2() to display exam details (regnum, marks, subject)

 

(a) Specify the class Student giving details of the functions void inpdetails1( ) and void show1().

(b) Using the concept of inheritance, specify the class Marks, giving the details of the functions void inpdetails2() and void show2(). The main function need not be written.

 

#include<iostream.h>
#include<conio.h>
#include<stdio.h>
class student
{
  char name[30],sex[10];
  int age;
  public:
    void inpdetails1()
    {
      cout<<"Enter a Name : ";
      gets(name);
      cout<<"Enter Sex : ";
      gets(sex);
      cout<<"Enter Age : ";
      cin>>age;
    }
    void show1()
    {
      cout<<"\nName : "<<name;
      cout<<"\nSex : "<<sex;
      cout<<"\nAge : "<<age;
    }
};

class marks:public student
{
  char subject[30];
  int regnum,marks;
  public:
    void inpdetails2()
    {
      student::inpdetails1();
      cout<<"Enter a Registration Number : ";
      cin>>regnum;
      cout<<"Enter Marks : ";
      cin>>marks;
      cout<<"Enter Subject : ";
      gets(subject);
    }
    void show2()
    {
      student::show1();
      cout<<"\nRegistration No. : "<<regnum;
      cout<<"\nMarks : "<<marks;
      cout<<"\nSubject : "<<subject;
    }
};
Your Ad Here

 

Question 14.

A class Mystring has been defined for the following methods/functions:

Class name Mystring
Data members/instance variables
str[]

len

to store the string

length of the given string

Member functions/methods
Mystring() constructor
void readstring() reads the given string from the input
int code(int index) returns ASCII code for the character at position index
void word() displays longest word in the string.

Specify the class Mystring giving the details of the constructor and void readstring(), int code(int index), void word() only. The main function need not be written.

 

#include<iostream.h>
#include<conio.h>
#include<stdio.h>
#include<string.h>
class Mystring
{
  char str[150];
  int len;
  public:
    Mystring()
    {
      strcpy(str,"");
      len=strlen(str);
    }
    void readstring()
    {
      cout<<"Enter a String : ";
      gets(str);
      strcat(str," ");
    }
    int code(int index)
    {
      int x=str[index];
      return(x);
    }
    void word()
    {
      char a[50],lw[50];
      int l=0,z=0;
      for(int i=0;str[i]!='\0';i++)
      {
        if(str[i]==' ')
        {
          a[z]='\0';
          if(strlen(a)>l)
          {
            strcpy(lw,a);
            l=strlen(a);
          }
          z=0;
        }
        else
        {
          a[z]=str[i];
          z++;
        }
      }
      cout<<"Longest word : "<<lw;
    }
};

 

=*=*=*=*=*=