(Paper) Sample Paper Class - XII Computer Science 2008-5

Disclaimer: This website is NOT associated with CBSE, for official website of CBSE visit - www.cbse.gov.in


Functions with array , Searching & sorting (6 or 7 marks)

1.       Write UDF in C++ which accepts an integer array and its size as arguments/ parameters and assign the elements into a 2 D array of integers in the following format :

            if the array is 1,2,3,4,5

             The resultant 2D array is given below

            1 0 0 0 0

            1 2 0 0 0

            1 2 3 0 0

            1 2 3 4 0

            1 2 3 4 5

 

 

 

2.       Write UDF in C++ to print the row sum and column sum of a matrix.

 

 

 

3.       Write UDF in C++ to find a name from a list of names using binary search method.

 

4.       Write UDF in C++ to insert an element in a one-dimensional sorted array in such a way that after insertion the array remain sorted.

 

 

 

5.       Write UDF in C++ to delete a name from a list of names.

 

 

 

6.        Write UDF in C++ to sort an array in ascending order using bubble sort.

 

 

 

7.       Write UDF in C++ to sort an array (storing names) in ascending order using insertion sort.

 

 

 

8.       Write UDF in C++ to sort an array in ascending order using Selection sort.

 

 

 

9.       Suppose A, B, C are the array of integers having size m, n, m+n respectively .The elements of array A appear  in ascending order, the       elements of array B appear in descending order. Write a UDF in C++ to produce third array C after merging arrays A and B in ascending order. Take the arrays A, B and C as argument to  the function.

 

 

 

10.   Write a function findsort(),to find whether the given integer Array arr[10] is sorted in ascending order or descending order or is not in order. The function should retun “A” for ascending , “D” for descending and “N” for no order.

 

 

 

11.   Write a function in C++ which accepts an integer array and its size as arguments/parameters and exchanges the values of first half side elements with the second half side elements of the array.

example : if the array is 8,10,1,3,17,90,13,60 then rearrange the array as 17,90,13,60,8,10,1,3

 

 

 

12.   Write a function in C++ which accepts an integer array and its size as arguments/parameters and exchanges the values at alternate locations .

example : if the array is 8,10,1,3,17,90,13,60 then rearrange the array as 10,8,3,1,90,17,60,13

 

 

 

13.   Write a function in C++ which accepts an integer array and its size as arguments/parameters and reverse the contents

       of the array without using any second array.

 

 

 

14.   Write a function in C++ which accepts an integer and a double value as arguments/parameters. The function should return a value of type double and it should perform sum of the following series :

x-x2/3! + x3/5! – x4/7! + x5/9! …… upto n terms

 

 

 

14.  Assume an array E containing elements of structure employee is required to be arranged in descending order of salary. Write a C++ function to arrange the same with the help of bubble sort , the array and its size is required to be passed as parameters to the function. Definition of structure Employee is as follows :

           
            struct employee

                        {

                                    int Eno;

                                    char name[25];

                                    float salary;

                        };

15.   Given two arrays of integers X and Y of sizes m and n respectively . Write a function named MERGE() which will  produce a third array Z , such that the following sequence is followed .

(i)      All odd numbers of X from left to right are copied into Z from left to right.

(ii)  All even numbers of X from left to right are copied into Z from right to left.

(iii)  All odd numbers of Y from left to right are copied into Z from left to right.

(ii)  All even numbers of Y from left to right are copied into Z from right to left.

Address calculation in 2D array ( 2 or 4 marks)

  1. An Array Val[1..15][1..10] is stored in the memory with each elements requiring 4 bytes of storage. If the base address of array  Val is 1500, determine the location of Val [12][9] when the array Val is stored

    (i) row wise    
    (ii) column wise.





  2. A 2-d array defined as A[4..7, -1..3] requires 2 words of storage space for each element. calculate the address of A[6,2], given the base address as 100, also calculate the address of A[7,0 If the array is stored in  row major order







  3. If an array B[11][8] is stored as column wise and B[2][2] is stored at 1024 and B[3][3] at 1084. Find out the base address, size of an element and address of B[5]3].





  4. An array ARR[35][15] is stored in the memory along the row with each of its element occupying 4 bytes. Find out the base address and the address of an element ARR[20][5], if the location ARR[2][2] is stored at the address 3000.





  5. An array S[40][30] is stored in the memory along the row with each of the element occupying 4 bytes, find out the memory location for the element S[15][5], if an element s[20][10] is stored at memory location 5700





  6. An array ARR[10][20] is stored in the memory with each element occupying 2  bytes of  space. Assuming the base address of ARR to be 800,compute the address of ARR[9][11], when the array is stored as :  

           i) Row wise               ii) Column wise                             

 

 

Prefix , post fix , infix notation (2 marks)

1.      Evaluate the following postfix expression using a stack and show the Contents of stack after execution of each operation:

(i)                 50,40,+, 18,14,-,4,*,+

(ii)                100,40,8,+,20,10,-,+,*

(iii)              5,6,9,+,80,5,*,-,/

(iv)              120,45,20,+,25,15,-,+,*

(v)               20,45,+,20,10,-,15,+,*

(vi)              TRUE,FALSE, TRUE FALSE, NOT, OR, TRUE , OR,OR,AND

 

2.      Give postfix form of the following expression:

(i)                 A*(B+(C+D)*(E+F)/G)*H

(ii)                A+[(B+C)*(D+E)*F]/G

(iii)              A*(B+D)/E-F-(G+H/K)

(iv)              ((A-B)*(D/E))/(F*G*H)

(v)               (True && false) || !(false||true)

 

 

3.      Write the equivalent infix expression for :

i.         10,3,*,7,1,-,*,23,+

ii.       /+a*bc-c*db

iii.      abc*+cdb*-/

 

 

Stack & Queue (6 or 7 marks)

Q1. class stack

            {            int data[10];

                        int top;

                        public:

                        Stack( ) { top=-1;}

                        void push ( ); // to push an element into the stack

                        void pop ( ) ; // to pop an element into the stack

                        void display( );// to display all the elements from the stack

            };

            complete the class with all function definition.

 

 

Q2.      Write a function in  C++ to perform insert operation in dynamically allocated Queue containing names   of students.

 

 

Q3.      Write a function in C++  to perform push operation in a dynamically allocated stack containing admission number of students. Also  declare the relevant class/ structure and pointers.

 

 

Q4.      Write a function in C++ to perform a DELETE operation in a dynamically allocated queue considering              the following description:

            Struct Node

            {            float U,V;

                        Node *Link;

            };

            class QUEUE

            {            Node *Raer, *Front;

                        Public:

                        QUEUE( ) { Rear =NULL; Front= NULL;}

                        Void INSERT ( );

                        Void DELETE ( );

                        ~QUEUE ( ); 

            }

 

 

Q5.      Write a function in C++ to perform a PUSH operation in a dynamically allocated stack considering the             following :

            Struct Node

            {            int X,Y;

                        Node *Link;

            };

            class STACK

            {            Node * Top;

                        Public:

                        STACK( ) { TOP=NULL;}

                        Void PUSH( );

                        Void Pop( );

                        ~STACK( );

            };

 

 

Q6.      Define function stackpush( ) to insert nodes and stackpop( ) to delete nodes, for a linklist implemented             stack having the following structure for each node:

            Struct Node

            {            char name[20];        

                        int age;

                        Node *Link;

            };

            class STACK

            {            Node * Top;

                        Public:

                        STACK( ) { TOP=NULL;}

                        Void stackpush( );

                        Void stackpop( );

                        ~STACK( );

            };

 

 

Q7. Consider the following portion of a program which implements passengers Queue for a bus.

            Write the definition of function Insert , to insert a new node in the queue with required information.

            Struct Node

            {            float U,V;

                        Node *Link;

            };

            class QUEUE

            {            Node *Raer, *Front;

                        Public:

                        QUEUE( ) { Rear =NULL; Front= NULL;}

                        Void INSERT ( );

                        Void DELETE ( );

                        ~QUEUE ( ); 

            };

 

 

Q8.      Give the necessary declaration of a linked list implemented queue containing float type values . Also     write a user defined functions in C++ to add and delete a float type number in the queue.

     

 

< Pervious

 Next >


  Go To Page :   1,   2,   3,   456   >>