Not yet checked 6 of 7 questions have not yet been compared with the official paper.
Section A
Q. 2
(a)Using C++ write a function pattern (int n) that produces the following output. Pay special attention to the spaces and clearly state the return type of the function. Note that the following is just an example; your solution should work for any input "n". 1 12 123 1234 1 2 3 4 5 1 2 3 4 5 6 1234567 [8]
(b)Write the differences between Computer Science, Software Engineering, Information Technology, Information Systems, Computer Engineering, and Bioinformatics. [6]
(c)Write output of the following C++ code assuming that there is no error in the code: int ary[4] = {1,2,3,4}; int *p1 = ary + 3; cout << p1[-2] << endl; int *p2 = &p1[-2]; *p2 = 10; cout << ary[1] << endl; [6]
Not yet checked
(20)
Q. 3
(a)Complete the C++ code below to find the number of distinct elements in an array in O(n) time (linear time complexity) where “n” is the number of elements in the array. For example, if the array is {3,1,3,8,2,1,8,2}, the number of distinct elements is 4 (to be returned from the function below) as the distinct elements are {1,2,3,8}. All the elements of the array are in the range [1,100]. Also, n >> 100 (n is significantly greater than 100). int numDistinctElements(int[] array, int n) { int count = 0; // write your code here return count; } [8]
(b)Write a detailed note on the principles of Information Security/ Privacy. [6]
(c)Write output of the following C++ code assuming that there is no error in the code: int v1 = 55; int* p1 = &v1; int* p2; p2 = p1; *p1 = 20; cout << *p2 << endl; cout << v1 << endl; [6]
Not yet checked
(20)
Section B
Q. 4
(a)Write a C++ program to check whether a string is palindrome or not. A palindrome is a string, which when read in both forward and backward ways is the same, e.g., “radar”, "madam" etc. Note that these are only examples, you will take the string as an input from a user using the cin.getline function and your code should be general that can work on any input string. You are not allowed to use any string-related library function. [12]
(b)Write output of the following C++ code assuming that there is no error in the code: #include <iostream.h> int main() { int a = 12, b = 25; cout << "a = '" << a << endl; cout << "b = " << b << endl; cout << "a | b = " << (a | b) << endl; return 0; } [8]
Not yet checked
(20)
Q. 5
(a)Define a class called Circle using C++. An object of the class Circle can be created using any of the following ways (implement all the ways): by default, the circle will be of radius 1 inch and centered at (0,0) with a given value for radius, centered at (0,0) by providing the center coordinates and the radius is assumed to be 1 by providing the radius and the coordinates for the center by providing another Circle object to initialize. In the main function (driver program), separately create 5 different objects of the Circle class using a different way of object creation (mentioned above) for each of them. [10]
(b)What is a virtual function in C++? Using an example, explain how does a virtual function mechanism work. [10]
(20)
Q. 6
(a)Complete the following recursive function using C++ to calculate k raised to the power n, i.e., k n . Use of any built-in (library) function is not allowed. int power(int k, int n) { // write your code here } [8]
(b)Compare and contrast the DES, AES, and RSA encryption algorithms. [8]
(c)Write the time complexity of the following C++ code in terms of Big-O notation. Assume that there is no error in the code. int isPrime (unsigned int n) // returns true if the argument value is prime and // false otherwise { for (unsigned int i = 2; (i * i) < n; i++) { // if i is a factor, then not prime if (n % i == 0) return 0; } // if we end loop without finding factor then // number must be Prime return 1; } [4]
Not yet checked
(20)
Part II
Q. 7
(a)The following function performs binary search on a given array of n numbers: 1. 2. int binarySearch (int x, int v[], int n) { 3. int low, high, mid; 4. low = 0; 5. high = n - 1; 6. while (low <= high) 7. { 8. mid = (low + high )/2; 9. if (x < v[mid]) 10. high = mid - 1; 11. else if (x > v[mid]) 12. low = mid + 1; 13. else return mid; 14. } 15. return -1; 16. } Draw control flow graph for the above function. Also find its cyclomatic complexity. [8]
(b)What is the difference between white box (Glass Box) testing and black box testing? Which of these testing techniques helps in identifying more errors in a system under evaluation? Explain. [6]
(c)Requirements can be specified using natural language specification. Write one user requirement and one system requirement for the following function: Automatically highlight incorrect spelling mistakes in an MS Word document. [6]
Not yet checked
(20)
Q. 8
(a)Draw a finite automaton over ∑ = {0, 1} that accepts all binary strings starting and ending with 0 (single-0 string counts). [8]
(b)Write a regular expression over ∑ = {0, 1} to represent a set of strings that begin with 101 and end with 110. [6]
(c)Write a Context-Free Grammar (CFG) over ∑ = {0, 1} for the language of all binary strings of the form 0 a 1 b 0 c where a+c=b. [6]
The 2022 CSS Computer Science paper set by the FPSC. Question wording only; questions marked “Not yet checked” have not been compared with the official paper yet.
Disclaimer Prep Right is independent and not affiliated with FPSC.