CSS Computer Science Past Paper 2022

    Optional · 80 marks · three hours

    WhatsApp

    Original FPSC paper

    Download

    Instructions specific to this paper

    • Attempt ONLY FOUR questions from PART-II, by selecting TWO questions from EACH
    • Attempt ONLY FOUR questions from PART-II by selecting TWO questions from EACH SECTION.

    Questions

    1. Q. 28 marks

      (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”. (b) Write the differences between Computer Science, Software Engineering, Information (6) Technology, Information Systems, Computer Engineering, and Bioinformatics. (c) Write output of the following C++ code assuming that there is no error in the code: (6) 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;

    2. Q. 38 marks

      (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; } (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: (6) int v1 = 55; int* p1 = &v1; int* p2; p2 = p1; *p1 = 20; cout << *p2 << endl; cout << v1 << endl;

    3. Q. 412 marks

      (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. (b) Write output of the following C++ code assuming that there is no error in the code: (8) #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; }

    4. Q. 510 marks

      (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): (1) by default, the circle will be of radius 1 inch and centered at (0,0) (2) with a given value for radius, centered at (0,0) (3) by providing the center coordinates and the radius is assumed to be 1 (4) by providing the radius and the coordinates for the center (5) 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. (b) What is a virtual function in C++? Using an example, explain how does a virtual (10) function mechanism work.

    5. Q. 68 marks

      (a) Complete the following recursive function using C++ to calculate k raised to the power n, i.e., kn. Use of any built-in (library) function is not allowed. int power(int k, int n) { // write your code here } (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. (4) 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; }

    6. Q. 78 marks

      (a) The following function performs binary search on a given array of n numbers: 1. int binarySearch (int x, int v[], int n) 2. { 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. (b) What is the difference between white box (Glass Box) testing and black box testing? (6) Which of these testing techniques helps in identifying more errors in a system under evaluation? Explain. (c) Requirements can be specified using natural language specification. Write one user (6) requirement and one system requirement for the following function: Automatically highlight incorrect spelling mistakes in an MS Word document.

    7. Q. 88 marks

      (a) Draw a finite automaton over ∑ = {0, 1} that accepts all binary strings starting and ending with 0 (single-0 string counts). (b) Write a regular expression over ∑ = {0, 1} to represent a set of strings that begin with (6) 101 and end with 110. (c) Write a Context-Free Grammar (CFG) over ∑ = {0, 1} for the language of all binary (6) a b c strings of the form 0 1 0 where a+c=b.

    Standard FPSC instructions

    Printed on this and every CSS paper.

    • Part-II is to be attempted on the separate Answer Book.
    • All the parts (if any) of each question must be attempted at one place instead of at different places.
    • Write Q. No. in the Answer Book in accordance with Q. No. in the question paper.
    • No page/space be left blank between the answers. All the blank pages of the Answer Book must be crossed.
    • Extra attempt of any question or any part of the attempted question will not be considered.

    New papers and past-paper breakdowns, as they drop

    We post CSS and PMS prep every day to 40,000+ aspirants.