0% found this document useful (0 votes)
30 views7 pages

Set 4

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)
30 views7 pages

Set 4

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/ 7

COMPUTER SCIENCE

Paper-l

(THEORY)

Question 1

(a) State the two Absorption laws. Verify anyone of them using truth table.[2]

(b) Reduce the following expression:

F(A.B.C) = ∑ ¿¿ )

Also find the complement of the reduced expression.

(c) Name the logic gate for the following circuit diagram and write its truth
table.

(d) Using truth table, verify whether the following is true or false:
→ →
(p ⇒ q) = ( q ⇒ p )

(e) If A=l, B=O, C=l and D=1 find its:

(i) Maxterm

(ii) Minterm

Question 2

(a) The following is a part of some class. What will be the output of the
function mymethod( ) when the value of counter is equal to 3? Show the dry
run / working.

void my method(int counter)

1
{

if ( counter = = 0 )

System.out.println(" ");

else

System .out. println(" He! 10 "+counter);

mymethod( --counter) ;

System.out.println(" "+counter);

(b) The following function is a part of some class which computes and returns
the greatest common divisor of any two numbers. There are some places in
the code marked by ?1?, n?, ?3?, ?4? and ?5? which must be replaced by
statement/expression so that the"function works correctly.

int gcd(int a, int b)

int r;

while(?1?)

r=?2?;

b=?3?

a=?4?

if(a==0)

2
return ?5?;

else

return -1;

Question 3

(a) State the principle of Duality. Give the dual of the following:

(A'.B)+(C.l )=(A'+C).(B+C)

(b) Reduce the Boolean expressions to their simplest forms:

(i) {(C.D)'+ A} + A + C.D + A.B

(ii) A.{B+C(A.B+A.C)'}

(c) Verify using a truth table if:

Question 4

(a) Show with the help of a logic diagram how a NAND gate is equivalent to an
OR gate. [3]

(b) Verify if the following is valid:

3
(a => b) /\ (a => c) = a => (b /\ c) [3]

(c) What is a Decoder? Draw the truth table and logic circuit diagram for a 2 to
4 Decoder. [4]

Question 5

Input a sentence from the user and count the number of times, the words "an"
and "and" are present in the sentence. Design a class Frequency using the
description given below:

Class name Frequency

Data Members / variables:

text :stores the sentence

countand :to store the frequency of the


word "and"

countan :to store the frequency of the


word "an"

len :stores the length of the string

Member functions/methods:

Frequency( ) constructor to initial ize the

instance variables

void accept(String n) to assign n to text, where the

value of the parameter n should

be in lower case.

void checkandfreq( ) to count the frequency of "and"

void checkandfreq( ) to coun! the frequency of "an"

4
void display( ) to display the number of "and"

and "an" with appropriate

messages.

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


accept(String), void checkandfreq( ), void checkanfreq( ) and void display( ).
Also define the main( ) function to create an object and call methods
accordingly to enable the task.

Question 6

A class DeciOct has been defined to convert a decimal number into its
equivalent octal number. Some of the members of the class are given below:

Class name DeciOct

Data Members / instance variables:

n stores the decimal number

oct stores the octal equivalent

number

Member functions:

DeciOct( ) constructor to initialize the data

members n=O, oct = O.

void getnum(int nn ) assign nn to n

void deci oct() calculates the octal equivalent

of 'n' and stores it in oct using

the recursive technique

void show() displays the decimal number 'n',

calls the function deci _ oct( )

and displays its octal equivalent

5
(a) Specify the class DeciOct, giving details of the constructor( ), void
getnum(int), void deci_oct() and void show(). Also define a maine ) function to
create an object and call the functigns accordingly to enable the task.

(b)State any two disadvantages of using recursion.

Question 6

You are given a sequence of N integers, which are called as pseudo arithmetic
sequences (sequences that are in arithmetic progression).

Sequence of N integers: 2, 5,6,8,9, 12

We observe that 2 + 12 = 5 + 9 = 6 + 8 = 14.

The sum of the above sequence can be calculated as 14 x 3 = 42.

For sequence containing an odd number of elements the rule is to double the
middle element, for example 2, 5, 7, 9, 12

= 2 + 12 = 5 + 9 = 7 + 7 = 14.

14 x 3 = 42 [middle element = 7]

A class Pseudoarithmetic determines whether a given sequence is a pseudo-


arithmetic sequence.

The details of the class are given below:

Class name Pseudoarithmetic

Data Members / instance variables:

n to store the size of the sequence

a[] integer array to store the sequence of

numbers

ans, flag store the status

sum store the sum of sequence of numbers

6
r store the sum of the two numbers

Member functions:

Pseudoarithmetic( ) default constructor

void accept( int nn ) to assign nn to n and to create

an integer array. Fill in the


elements of the array.

boolean check( ) return true if the sequence is a

pseudo-arithmetic sequence

otherwise returns false

Specify the class Pseudoarithmetic, giving the details of the constructor( ), void
accept(int) and boolean check(). Also define a main( ) function to create an
object and call the member functions accordingly to enable the task.

You might also like