Formatting page ...
VIKAS BHARTI SCHOOL BHARTIPURAM, GORAKHPUR Mock Trials 2019 (Set - A) COMPUTER SCIENCE (Form Sc) PAPER 1 (Theory) (Maximum marks: 70) (Time allowed: 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 six questions from Part II, choosing two 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 (20 Marks) Answer ALL questions While answering questions in this part. Indicates briefly your working and reasoning, wherever required. Question: 1 a) Show that X ~ (Y X) is a Tautology. [1] b) Calculate the time complexity using Big O notation for the following given code segment: [1] for (int i=0;i<n;i++) s+=k; c) If F(A, B, C) = A (BC +B C), then find F . [1] d) Verify the following proposition with the help of a Truth Table. [1] P (~ P Q ) = P Q e) Convert the following infix expression into its postfix form [1] X + ( Y + Z ) + ( ( P + Q) * R ) / S Question: 2 a) The array D[m][n] is stored with each element requiring 4 bytes of storage. If the base address at D[1][1] is 1500 and the address at D[4][5] is 1608. Determine the number of rows of the matrix when the matrix is stored in Column Major Wise. [2] b) State how a binary tree is a recursive data structure? [2] c) Write two differences between words extends and implements. d) If (x y) then write its: i. ii. [2] [2] Converse Contra positive e) Differentiate between a constructor and a method of a class. [2] Question: 3 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/ working. [5] void Recur(int n ) { if (n > 1 ) { System.out.print ( n + ); if(n%2!=0) {n=3*n+1; System.out.print ( n + ); } Recur(n/2 ) ;}} Part II (50 Marks) Answer SIX questions in this Section, Choosing two questions from Section A, two from Section B and two from Section C. Section A Answer any two questions Question: 4 The Past Pupil Association of a University Computer Science Department is organizing a reunion function at the campus. The invitation card is to be used to a person if any one of the following conditions must be satisfied: The person is an ex student of the department and had passed out in 1995. OR The person is not an ex student of the same department but passed out from the university in 1995 and has made a contribution of Rs. 2000. The inputs are: E : The person is ex student of the department. U : The person is not an ex student of the department, but a student of the same university. P : The person passed out in 1995. S : The person contributes Rs. 2000. Output: I Denotes the invitation card is issued. [1 indicates Yes and 0 indicates No in all cases] a) Draw the truth table for the inputs and outputs given above and write the SOP expression for X( E, U, P, S ). [5] b) What is a decoder? Draw the logic diagram for 3 to 8 decoder. [3] c) State whether the following expression is a Tautology, Contradiction or a Contingency, with the help of a truth table: [2] (X = >Z) ~ [(X= >Y) (Y = >Z)] Question: 5 a) Given the Boolean function F(X, Y, Z, W)= (3,4,5,6,7,10,11,14,15) Use Karnaugh s map to reduce the given 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] b) Verify algebraically if X Y Z + X Y Z+ X YZ + X YZ + XY Z +XY Z = X +Y [3] c) Differentiate between wff and proposition. [2] Question: 6 a) Given the Boolean function F(A, B, C, D)= (0,2,4,8,9,10,12,13) Use Karnaugh s map to reduce the given function F, using the 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] a) Draw the truth table and logic diagram of a full adder. ` [5] 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. Flow-charts and algorithms are not required. The programs must be written in java. Question: 7 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: N : number to be converted Member functions : Change ( ) : constructor void input ( ) : accepts integer to be converted to base 16. void hexadeci ( int x) : to convert decimal integer to hexadecimal form void decihexa( ) : to convert hexadecimal back to decimal integer. Void display ( ) : to display hexadecimal and decimal values Specify the class change giving the details of the constructor and the functions void input( ), void hexadeci(int) , void decihexa( ) and void display( ). The main function need not be written. [10] Question: 8 You are given a sequence of n integers, which are called 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 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 to store the status sum to store the sum of sequence of numbers r to store the sum of 2 numbers Member functions/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 return false. Specify the class Pseudoarithmetic, giving details of the constructor( ), void accept(int) and Boolean check( ). Also define the main function to create an object and call methods accordingly to enable the task. [10] Question: 9 A sequence of Fibonacci strings is generated as follows: S0 = a , S1= b , Sn=S(n-1)+S(n-2) where + denotes concatenation. Thus the sequence is: a,b, ba, bab, babba, babbabab,........ n terms. Design a class FiboString to generate Fibonacci strings. Some of the members of the class are given below: Class name : FiboString Data members/ instance variables: X : to store the first string Y : to store the second string Z : to store the concatenation of the previous tow string N : to store number of the terms Member methods/functions: FiboString() : constructor to assign x= a , y= b and z= ba void accept() : to accept the number of terms void generate(): to generate and print the Fibonacci strings. The sum of ( + i.e. concatenation) first two strings is the third string. e.g. a is frist string and b is secnd string then the third string will be ba and the fourth will be bab and so on. Specify the class FiboString, giving details of the constructor(), void accept() and void generate(). Define the main ( ) function to create an object and call the functions accordingly to enable the task. [ 10 ] Section C Attempt any TWO questions from this section 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 comments in the program and mnemonic names or pseudo codes for algorithm. The programs must be written in Java. The algorithm must be written in general/ standard form wherever required/ specified. (Flow charts are not required) Question : 10 A super class Record has been defined to store the names and ranks of 50 students. Define a sub class Rank to find the highest rank along with the name. The details of both classes are given below: Class name : Record Data members/Instance variables: name[ ] rnk[ ] : to store the names of students : to store the ranks of students Member methods/Functions: Record() : constructor to initialize data members void readvalues() : to store names and ranks void display() : displays the names and the corresponding ranks class name : Rank Data members Index : integer to store the index of the topmost rank Member functions Rank() : constructor to invoke the base class constructor, to initialize index to 0. void highest(): finds the index location of the topmost rank and stores it in index without sorting the array [5] void display() : displays the name and ranks along with the name having the topmost rank. Specify the class Record giving details of the constructor(), void readvalues(), void display(). Using the concept of inheritance, specify the class Rank giving details of constructor(), void highest() and void display(). The main function and algorithm need not be written. [5] Question 11. Stack is a kind of data structure which can store elements with the restriction that an element can be added or removed from the top only. The details of class Stack are given below: Class name : Stack St [ ] : the array to hold names. Size : the maximum capacity of the string array top : the index of the topmost element of the stack ctr : to count the number of elements of the stack Stack() : default constructor Stack(int cap) : constructor to initialize size=cap and top=-1 void pushname(String n) : to push a name into the stack. If the stack is full, display Member functions/methods: the message overflow . String popname() : removes a name from the top of the stack and returns it. If the stack is empty, display the message underflow . void display() : Display the elements of the stack. a) Specify class Stack giving details of the constructors(), void pushname(String n), String popname() and void display(). The main function and algorithm need not be written. [4] b) Under what principle does the above entity work? [1] Question 12. a) A linked list is formed from the objects of the class, class Node [2] { int info; Node link; } Write an algorithm OR a method for deleting a node from a linked list. The method declaration is given below: void deletenode(Node start) b) Answer the following from the diagram of a Binary tree given below: i) ii) iii) Write the postorder traversal Name the leaves of the tree Height of the tree [1] [1] [1] Mock Trials 2019/set-A/Form sc/SKG/004
|