Anda di halaman 1dari 6

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 questions in Part I (compulsory) and Seven questions from Part-II, choosing three questions
from Section-A, two from Section-B and two from Section-C.
All working, including rough work, should be done on the same sheet as the rest of the answer.
The intended marks for questions or parts of questions are given in brackets [].
-------------------------------------------------------------------------------------------------------------------------
PART I
Answer all questions
While answering questions in this Part, indicate briefly your working and reasoning,
wherever required.

Question 1

(a) Construct the inverse, converse and contrapositive of conditionals given below : [2]
(i) If it is January, then it is cold. (ii) If y+5 ≠ 7, then y<0
(b) State any two Equivalence laws and prove them algebraically. [2]
(c)Determine if the following wff is valid, satisfiable or unsatisfiable: [2]
p v q & ~p v ~q & p
(d) Complement the following and then reduce : [2]
(x+y’).y.z’+x’z(y+x’.y)
(e) Convert the following expression F (X,Y,Z) =X’+Y’Z into canonical SOP form. [2]

Question 2

(a) Differentiate between static and dynamic binding. [2]


(b) Convert the following infix notation to postfix: [2]
A* (B/C+D)^E-(F+G-H)
(c) Each element of an array arr[15][20] requires ‘W’ bytes of storage. If the address of
arr[6][8] is 4580 and the Base Address at arr[1][1] is 4000, find the width ‘W’of each cell in the
array arr[][] when the array is stored as Column Major Wise. [2]
(d) What is the difference between StringTokenizer and StreamTokenizer classes? [2]
(e) State two ways in which linked lists are different from arrays. [2]

Question 3
a) The following function recur() and someRecur( ) are a part of some class. Give the output when
the function someRecur( ) is called. Show the dry run/ working.
int recur(int n)
{
if(n>1)
return n*recur(n-1);

else return 1;
}

int someRecur(int m)
{
if(m==0)
return 0;
else
return recur(m%10)+someRecur(m/10);

}
(i)What will the function someRecur(145) return? [2]
(ii)What will the function someRecur(101)return? [2]
(iii) For what purpose are the two functions used together? [1]

(b) The following function is part of some class. It prints the frequency of each digit present in the
array.
void freq (int arr[])
{
int i,j,f;
for(i=0;i<arr.length;i++)
{
f=?1?;
for(j=i+1;j<?2?;j++)
{
if(arr[i]==arr[j] && ?3?)
{
f++;
?4?
}
}
if(?5?)
System.out.println(“Frequency of “+a[i]+” = “+f);
}
(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]

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(A, B, C, D)=∑ (0,2,3,4,6,8,10,11,14,15)


(i) Reduce the above expression by using 4- Variable K-Map, showing the various groups
(i.e. octal, quads and pairs). [3]
(ii) Draw the Logic gate diagram of the reduced expression using NAND gates only. [2]

(b) Given F(A, B, C, D) = π (5,6,7,8,10,12,14,15)


(i) Reduce the above expression by using 4-Variable K-Map, showing the various groups (i.e.
Octal, quads, pairs). [3]
(ii) Draw the Logic gate diagram of the reduced expression using NOR gates only. [2]

Question 5

(a) Draw the logic diagram and Truth table to Encode the Octal lines. Briefly explain the
working of the logic diagram. [5]
(b) Simplify the equation and draw the gate for the reduced expression.
F = A’B + A.B’.C + A [2]
(c) Differentiate between converse and inverse. Give example. [3]

Question 6

(a) From the premises p=>q and ~q, deduce ~p. [3]
(b) What is Big O notation? What do you understand by best-case, average-case,
worst-case complexities? [5]
(c) How many selection lines does an 8:1multiplexer have? Draw the block diagram of a
8 X 1 MUX. [2]

Question 7

(a) How does Half Adder differ from Full Adder? Draw truth table for both the adders. Also
Derive expression for full adder and simplify the same? [5]
(b) Prove that [(p’+q).(q’+r)]’+(p’+r)=1 [3]
(c) Verify the following:
∑(0,2,7,6) = π (1,3,4,5) [2]

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 Java
Question 8

Design a class Composite to fill an array of order [m x n] with the first [m x n] composite numbers
column wise. The details of the members of the class are given below:
Class name: Composite
Data members/ instance variables:
arr[ ] [ ] : Two dimensional array.
m : integer to store the number of rows.
n : integer to store the number of columns.
Member functions:
Composite( ) : to accept the size of the array.
int isComposite( int p) : return 1 if number is composite and 0 if not composite.
void fill( ) : to fill the elements of the array with the first (m x n) composite numbers.
void display( ) : displays the array in a matrix form.
Specify the class Composite giving details of the constructor and member functions int
isComposite(int), void fill( ) and void display( ) with main( ) function to create an object and
call the function accordingly. [10]

Question 9

Design a class Sort which enables a sentence to be arranged in ascending order according to its
word length.
The details of the members of the class are given below:
Class name :Sort
Datamembers/ instance variables:
Str : to store a word
Member functions:
Sort( ) : default constructor
void readword( ) : to accept the inputted sentence
void arrange( ) : to arrange the sentence in ascending order of word length using any sorting
technique.
void disp( ) : displays the sentence.

Specify the class Sort giving details of the constructor and the member functions void
readword( ), void arrange, void disp( ) and defining the main( ) function to create an object
and call the function in order to execute the class by displaying the original sentence and the
changed sentence with proper message. [10]

Question 10

A class Recursion has been defined to find the magic numbers up to a limit. Some of the members
of the class are given below.
Class name: Recursion
Data members/instance variables:
limit : integer to store the limit.
Members functions/methods:
Recursion() default constructor.
void input() to accept the limit of the series.
int num(int n) to return the sum of digits using recursive technique.
void generate_magic_nos() to generate magic numbers upto the given given limit.

(a) Specify the class Recursion, giving details of the Constructor and member functions void
input( ), int num(int), void generate_magic_nos( ) and the main( ) function to create an
object and call the member function according to enable the task. [8]
(b) Why recursive functions result into slower execution of the program? [2]

SECTION - C
Answer any two questions
Each Program/ Algorithm should be written in such a way that it clearly depicts the logic of the
problem step wise. This can also be achieved by using pseudo codes.
(Flowcharts are not required)
Programs to be written in Java.
The Algorithm must be written in general/ standard form.
Question 11
A class Employee contains employee details and another class Salary calculates the employee’s
net salary.
Class name: Employee
Data members/instance variables:
emp_no: to store the employee number
emp_name: to store the employee name
design: to store the employee designation
Member functions:
Employee( ) : default constructor
Employee( … ) : parameterized constructor to assign values to employee number, 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:
Salary(…) : parameterized constructor to assign values to data members.
void calculate( ) : calculate the employee’s net salary according to 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 the Net salary.

Specify the class Employee giving details of the constructors and member function void display( ).
Using the concept of Inheritance specify the class Salary giving details of constructors and the
member function void calculate( ). The main function need not be written.
[10]

Question 12

Chain is an entity which can handle at the most 50 integers. The chain enables the user to add and
remove integers from both the ends i.e. front and rear. Define a class Chain with the following
details:
Class name : Chain
Data Members:
ele[ ] : the array to hold the integer elements.
cap : stores the maximum capacity of the array.
front : to point the index of the front.
rear : to point the index of the rear.
Member functions:
Chain(int max) : constructor to initialize the data cap =max, front = rear = 0 and to
create the integer array.
void pushfront(int v) : to add integers from the front index if possible else display the
message “full from front”.
int popfront( ) : to remove the return elements from front. If array is empty then return -999
void pushrear(int v) : to add integers from the front index if possible else display the
message “full from rear”.
int poprear( ) : to remove and return elements from rear.If the array is empty then return-999

(a) Specify the class Chain giving details of the constructor andmember function void
pushfront(int), int popfront( ) , void pushrear( int) and int poprear( ). The main function
need not be written. [9]
(b)What is the common name of the entity described above? [1]

Question 13

(a) Link Lists are linear data structure. Create Algorithms for the following operations: [4]
(i) Insertion of a Node in the middle of a Link List.
(ii) Deletion of the last Node in a Link List.

(b)Answer the following from the diagram of a Binary Tree given below:

(write A,B,C,D ……… in the nodes from left to right and then solve)
1. Name the leaves of the tree. [1]
2. Write the path between A to G. [1]
3. State the level of node E. [1]

(c) For the given Binary Tree write the: [3]


1. Postorder Sequence.
2. Inorder Sequence.
3. Preorder Sequence.

Anda mungkin juga menyukai