0% found this document useful (0 votes)
92 views10 pages

Set 2

1. The document provides details about computer science paper 1 including questions on Boolean algebra, exception handling, arrays, recursion, logic gates, prime numbers, and classes for matrices, parallelograms, and doubly ended queues. 2. Questions cover topics like Boolean expressions, postfix conversion, stack algorithms, file streams, addresses in row-major matrices, recursion tracing, logic expressions and diagrams, checking for prime and emirp numbers, interchanging letters in words, matrix subtraction, calculating parallelogram perimeter and area using inheritance, and deque operations. 3. The document seeks specifications for classes to solve problems on matrices, parallelograms, emirp numbers, word manipulation, and deque operations. Details

Uploaded by

koushikmalakar
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
92 views10 pages

Set 2

1. The document provides details about computer science paper 1 including questions on Boolean algebra, exception handling, arrays, recursion, logic gates, prime numbers, and classes for matrices, parallelograms, and doubly ended queues. 2. Questions cover topics like Boolean expressions, postfix conversion, stack algorithms, file streams, addresses in row-major matrices, recursion tracing, logic expressions and diagrams, checking for prime and emirp numbers, interchanging letters in words, matrix subtraction, calculating parallelogram perimeter and area using inheritance, and deque operations. 3. The document seeks specifications for classes to solve problems on matrices, parallelograms, emirp numbers, word manipulation, and deque operations. Details

Uploaded by

koushikmalakar
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 10

COMPUTER SCIENCE

PAPER 1 (THEORY)

PART I

Question 1

a. State the Principle of Duality. Write the dual of: [2]

(P+Q').R.I = P.R + Q'.R

b. Minimize the expression using Boolean laws: [2]

F = (A + B').(B + CD),

c. Convert the following cardinal form of expression into its [2]


canonical form:

F (P,Q,R) = 1t (1,3)

d. Using a truth table verify: [2]

( -p => q) /\ P = (p /\ -q) V (p /\ q)

e. If A = 1 and B = 0, then find: [2]

(i) (N + 1).B

(ii) (A + B')'

Question 2

a. Differentiate between throw and throws with respect to


exception handling. [2]
b. Convert the following infIX notation to its postfix form:
E* (F/(O-H) * I)+J
c. Write the algorithm for push operation (to add elements) in an
array based stack. [2]
d. Name the File Stream classes to:
(i) Write data to a file in binary form.

(ii) Read data from a file in text form.

e. A square matrix M [ ][] of size 10 is stored in the memory with


each element requiring 4 bytes of storage. If the base address at
M [0][0] is 1840, determine the address at M [4][8] when the
matrix is stored in Row Major Wise. [2]
Question 3
a. The following function Recur ( ) is a part of some class. What will
be the output of the function Recur () when the value of n is
equal to 10. Show the dry run I working. [5]
void Recur (int n)
{
if(n> I)
{
System.out.print (n +" ");
if(n%2 !=O)
{
n = 3 * n+l;
System.out.print(n +" ");
}
Recur (n/2);
}
}
b. The following function is a part of some class. Assume 'n' is a
positive integer. Answer the given questions along with dry run I
working. int unknown (int n)
{
int i, k;
if (n%2=0)
{ i = n/2;
}
else
{ k=n; n--; i=n/2;
}
while (i > 0)
{ k=k.i.n;
i-- --;
n--- ---' ,
return k;
}
(i) What will be returned by unknown(5)? [2]
(ii) What will be returned by unknown(6)? [2]
(iii) What is being computed by unknown (int n)? [1]
Question 6
a. In the following truth table x and yare inputs and Band D are
outputs: [3]

INPUT OUTPUT
x y B D
0 0 0 0
0 1 1 1
1 0 0 1
1 1 0 0
Answer the following questions:
(i) Write the SOP expression for D.
(ii) Write the POS expression for B.
(iii) Draw a logic diagram for the SOP expression derived for
D, using only NAND gates.

b. Using a truth table, verify if the following proposition is valid or


invalid:
(a = > b) /\ (b => c) = (a => c)

c. From the logic circuit diagram given below, name the outputs (I),
(2) ~nd (3). 14) Finally derive the Boolean expression and simplify
it to show that it represents a logic gate. Name and draw the
logic gate.

Question 8
An emirp number is a number which is prime backwards and
forwards.
Example: 13 and 31 are both prime numbers.

Thus, 13 is an emirp number.

Design a class Emirp to check if a given number is Emirp number


or not. Some of the members of the class are given below:
Class name Emirp
Data members/instance variables:
n : stores the number
rev : stores the reverse of the number
f : stores the divisor
Member functions:
Emirp(int nn) : to assign n = nn, rev = 0 and f= 2
int isprime(int x) : check if the number is prime using
the recursive technique and return
I if prime otherwise return 0
void isEmirp(): reverse the given number and check if both

the original number and the reverse number are prime. by invoking

the function isprime(int) and display the result with an appropriate


message.

Specify the class Emirp giving details of the constructor(illt), int


isprime(int) and void isEmirp(). Define the main( ) function to create
an object and call the methods to check for Emirp number.

Question 9

Design a class Exchange to accept a sentence and interchange the


first alphabet with the [10] last alphabet for each word in the
sentence, with single letter word remaining unchanged. The words in
the input sentence are separated by a single blank space and
terminated by a full stop.

Example: Input: It is a warm day.

Output: tl si a marw yad

Some of the data members and member functions are given below:

Class name Exchange

Data members/instance variables:

Sent :stores the sentence

rev :to store the new sentence

size :stores the length of the sentence

Member functions:

Exchange() default constructor

void readsentence( ) to accept the sentence


void exl'irstlast( ) extract each word and interchange the
first and last alphabet of the word and
form a new sentence rev using the
changed words

void display( ) display the original sentence along with


the new changed sentence.

Specify the class Exchange giving details of the constructor( ), void

readsentence( ), void exfirstlast( ) and void display().

Define the main( )function to create an object and call the functions

accordingly to enable the task.

Question 10

A class Matrix contains a two dimensional integer array of order [m

n]. The 1101 maximum value possible for both om' and 'n' is Design

class Matrix to find the difference of the two matrices. The details

The detaiIs of the members of the class are given below:

Class name Matrix

Data members/instance variables:

arr[ ][ ] :stores the matrix element

m :integer to store the number of rows

n :integer to store the number of columns

Member functions:

Matrix (int mm, int nn) :to


initialize the size of the matrix m = mm
and n = nn
void lillarray( ) to enter the elements of the matrix

Matrix SubMat(Matrix A) subtract the current object from the


matrix of parameterized object and
return the resulting object

void display( ) display the matrix elements

Specify the class Matrix giving details of the constructor(int,int), void

fillarray( ), Matrix SubMat(Matrix) and void display. Define the main)

function to create objects and call the methods accordingly to enable

the task.

SECTION –C

Question 11

A super class Perimeter has been defined to calculate the perimeter

of a parallelogram. Define a subclass Area to compute the area of

the parallelogram by using the required data members of the super

class. The details are given below:

Class name Perimeter

Data members/instance variables:

a to store the length in decimal

b to store the breadth in decimal

Member functions:

Perimeter( ... ) :parameterized constructor to assign


values to data members
double Calculate( ) calculate and return the perimeter of a
parallelogram as 2 * (length + breadth)

void show() to display the data members along with


the perimeter of the parallelogram

Class name :Area

Data members/instance variables:

h : to store the height in decimal

area : to store the area of the parallelogram

Member functions:

Area( ... ) : parameterized constructor to assign


values to data members of both the
classes

void doarea( ) :compute the area as (breadth * height)

void show() :display the data members of both


classes along with the area and
perimeter of the parallelogram.

Specify the class Perimeter giving details of the constructor( ... ),

double Calculate( ) and void show(). Using the concept of


inheritance, specify the class Area giving details of the
constructor(... ), void doarea() and void show( ).

The main function and algorithm need not be written.

Question 12
A doubly queue is a linear data structure which enables the user to
add and remove [101 integers from either ends, i.e. from front or
rear. Define a class Dequeue with the following details:

Class name : Dequeue

Data members/instance variables:

arr[ ] : array to hold up to 100 integer elements

lim : stores the limit of the dequeue

front : to point to the index of front end

rear : to point to the index of the rear end

Member functions:

Dequeue(int I) : constructor to initialize the data members

lim=l; front=rear=O

void addfront(int val): to add integer from the front if possible else

display the message ("Overflow from front")

int popfront( ) : returns element from front, if possible

: otherwise returns -9999

int poprear( ) : returns element from rear, if possible

otherwise returns -9999

Specify the class Dequeue giving details of the constructor(int), void


addfront(int), void addrear(int), int popfront( ) and int poprear( ).

The main function and algorithm need not be written.

You might also like