eCareers

Computer Science 2016 Past Paper

COMPUTER SCIENCE, PAPER-I

                                                                  FEDERAL PUBLIC SERVICE COMMISSION
                                                                    COMPETITIVE EXAMINATION - 2016
                                                                  FOR RECRUITMENT TO POSTS IN BS-17
                                                                  UNDER THE FEDERAL GOVERNMENT
                                                                      COMPUTER SCIENCE, PAPER-I 

TIME ALLOWED: THREE HOURS
PART-I(MCQS): MAXIMUM 30 MINUTES

PART-I (MCQS) MAXIMUM MARKS = 20
PART-II MAXIMUM MARKS = 80

NOTE: (i) Part-II is to be attempted on the separate Answer Book.
(ii) Attempt ONLY FOUR questions from PART-II by selecting TWO questions from EACH
SECTION.
(iii) All the parts (if any) of each Question must be attempted at one place instead of at different places.
(iv) Candidate must write Q. No. in the Answer Book in accordance with Q. No. in the Q.Paper.
(v) No Page/Space be left blank between the answers. All the blank pages of Answer Book must be crossed.
(vi) Extra attempt of any question or any part of the attempted question will not be considered
 

                                                                                     PART-II
SECTION-I
Q. 2. (a) Write a program to input choice from user for temperature conversion from Fahrenheit
to Celsius or Celsius to Fahre00000000nheit. After the choice, input temperature from
user and display the converted answer. Sample execution of the program is given below;
1. Fahrenheit to Celsius
2. Celsius to Fahrenheit
Enter your choice: 1
Enter Temperature in Fahrenheit: 98
Same Temperature in Celsius: 36.7
Press Any Key to Continue....
(b) Which type of computer (supercomputers, mainframe computers, minicomputers,
microcomputers) will suit an individual? Justify your answer.
(c) Suppose you are trying to build a Student Registration System using object oriented
approach. Objective of the system is to store information of course registration of
students and their course results. In C++ syntax define following classes with suitable
attributes each having getdata( ) and showdata( ) member functions along with
suitable constructor functions;
Person, Teacher, Student, Course, Section, Allocation (containing information about
allocation of a course to a teacher in a semester), Registration (containing information
about registration of a student in course, this class will also save course result
information of the student). You can add more classes which you think suitable for the
system.

Q. 3. (a) Define a function named monthly-profit which will calculate the monthly profit on the
given investment amount. Function will take two float arguments, percent profit rate and
investment amount and return the monthly profit (float). Write function prototype,
function definition and a main program to demonstrate the functionality. Sample
execution of the program is given below. Note that monthly profit 4000 has been
calculated by the function by doing (8/100) * 50000. User can enter any values therefore
write generalized function (user variables, not given values).
Enter percent profit rate: 8
Enter investment amount: 50000
Monthly profit: 4000
Press Any Key to Continue....
(b) Explain and differentiate between volatile and non-volatile memory, giving examples.
(c) Suppose you are trying to build a Library Information System using object oriented
approach. System should be able to keep track of books issued and returned. It should be
able to calculate fine if a book is late. Currently you are required to design classes i.e. not
to write C++ code but describe which class you will define, which data members you
will add, which member functions you will include in those classes. Define only suitable
classes and suitable attributes (data members) in C++ syntax. Names of some classes are
like, Student, Teacher, Book, Issue Book etc. You can (but not required to) extend this
list of four classes if you think of some other suitable classes. 
COMPUTER SCIENCE, PAPER-I
Q. 4. (a) Define a structure to store records of Persons. We want to store only Name, age and address
of Person. Write main program to input record of one person and display ‘Young’ if its age
is less than 20 or ‘Old’ if the age is greater than 50 and ‘Middle’ if the age of person is
between 21 and 49. Sample execution of the main program is given below:
Enter Name = Kashif
Enter Age = 19
Enter Address = H 120, St: 08, KAR.
Person is YOUNG
Press Any Key to Continue ......
(b) Convert given binary numbers to Decimal, Octal and Hexadecimal.
(i) 100(2) (ii) 10100(2) (iii) 100101(2)
(c) Suppose you are designing software for a Medical Store, using object oriented
techniques. Decide and define classes (like ‘Person’, ‘Customer’, ‘Salesman’, ‘Purchase’
etc.) and their attributes in C++ or Java syntax. You are not required to write any
member functions and main programme. You must use inheritance where suitable.

SECTION-II
Q. 5. (a) Describe the followings (no description with more than three lines);
 

i. Sibling Nodes 

ii. Degree of a tree 

iii. Leaf Node

iv. Height/ Depth of a tree 

v. Binary Tree 

vi. Full Binary Tree

vii. Complete Binary Tree 

viii. Maximum number of nodes in a Binary Tree at level L.

(b) 

Find the time complexity of Binary search by resolving the recurrence (given below)
using iterative substitution method.

T(1) 

= 2 

if n =< 1

T(n) 

= 4 + T(n/2) 

if n>1
(c) Draw the given array in the form of binary tree. Then apply ‘Build-Heap’ Algorithm to
convert the given tree in the form of Max-Heap (i.e. draw final Max-heap in the form of
tree and array). Finally show execution of ‘Heap-sort’ algorithm by rewriting the Heap
array after each iteration of the algorithm.
A = {8, 14, 2, 26, 10, 12, 16, 28, 20, 7}

Q. 6. (a) Write Abstract Data Types (ADT) of Stack and Queue. Include the specifications of Add,
Delete, IsEmpty, IsFull functions along with their respective functions.
(b) For step count expressions n2 + 10 and 2n / 4 find breakeven point i.e. for which value
of n (starting from 1,2…) second expression will become greater than value of first
expression.
(c) In AVL tree balance factor of every node is -1 or 0 or +1. We can calculate the balance
factor as Height left-sub-tree – Height right-sub-tree. Construct AVL tree from the given data;
A = {8, 14, 2, 26, 10, 12, 16, 28, 20, 7}

Q. 7. (a) Draw a diagram that illustrates the process of translating a C++ source file into an
executable file. Give example of each phase depicted in your diagram of compilation
process.
(b) Compare and contrast among compiler, interpreter and assembler.
(c) Describe Software Development Life Cycle (SDLC). Explain your answer with the help
of depicting and describing different phases of pure water fall software life cycle.
(d) What is the difference between SRS document and design document? What are the
contents we should contain in the SRS document and design document.

Q. 8. (a) What are the purposes of Data Flow diagrams, Entity-Relationship diagrams? Give an
example diagram of each.
(b) Explain five properties of language using the example of English. Explain why a
software language like MiniJava meets these properties as well.
(c) Lexical analysis: Consider the following regular expression
r1 = (A | …. | Z) * (0 | …. | 9)*
Describe the language defined by r1 in English. Turn r1 into an equivalent finite
automaton. Remove ?-moves from the finite automation.
(d) What do you mean by Context Free Grammar (CFG)? Illustrate your answer with
examples. 

                                                                                          PART-II
SECTION-A
Q. 2. (a) Suppose you add two new devices to an existing five-device network. If you have a fully
connected mesh topology, how many new cable lines are needed? If, however, the
devices are arranged in a ring, how many new cable lines are needed?
(b) Transmission media are not perfect because of imperfections and impairments in the
signal sent through the medium. Signals at the beginning and at the end of the
medium are not the same. Discuss in detail the impairments in the transmission medium.
(c) Whenever multiple devices are used in a network, the problem arises that how to
connect them to make one-on-one communication possible. Switching is the best solution
for this kind of problem. A switched network consists of a series of inter-linked nodes
called switches. Explain briefly the methods of switching used by computer networks.

Q. 3. (a) RAID is a physical disk drives viewed by the operating system as a single logical drive,
where data are distributed across the physical drives of an array. Explain different levels
of RAID? Elaborate your answer with suitable diagrams.
(b) The basic function performed by a computer is execution of a program, which
consists of set of instructions stored in memory. The processor required for a single
instruction is called an instruction cycle. Elaborate basic instruction cycle used by
modern computer systems. Also add diagrams for explanation.
(c) Differentiate between Reduced Instruction Set Computers (RISC) and Complex
Instruction Set Computers (CISC) architectures.

Q. 4. (a) Deadlock prevention algorithms prevents deadlock by restraining how requests can be
made, the restrain ensure that at least one of the necessary conditions for deadlock
cannot occur and hence, that deadlock cannot hold. Explain the Banker’s Algorithm for
deadlock avoidance.
(b) Central Processing Unit (CPU) scheduling deal with the problem of deciding which of
the processes in the ready queue is to be allocated to the CPU. What are the pros and
cons of Multilevel Queue Scheduling and Multilevel Feedback Queue Scheduling?
(c) What do you know about Process Control Block? Discuss its components in detail.

SECTION-B 
Q. 5. (a) A complete SELECT statement embedded within another SELECT statement. The
results of this inner SELECT statement (or subselect) are used in the outer statement to
help determine the contents of the final result. Differentiate among following nested
sub-queries operators “IN”, “ANY” and “ALL”.
(b) Explain how Pattern match search condition (LIKE/NOT LIKE) can be used in
SELECT statement part of SQL in database management system.
(c) Differentiate between Data Manipulation Language (DML) and Data Definition
Language (DDL) of structured query language (SQL) in database management system
(DBMS). 
 

Q. 6. (a) A transaction is a unit of program execution that accesses and possibly updates various
data items. Usually, a transaction is initiated by a user program written in a data
manipulation language. Explain the ACID property of transaction processing.
(b) Distinguish among functional dependency, Fully functional dependency and Transitive
dependency.
(c) A trigger is a statement that the system executes automatically as a side effect of a
modification to the database. What are the different forms of triggers and how they are
defined?

Q. 7. (a) Write down a short note on Array versus Matrix Operations
(b) Differentiate between CMY and CMYK Colour Models used in digital image
processing.
(c) Explain the Boundary Extraction Algorithm used for basic morphology.

Q. 8. (a) Explain the principals of requirement engineering of web applications.
(b) Elaborate the term E-Commerce. Discuss in detail about the effects of
E-Commerce in Islamic Banking in Pakistan.
(c) What are the components of Generic web application architecture?