Documenti di Didattica
Documenti di Professioni
Documenti di Cultura
Paper – 2
(PRACTICAL)
(Planning Session: One hour)
(Examination Session: Two hour)
(Maximum Marks: 100)
INSTRUCTIONS
As it is practical examination, the candidate is expected to do the following:
(a) Indicate the required inputs for the problem. State the method/formula for solving the
problem. Mention the required output for the selected problem.
(b) Write an algorithm for the selected problem.
(c) Write a program in C++/Java. Document your program by using mnemonic names and
comments. Test run the program on the computer using the given test data and get a print
out (hard copy) in the format specified in the problem alongwith the program listing.
Question 1.
Read in an integer n (which can be at the most 50). Then read in n integers one by one
and store them in an array data from index 0 to n-1. Now rearrange the integers in data in
the following way:
Find the minimum value in data and put it in the centre of the array (that is at n/2); find
the next smallest value in data and put it to its left; then the next smallest and place it to
its right and so on alternating left and right until all integers in data are done. For
example if the array is initially:
However, since there is very little memory, you are not allowed to use any other array
apart from data.
Test your program for the following data and any other sample data that you can
visualize:
Sample data:
Input:
Number of integers: 5
Integers: 8,10,3,6,7
Output:
Original array
8,10,3,6,7
Rearranged array
8,6,3,7,10
Input:
Number of integers: 8
Integers: 1,2,3,4,5,6,7,8
Output:
Original array
1,2,3,4,5,6,7,8
Rearranged array
8,6,4,2,1,3,5,7
Design a program that reads a quotation from a data file “quote.txt”. This file has already
been created for you. It outputs the total number of times that vowel pairs occur in the
data file. It also outputs the number of times each vowel pair occurs in the quotation.
Output the result in the format given below:
For Example:
Input data:
Output:
a e i o u
a 0 0 1 0 0
e 1 2 0 0 0
i 0 2 0 0 0
o 0 0 0 1 0
u 0 0 1 0 0
Question 3.
Design a program that accepts an infix expression character by character and then
converts it into postfix expression. To mark the end of input, any special character, i.e.,
“;” can be used.
Test your program for the following data and any other sample data that you can
visualize:
(A - B) * (C / D) + E (terminated by ;)
Output:
Postfix expression
AB – CD / * E +
Sample data:
A – B * C (terminated by ;)
Output:
Postfix expression
ABC * –
Sample data:
A * (B + (C + D) * (E + F) / G) * H (terminated by ;)
Output:
Postfix expression
ABCD + EF + * G / + * H *