Upload
others
View
9
Download
0
Embed Size (px)
Citation preview
420
Marking Scheme — Computer Science
General Instructions :
The answers given in the marking scheme are SUGGESTIVE, Examiners are requested to
award marks for all alternative correct Solutions/Answers conveying similar meaning.
All programming questions have to be answered with respect to C++ Language for Section
A and Python for Section B (All presently supported versions of compilers/interpreters
should the considered).
In C++/Python, ignore case sensitivity for identifiers (Variable / Functions / Structures /
Class Names) unless explicitly specified in question.
In SQL related questions:
– Both ways of text/character entries should be acceptable. For example: "AMAR"
and 'amar' both are acceptable.
– All date entries should be acceptable for example: 'YYVY-MM-DD', 'YY-MM-
DD', 'DD-Mon-YY', UDD/MM/YY" , 'DD/MMIYY', 'MM/DD/YY", 'MM/DD/
YY' and {MM/DD/YY} are correct.
– Semicolon should be ignored for terminating the SQL statements.
– Ignore case sensitivity for commands.
– Ignore headers in output questions.
QUESTION PAPER CODE 91/1EXPECTED ANSWERS
Section-A(Only for C++ Candidates)
1. (a) Find the correct identifiers out of the following, which can be used for naming
variable, constants or functions in a C++ program: 2
While, for, Float, new, 2ndName, A%B, Amount2, _Counter
421
Ans While, Float, Amount2,_Counter
(½ Mark for each correct identifier)
Note:
Deduct ½ Mark for writing additional incorrect identifier(s)
No marks to be awarded if all the identifiers are mentioned
(b) Observe the following program very carefully and write the names of
those header file(s), which are essentially needed to compile and execute the
following program successfully: 1
typedef char TEXT [80];
void main ()
{
TEXT Str[] = "Peace is supreme";
int Index=0;
while (Str[Index] !='\0')
if (isupper(Str[Index]"
Str[Index++]='#';
else
Str[Index++]='*';
puts (Str);
}
Ans ctype, stdio
(½ Mark for each correct header file)
Note:
Ignore any additional header file(s)
422
(c) Observe the following C++ code very carefully and rewrite it after removing
any/all syntactical errors with each correction underlined. 2
Note: Assume all required header files are" already being included in the
program.
#Define float Max=70.0;
Void maine)
{
int Speed
char Stop='N';
cin>>Speed;
if Speed>Max
Stop='Y';
cout<<Stop<<end;
}
Ans #define Max 70.0 //Error 1,2,3
void main () //Error 4
{
int Speed ; //Error 5
char Stop=' N' ;
cin>>Speed;
if (Speed>Max) //Error 6
Stop=' Y' ;
cout<<Stop<<endl; //Error 7
}
423
(½ Mark for each correction upto a maximum of 4 corrections)
OR
(1 Mark for only identifying any 4 errors, without suggesting
corrections)
(d) Write the output of the following C++ program code: 2
Note : Assume all required header files are already being included in the
program.
void Position(int &Cl, int C2=3)
{
C1+=2;
C2+=Y;
}
void main()
{
int Pl=20, P2=4;
Position(Pl);
cout<<P1<<","<<P2<<endl;
Position(P2,Pl);
cout<<Pl<<","<<P2<<endl;
}
Ans 22, 4
22, 6
(½ Mark for each correct value of output)
424
Note:
Deduct V2 Mark for not considering any or all end/(s) at properp/ace(s)
Deduct 'l'2 Mark for not considering any or all ',' at properplace(s)
OR
(Full 2 marks to be awarded for mentioning Syntax Error ORundeclared variable Y)
(e) Write the output of the following C++ program code: 3
Note: Assume all required header files are already being included in the
program.
class Calc
{
char Grade;
int Bonus;
public:
Calc() {Grade='E';Bonus=0;}
void Down(int G)
{
Grade-=G;
}
Void Up (int G)
{
Grade+=G;
Bonus++;
425
}
void Show()
{
cout<<Grade<<"#"<<Bonus<<end1;
}
};
void main()
{
Calc c;
C.Down(2);
C. Show();
C.Up(7);
C.Show();
C.Down(2);
C. Show();
}
Ans C#0
J#l
H#l
(1 Mark for each correct line of output)
Note:
Deduct ½ Mark for not considering any or all end/(s) at properplace(s)
Deduct ½ Mark for not writing any or all # symbol(s)
OR
426
(Full 3 marks to be awarded if undeclared object C OR ERROR isidentified)
(f) Study the following program and select the possible output(s) from the options(i) to (iv) following it. Also, write the maximum and the minimum values thatcan be assigned to the variable NVM. 2
Note:
– Assume all required header files are already being included in theprogram.
– random(n) function generates an integer between 0 and n - 1.
void main()
{
randomize();
int NOM;
NOM=random(3)+2;
char TEXT[]="ABCDEFGHIJK";
for (int I=1;I<=NOM; I++)
{
for(int J=NUM; J<=7iJ++)
cout<<TEXT[J];
cout<<end1;
}
}
(i) FGHI (ii) BCDEFGH (iii) EFGH (iv) CDEFGH
FGHI BCDEFGH EFGH CDEFGH
FGHI EFGH
FGHI EFGH
427
Ans (iii) and (iv) Minimum value of NUM = 2
Maximum value of NUM = 4
(½ Mark for writing option (iii) )
(½ Mark for writing option (iv) )
Note: Deduct V2 mark for writing each additional option along with
both correct options
(½ Mark for writing correct Minimum value of NUM)
(½ Mark for writing correct Maximum value of NUM)
2. (a) What is a copy constructor? Give a suitable example in C++ to illustrate with
its definition within a class and a declaration of an object with the help of it. 2
Ans A copy constructor is an overloaded constructor in which an object of the
same class is passed as reference parameter.
class Point
{
int x;
public:
Point () {x=0;}
Point (Point &p) // Copy constructor
{x = p.x;}
:
} ;
void main ()
{
Point p1;
428
Point p2(p1);//Copy constructor is called here
//OR
Point p3=pl;//Copy constructor is called here
}
(1½ Mark to be awarded if the copy constructor is explained with an
appropriate example)
OR
(1 Mark for correct explanation of copy constructor only without an
example)
(½ Mark for correct declaration of an object)
(b) Observe the following C++ code and answer the questions (i) and (ii) : 2
class Traveller
{
long PNR;
char TName[20];
public :
Traveller() //Function 1
{cout<<"Ready"<<endl;}
void Book(long P,char N[]) //Function 2
{PNR = P, strcpy(TName, N);}
void Print() //Function 3
{cout<<PNR << TName <<end1;}
~Traveller() //Function 4
cout<<"Booking cancelled"<<endl;
429
};
(i) Fill in the blank: statements in Line 1 and Line 2 to execute Function 2
and Function 3 respectively in the following code: 1
void main()
{
Traveller T;
___________ //Line 1
___________ //Line 2
}//Stops here
Ans T.Book(1234567,"Ravi"); //Line 1
T.Print(); //Line 2
(½ Mark for writing each correct Function)
(ii) Which function will be executed at l//Stops here? What is this function
referred as ? 1
Ans Function 4
OR
~Traveller()
It is a Destructor function.
(½ Mark for writing Function 4 or - Traveller())
(½ Mark for referring Destructor)
(c) Write the definition of a class PIC in C++ with following description: 4
Private Members
- Pno //Data member for Picture Number (an integer)
- Category//Data member for Picture Category (a string)
430
- Location//Data member for Exhibition Location (a string)
- FixLocation //A member function to assign
//Exhibition Location as per category
//as shown in the following table
Category Location
Classic Amina
Modern Jim P1aq
Antique Ustad Khan
Public Members
- Enter() //A function to allow user to enter values
//Pno, category and call FixLocation() function
- SeeAll() //A function to display all the data members
Ans class PIC
{
int Pno;
char Category[20];
char Location[20];
void FixLocation();
public:
void Enter();
void SeeA11();
} ;
void PIC::FixLocation()
{
431
if (strcmpi (Category,"Classic")==0)
strcpy(Location,"Amina") ;
else if(strcmpi(Category,"Mbdern")==O)
strcpy(Location,"Jim Plaq");
else if strcmpi (Category, "Antique") ==0)
strcpy(Location,"Ustad Khan");
}
void PIC::Enter()
{
cin>>Pno;gets(Category) ;
FixLocation() ;
}
void PIC:: SeeA11()
{
cout<<Pno<<Category<<Location<<endl;
}
(½ Mark for correct syntax for class header)
(½ Mark for correct declaration of data members)
(1 Mark for correct definition of FixLocation())
(1 Mark for correct definition of Enter() with proper invocation ofFixLocation() function)
(1 Mark for correct definition of SeeAll())
NOTE:
Deduct ½ Mark if FixLocation() is not invoked properly insideEnter() function
432
No marks to be deducted for defining Member Functions insidethe class
strcmp()/strcmpi() acceptable
(d) Answer the questions (i) to (iv) based on the following: 4
class Exterior
{
int OrderId;
char Address[20];
protected:
float Advance;
public:
Exterior();
void Book(); void View();
};
class Paint:public Exterior
{
int WallArea,ColorCode;
protected:
char Type;
public:
Paint ();
void PBook();
void PView();
};
433
class Bill : public Paint
{
float Charges;
void Calculate();
public :
Bill ();
void Bil11ng ();
void Print ();
};
(i) Which type of Inheritance out of the following is illustrated in the aboveexample?
– Single Level Inheritance
– Multi Level Inheritance
– Multiple Inheritance
Ans Multi Level Inheritance
(1 Mark for mentioning correct option)
(ii) Write the names of all the data members, which are directly accessiblefrom the member functions of class Paint.
Ans WallArea, ColorCode,Type, Advance
(1 Mark for correct answer)
Note: No marks to be awarded for any partial/additional answer(s)
(iii) Write the names of all the member functions, which are directly accessiblefrom an object of class Bill.
Ans Billing(), Print(), PBook(), PView(), Book(), View()
(1 Mark for correct answer)
434
Note:
No marks to be awarded for any partial/additional answer(s)
Constructors can be ignored
(iv) What will be the order ·of execution of the constructors, when an object
of class Bill is declared ?
Ans Exterior(), Paint(), Bill()
(1 Mark for correct answer)
Note: No marks to be awarded for any other order
3. (a) Write the definition of a function Alter(int A[], int N) in C++, which should
change all the multiples of 5 in the array to 5 and rest of the elements as O.
For example, if an array of 10 integers is as follows: 2
A[0] A[1] A[2] A[3] A[4] A[5] A[6] A[7] A[8] A[9]
55 43 20 16 39 90 83 40 48 25
After executing the function, the array content should be changed as follows:
A[O] A[l] A[2] A[3] A[4] A[5] A[6] A[7] A[8] A[9]
5 0 5 0 0 5 0 5 0 5
Ans void Alter (int A[ ] lint N)
{
for (int i=0;i<N;i++)
if (A[i] %5==0)
A[i]=5;
else
A[i]=0;
}
435
OR
Any other correct equivalent function definition
(½ Mark for correct loop)
(½ Mark for correct checking of divisibility of array elements by 5)
(½ Mark for correct use of else OR correct checking of non divisibility
of array elements by 5 )
(½ Mark for correct assignment of 5 and 0 for multiples and nonmultiples of 5 respectively)
(b) A two dimensional array P[20] [50] is stored in the memory along the rowwith each of its element occupying 4 bytes, find the address of the elementP[10] [30], if the element P[5] [5] is stored at the memory location 15000. 3
Ans Loc(P[I] [J]) along the row
=BaseAddress+W [(I-LBR)*C+(J-LBC)]
(where C is the number of columns, LBR=LBC=O)
LOC (P [5] [5] )
= BaseAddress + W*[I*C + J]
15000 = BaseAddress + 4*[5*50 + 5]
= BaseAddress + 4*[250 + 5]
= BaseAddress + 4*255
= BaseAddress + 1020
BaseAddress = 15000-1020 = 13980
LOC (P [10] [30]) = 13980 + 4* [10*50+30]
= 13980 + 4*530
= 13980 + 2120
= 16100
436
OR
LOC (P [ 10] [30] )
= Loc(P[5] [5])+ W[(I-LBR)*C+(J-LBC)]
= 15000 + 4[(10-5)*50 + (30-5)]
= 15000 + 4[ 5*50 + 25]
= 15000 + 4 *275
= 15000 + 1100
= 16100
OR
(Where C is the number of columns and LBR=LBC=l)
LOC (P [5] [5])
15000 = BaseAddress + W [( I-1)*C + (J-1)]
= BaseAddress + 4[4*50 + 4]
= BaseAddress + 4[200 + 4]
= BaseAddress + 4 * 204
= BaseAddress + 816
BaseAddress = 15000 - 816 = 14184
LOC (P [10] [30])
= 14184 + 4[(10-1)*50 + (30-1)]
= 14184 + 4[9*50 + 29]
= 14184 + 4[450 + 29]
= 14184 + 4*479
= 14184 + 1916
= 16100
437
(1 Mark for writing correct formula (for row major) ORsubstituting formula with correct values)
( 1 Mark for at least one step of intermediate calculation)
( 1 Mark for final correct address)
(c) Write the definition of a member function Pop( ) in C++, to delete a bookfrom a dynamic stack of TEXTBOOKS considering the following code isalready included in the program. 4
struct TEXTBOOKS
{
char ISBN[20]; char TITLE[80];
TEXTBOOKS *Link;
};
class STACK
{
TEXTBOOKS *Top;
public:
STACK() {Top=NULL;}
void Push();
void pope);
~STACK();
};
Ans void STACK::POP ()
{
if (Top!=NULL)
438
{
TEXTBOOKS *Temp;
Temp=Top;
cout<<Top->ISBN<<Top->TITLE<<"deleted"<<endl;
Top=Top->Link;
delete Temp;
}
else
cout<<"Stack EmptY"<<endl;
}
OR
Any other correct equivalent function definition
(1 Mark for checking Empty/Non-empty STACK)
( 1 Mark for assigning Top to Temp)
(1 Mark for linking the Top to next node)
(1 Mark for deleting Temp node)
(d) Write a function REVCOL (int P[] [5], int N, int M) in C++ to display
the content of a two dimensional array, with each column content in reverse
order. 3
Note: Array may contain any number of rows.
For example, if the content of array is as follows:
15 12 56 45 51
13 91 92 87 63
11 23 61 46 81
439
The function should display output as :
11 23 61 46 81
13 91 92 87 63
15 12 56 45 51
Ans void REVCOL(int P[] [5],int N,int M)
{
for(int I=N-1;I>=0; I--)
{
for(int J=0; J<M; J++)
cout<<P[1] [J];
cout<<endl;
}
}
OR
void REVCOL(int P[] [5],int N,int M)
{
for(int I=0;1<N/2;1++)
{
for(int J=0;J<M;J++)
{
int T = P[1] [J];
P[1] [J] = P[N-1-l] [J];
P[N-I-l] [J] = T;
}
440
}
for (I=0; I<N; 1++)
{
for(int J=0; J<M; J++)
cout<<P[1] [J];
cout<<endl;
}
}
(1 Mark for correct nestjng of loop(s)
(1½ Mark for correct logic for reversing the content of each column)
(½ Mark for correctly displaying the content)
Note:
N and M can be written interchangeably for number of rows
and columns
(e) Convert the following infix expression to its equivalent Postfix expression,
showing the stack contents for each step of conversion. 2
X / Y + U* (V-W)
Ans X / Y + U*(V-W) = ((X / Y) + (U*(V-W)))
Element Stack Postfix
(
(
X X
/ / X
Y / XY
441
) XY/
+ + XY/
( + XY/
U + XY/U
* + * XY/U
( + * XY/U
V + * XY/UV
- + * - XY/UV
W + * - XY/UVW
) + * XY/UVW-
) + XY/UVW-*
) XY/UVW-*+
OR
Element Stack Postfix
X X
/ / X
Y / XY
+ + XY
U + XY/U
* +* XY/U
( +*( XY/U
V +*( XY/UV
- +*(- XY/UV
442
W +*(- XY/UVW-
) +* XY/UVW-*
XY/UVW-*+
OR
Any other method for converting the given Infix expression to its
equivalent Postfix expression showing stack contents
(½ Mark for converting expression up to each operator)
OR
(1 Mark to be given for writing correct answer without showing the
Stack Content on each step)
4. (a) Write function definition for SUCCESS( ) in C++ to read the content of a text
file STORY.TXT, count the presence of word STORY and display the number
of occurrence of this word. 2
Note:
– The word STORY should be an independent word
– Ignore type cases (i.e. lower/upper case)
Example:
If the content of the file STORY.TXT is as follows:
Success shows others that we can do it. It is
possible to achieve success with hard work. Lot
of money does not mean SUCCESS.
The function SUCCESS( ) should display the following:
3
Ans voidSUCCESS ()
{
443
int count=0;
ifstream f("STORY.TXT") ;
char s[20] ;
while (!f.eof () )
{
f>>s;
if (strcmpi (s,"STORY")==0)
//OR if(strcmpi(s,"SUCCESS")==0)
count++;
}
cout<<count;
f.close () ;
}
OR
Any other correct function definition
(½ Mark for opening STORY. TXT correctly)
(½ Mark for reading each word (using any method) from the file)
(½ Mark for comparing the word with STORY OR SUCCESS)
(½ Mark for displaying correct count of STORY OR SUCCESS)
NOTE:
(½ Mark to be deducted if STORY or SUCCESS is compared withoutignoring the case)
(b) Write a definition for function Economic ( ) in C++ to read each record of a
binary file ITEMS.DAT, find and display those items, which costs less than
444
2500. Assume that the file ITEMS.DAT is created with the help of objects of
class ITEMS, which is defined below: 3
class ITEMS
{
int ID;char GIFT[20]; float Cost;
public :
void Get ()
{
cin>>CODE;gets(GIFT);cin>>Cost;
}
void See ()
{
cout<<ID<<":"<<GIFT<<":"<<Cost<<end1;
}
float GetCost() {return Cost;}.
};
Ans void Economic()
{
ITEMS I;
ifstream fin ("ITEMS.DAT", ios::binary);
while (fin.read((char *)&I,sizeof(I)))
{
if(I.GetCost()<2500)
I. See () ;
445
}
fin. close () ;
}
OR
Any other correct equivalent function definition
(½ Mark for opening ITEMS.DAT correctly)
(1 Mark for reading all records from the file)
(1 Mark for checking value of Cost < 2500 )
(½ Mark for displaying the desired items)
(c) Find the output of the following C++ code considering that the binary file
CLIENTS.DAT exists on the hard disk with records of 100 members. 1
class CLIENTS
{
int Cno;char Name[20];
public :
void In(); void Out();
};
void main()
{
fstream CF;
CF.open("CLIENTS.DAT",ios::binary|ios::in);
CLIENTS C;
CF.read((char*) &C, sizeof(C));
CF.read((char*) &C, sizeof(C));
446
CF.read((char*) &C, sizeof(C));
int POS=CF.tellg()/sizeof(C);
cout<<"PRESENT RECORD:"<<POS<<end1;
CF.close () ;
}
Ans PRESENT RECORD: 3
(1 Mark for writing PRESENT RECORD: 3)
OR
(1 Mark for writing only 3)
OR
(½ Mark for writing only PRESENT RECORD:)
Section-B
(Only for Python Candidates)
1. (a) How is_init( ) _different from _del ( ) _ ? 2
Ans _init_() is the class constructor or initialization method which is automaticallyinvoked when we create a new instance of a class
_del_() is a destructor which is automatically invoked when an object(instance) goes out of scope.
For Example:
class Sample:
def _init__(se1f) :
se1f.data = 79
print ('Data:',self.data, 'created')
def _de1 __ (self) :
print('Data: ',self.data,'deleted')
447
s = Sample ()
del s
(2 Marks for correct differentiation)
OR
(2 Marks for differentiation through example)
OR
(1 Mark for each correct definition)
(b) Name the function/method required to 1
(i) check if a string contains only uppercase letters
(ii) gives the total length of the list.
Ans (i) isupper()
(ii) len()
(½ Mark for each correct function/ method name)
(c) Rewrite the following code in python after removing all syntax error(s).
Underline each correction done in the code. 2
def Tot(Number) #Method to find Total
Sum=0
for C in Range (1, Number+1):
Sum+=C
RETURN Sum
print Tot[3] #Function Calls
print Tot[6]
Ans def Tot (Number) : #Method to find Total #Error 1
Sum=0
448
for C in range (1, Number+1) : #Error 2
Sum+=C
return Sum #Error 3
print Tot (3) #Function Call #Error 4
print Tot (6) #Error 4
(½ Mark for each correction)
OR
(1 mark for identifying all the errors, without suggesting corrections)
(d) Find and write the output of the following python code : 2
for Name in ['Jayes', 'Ramya', 'Taruna', 'Suraj']:
print Name
if Name[0]== 'T':
break
else :
print 'Finished1'
print 'Got it!'
Ans Jayes
Ramya
Taruna
Got it!
(½ Mark for each correct line)
Note:
Deduct ½ Mark for not considering any or all line breaks at properplace(s)
449
(e) Find and write the output of the following python code : 3
class Worker :
def_init_(self,id,name) : #constructor
self.ID=id
self.NAME=name
def Change(self):
self.ID=self.ID+10
self.NAME='Harish'
def Display (self,ROW) :
print self.ID,self.NAME,ROW
w=Worker(55,'Fardeen')
w.Display(l)
w.Change ()
w.Display(2)
print w.ID+len(w.NAME)
Ans 55 Fardeen 1
65 Harish 2
71
(1 Mark for each correct line)
Note:
Deduct ½ Mark for not considering any or all line break(s) at properplace(s).
(f) What are the possible outcome(s) executed from the following code? Alsospecify the maximum and minimum values that can be assigned to variable
NUMBER. 2
450
STRING="CBSEONLINE"
NUMBER=random.randint(0,3)
N=9
while STRING[N] !='L':
print STRING[N]+STRING[NUMBER]+'#',
NUMBER=NUMBER+l
N=N-l
(i) ES#NE#IO# (ii) LE#NO#ON# (iii) NS#IE#LO#
(iv) EC#NB#IS#
Ans (i) ES#NE#IO#
(iv) EC#NB#IS#
Minimum value of NUMBER = 0
Maximum value of NUMBER = 3
(½ Mark for writing option (i))
(½ Mark for writing option (iv) )
Note:
Deduct ½ mark for writing each additional option along withboth correct options
(½ Mark for writing correct Minimum value of NUMBER)
(½ Mark for writing correct Maximum value of NUMBER)
2. (a) Illustrate the concept inheritance with the help of a python code. 2
Ans class Base :
def __init__ (self):
print "Base Constructor at work ... "
451
def show (self) :
print "Hello Base"
class Der(Base) :
def __init__ (self):
print "Derived Constructor at work ... "
def display (self) :
print "Hello from Derived"
(1 Mark for base class)
(1 Mark for derived class)
(b) What will be the output of the following python code ? Explain the try and
except used in the code. 2
U=0
V=6
print 'First'
try:
print 'Second'
M=V/U
print 'Third',M
except ZeroDivisionError
print V*3
print 'Fourth'
except:
print V*4
print 'Fifth'
452
Ans First
Second
18
Fourth
The code written within try triggers the exception written after exceptZero Division Error: in case there is a division by zero error otherwisethe default exception is executed
OR
Any other correct explanation for usage of try and except
(½ Mark for first two lines of correct output)
(½ Mark for next two lines of correct output)
(½ Mark each for correct explanation of try and except)
(c) Write a class PICTURE in Python with following specifications: 4
Instance Attributes
- Pno # Numeric value
- Category # String value
- Location # Exhibition Location with String value
Methods:
- FixLocation() # A method to assign
# Exhibition Location as per Category
# as shown in the following table
Category Location
Classic Amina
Modern Jim Plaq
Antique Ustad Khan
453
- Enter() # A function to allow user to enter values
# Pno, Category and call FixLocation()method
- SeeAll()# A function to display all the data members
Ans class PICTURE:
Pno=0
Category=" "
Location=" "
def FixLocation() :
if self.Category=="Classic":
self. Location="Amina"
elif self.Category "Modern":
self.Location="Jim Plaq"
elif self.Category=="Antique":
self.Location="Ustad Khan"
def Enter() :
self.Pno=int(input("Enter Pno:"))
self.Category=input("Enter Name:")
self.FixLocation()
def SeeA11 ()
print self.Pno,self.Category,self.Location
(½ Mark for correct syntax for class header)
(½ Mark for correct declaration of instance attributes)
(1 Mark for correct definition of FixLocation())
(1 Mark for correct definition of Enter() with proper invocation ofFixLocation() method)
454
(1 Mark for correct definition of SeeAll())
NOTE:
Deduct ½ Mark if FixLocation() is not invoked properly inside Enter()
method
(d) What is operator overloading with methods ? Illustrate with the help of anexample using a python code. 2
Ans Operator overloading is an ability to use an operator in more than one form.
Examples:
In the following example operator + is used for finding the sum of
two integers:
a = 7
b = 5
print (a+b) # gives the output: 12
Whereas in the next example, shown below the same + operator is used to
add two strings:
a = 'Indian'
b = 'Government'
print (a+b) #gives the output: Indian Government
(1 Mark for correct definition of Operator overloading)
(1 Mark for correct example of Python code to illustrate Operator
overloading)
(e) Write a method in python to display the elements of list thrice if it is a numberand display the element terminated with '#' if it is not a number. 2
For example, if the content of list is as follows :
ThisList=['41', 'DROND', 'GIRIRAJ', '13', 'ZARA']
455
The output should be
414141
DROND#
GIRIRAJ#
131313
ZARA#
Ans def fun (L) :
for I in L:
if I.isnumeric() :
print(3*I) # equivalently: print(I+I+I)
else:
print(I+'#')
(½ Mark for correct loop)
(½ Mark for checking numeric/non numeric)
(½ Mark for displaying numeric content)
(½ Mark for displaying numeric content)
3. (a) What will be the status of the following list after fourth pass of bubble sort
and fourth pass of selection sort used for arranging the following elements in
descending order ? 3
14, 10, -12, 9, 15, 35
Ans Bubble Sort
14,10,-12,9,15,35 (Original Content)
i. 14,10,9,15,35,-12
ii. 14,10,15,35,9,-12
456
iii. 14,15,35,10,9,-12
iv. 15,35,14,10,9,-12 (Unsorted status
after 4th pass)
Selection Sort
14,10,-12,9,15,35 (Original Content)
i. 35,10,-12,9,15,14
ii. 35,15,-12,9,10,14
iii. 35,15,14,9,10,-12
iv. 35,15,14,10,9,-12
For Bubble Sort
(1½ Mark if (iv) pass is correct)
OR
(½ Mark for (i) pass)
(½ Mark for (jj) pass)
(½ Mark for (iii) pass)
For Selection Sort
(1½ Mark if (iv) pass is correct)
OR
(½ Mark for {i) pass)
(½ Mark for (ii) pass)
(½ Mark for (iii) pass)
(b) Write a method in python to search for a value in a given list (assuming that the
elements in list are in ascending order) with the help of Binary Search method.
The method should return -1 if the value not present else it should return
position of the value present in the list. 2
457
Ans def bSearch(L, key):
low = 0
high = len(L)-l
found = False
while (low <= high) and (not found) :
mid = (low+high)//2
if L[mid]== key:
found = True
elif L[mid] < key:
low = mid + 1
else:
high = mid - 1
if found:
return mid+1 # may even be 'return mid'
else:
return -1
(½ Mark for correct Initialization of lower and upper bounds)
(½ Mark for correct loop)
(½ Mark for reassigning Mid, Low, Up bound)
(½ Mark for returning correct value)
(c) Write PUSH (Books) and POP (Books) methods in python to add Books
and remove Books considering them to act as Push and Pop operations of
Stack. 4
Ans def push (Books):
458
Stack.append (Books)
print 'Element:',Book,'inserted successfully'
def pop() :
if Stack == []:
print (' Stack is empty! ')
e1se:
print('De1eted element is', Stack.pop())
(2 Marks for correctly pushing an element into the stack)
(1 Mark for checking empty stack in POP()
(1 Mark for popping element from stack)
(d) Write a method in python to find and display the prime numbers between 2 to
N. Pass N as argument to the method. 3
Ans def prime_numbers(N):
for I in range(2, N+1):
M = I // 2
IsPrime=l
for J in range(2, M+1) :
if I % J == 0:
IsPrime=0
break
if IsPrime==l:
print (I)
OR
Any other correct equivalent method definition
459
(1 Mark for correct loops)
(1 Mark for checking prime numbers between 2 to N)
(1 Mark for displaying the numbers)
(e) Evaluate the following postfix notation of expression. Show status of stack
after every operation. 2
84, 62, -, 14, 3, ", +
Ans E1ement Stack
84 84
62 84, 62
- 22
14 22, 14
3 22, 14, 3
* 22, 42
+ 64
(1 mark for evaluating till 22)
(½ mark for evaluating till 22,42)
(½ mark for evaluating till final 64)
Note:
Only 1 mark to be awarded for evaluating final answer as 64 without
showing stack contents
4. (a) Differentiate between the following : 1
(i) f = open ('diary. txt', 'r' )
(ii) f = open ('diary. txt', 'w')
460
Ans (i) diary.txt is opened for reading data
(ii) diary. txt is opened for writing data
(1 mark for writing correct difference)
OR
(½ Mark for each correct explanation of (i) and (11))
(b) Write a method in python to read the content from a text file diary.txt line by
line and display the same on screen. 2
Ans def read_file () :
inFile = open('diary.txt','r')
for line in inFile:
print line
(½ Mark for opening the file)
(1 Mark for reading all lines)
(½ Mark for displaying all lines)
(c) Consider the following definition of class Member, write a method in python
to write the content in a pickled file member.dat. 3
class Member:
def_init_(se1f,Mno,N):
se1f.Memno=Mno
se1f.Name=N
def Show(self):
Display(self.Memno,"#",self.Name)
Ans import pickle
class Member:
461
def_init_(self, Mno, N) :
self.Memno=Mno
self.Name=N
def Show (self) :
Display (self.Memno, "#", self . Name)
def store_data (self) :
piFile = open ('member. dat', 'wb')
pickle.dump (self, piFile)
piFile.close()
(1 Mark for method header)
(1 Mark for opening the file member dat in correct mode)
(1 Mark each for writing member details into the file)
Section-C
(For all Candidates)
5. (a) Observe the following table carefully and write the names of the most
appropriate columns, which can be considered as (i) candidate keys and
(ii) primary key. 2
Id Product Qty Price Transaction Date
101 Plastic Folder 12" 100 3400 2014-12-14
104 Pen Stand Standard 200 4500 2015-01-31
105 Stapler Medium 250 1200 2015-02-28
109 Punching Machine Big 200 1400 2015-03-12
103 Stapler Mini 100 1500 2015-02-02
462
Ans Candidate keys : ld, Product
Primary keys : ld
(1 Mark for writing correct Candidate keys)
(1 Mark for writing correct Primary key)
Note:
No marks to be deducted for mentioning Price andlor TransactionDate as additional candidate keys.
(b) Consider the following DEPT and WORKER tables. Write SQL queries for(i) to (iv) and find outputs for SQL queries (v) to (viii) : 6
Table: DEPT
DCODE DEPARTMENT CITY
D01 MEDIA DELHI
D02 MARKETING DELHI
D03 INFRASTRUCTURE MUMBAI
DO5 FINANCE KOLKATA
D04 HUMAN RESOURCE MUMBAI
Table: WORKER
WNO NAME DOJ DOB GENDER DCODE
1001 George K 2013-09-02 1991-09-01 MALE DO1
1002 Ryma Sen 2012-12-11 1990-12-15 FEMALE D03
1003 Mohitesh 2013-02-03 1987-09-04 MALE DOS
1007 Ani1 Jha 2014-01-17 1984-10-19 MALE D04
1004 Manila Sahai 2012-12-09 1986-11-14 FEMALE DO1
1005 R SAHAY 2013-11-18 1987-03-31 MALE D02
1006 Jaya Priya 2014-06-09 1985-06-23 FEMALE DOS
463
Note: DOJ refers to date of joining and DOB refers to date of Birth ofworkers.
(i) To display Wno, Name, Gender from the table WORKER in descendingorder of Wno.
Ans SELECT Wno,Narne,GenderFROM Worker
ORDER BY Wno DESC;
(½ Mark for SELECT Wno, Name, Gender FROM Worker)
(½ Mark for ORDER BY Wno DESC)
(ii) To display the Name of all the FEMALE workers from the tableWORKER.
Ans SELECT Name FROM Worker
WHERE Gender='FEMALE' ;
(½ Mark for SELECT Name FROM Worker)
(½ Mark for WHERE Gender =' FEMALE' )
(iii) To display the Wno and Name of those workers from the tableWORKER who are born between '1987-01-01' and '1991-12-01'.
Ans SELECT Wno, Name FROM Worker
WHERE DOB BETWEEN '1987-01-01' AND '1991-12-01';
OR
SELECT Wno, Name FROM Worker
WHERE DOB >='1987-01-01' AND DOB <='1991-12-01'
(½ Mark for SELECT Wno, Name FROM Worker)
(½ Mark for
WHERE DOB BETWEEN '1987-01-01' AND '1991-12-01'
OR
WHERE DOB >='1987-01-01' AND DOB <='1991-12-01')
464
(iv) To count and display MALE workers who have joined after'
1986-01-01' .
Ans SELECT COUNT(*) FROM Worker
WHERE GENDER='MALE' AND DOJ > '1986-01-01';
OR
SELECT * FROM Worker
WHERE GENDER='MALE' AND DOJ > '1986-01-01';
(Any valid query for counting and/or displaying for male workers will
be awarded 1 mark)
(v) SELECT COUNT(*), DCODE FROM WORKER
GROUP BY DCODE HAVING COUNT(*)>1;
Ans COUNT(*) DCODE
2 D01
2 D05
(½ Mark for correct output)
(vi) SELECT DISTINCT DEPARTMENT FROM DEPT;
Ans Department
MEDIA
MARKETING
INFRASTRUCTURE
FINANCE
HUMAN RESOURCE
(½ Mark for correct output)
465
(vii) SELECT NAME, DEPARTMENT, CITY FRQM WORKER W,DEPT
D WHERE W. DCODE=D.DCODE AND WNO<100"3 ;
Ans NAME DEPARTMENT CITY
George K MEDIA DELHI
Ryma Sen INFRASTRUCTURE MUMBAI
(½ Mark for correct output)
(viii) SELECT MAX(DOJ), MIN(DOB) FROM WORKER;
Ans MAX (DOJ) MIN (DOB)
2014-06-09 1984-10-19
(½ Mark for correct output)
Note: In the output queries, please ignore the order of rows
6. (a) Verify the following using Boolean Laws. 2
x + Y' = X.Y+X.Y'+X'.Y'
Ans L.H.S
=X + Y'
=X. (Y+Y') + (X + X') . Y'
=X.Y + X.Y' + X.Y' + X' . Y'
=X.Y + X.Y' + X' . Y'
=R.H.S
OR
R.H.S
=X. Y + X. Y' + X'. Y'
=X. (Y + Y') + X'. Y'
466
=X.1+ X'. Y'
=X + X'. Y'
=X + Y'
=L.H.S
(2 Marks for any valid verification using Boolean Laws)
OR
(1 Mark for partial correct verification using Boolean Laws)
(b) Draw the Logic Circuit for the following Boolean Expression : 2
(U + V').W' + Z
Ans
(½ Mark for v' and W')
(½ Mark for (U+ V'))
(½ Mark for (U+V'). W')
(½ Mark for (U+V'). W'+Z)
(c) Derive a Canonical SOP expression for a Boolean function F, represented by
the following truth table : 1
A B C F(A,B,C)
0 0 0 1
0 0 1 0
0 1 0 0
0 1 1 1
467
1 0 0 1
1 0 1 0
1 1 0 0
1 1 1 1
Ans F(A,B,C) = A'B'C' + A'BC + AB'C' + ABC
OR
F(A,B,C) = ∑ (0,3,4,7)
(1 Mark for the correct SOP form)
OR
(Vl Mark for writing any two term correctly)
Note: Deduct ½ mark if wrong variable names are used
(d) Reduce. the following Boolean Expression to its simplest form using K-Map : 3
F(X,Y,Z,W) = ∑(O,1,6,8,9,10,11,12,15)
Ans
468
Simplified Expression: XV' + Y'Z' + XZ'W' + XZW + X'YZW'
(½ Mark for each of grouping - 5 groups x ½ = 2½ Marks)
(½ Mark for writing final expression in reduced/minimal/nonredundant form as XV' + Y'Z' + XZ'W' + XZW + X'YZW' )
Note: Deduct ½ mark if wrong variable names are used
7. (a) Illustrate the layout for connecting 5 computers in a Bus and a Star topologyof Networks. 1
Ans
OR any valid illustration of Bus and Star Topology.
(½ Mark for drawing each correct layout)
(b) What is a spam mail ? 1
Ans Spam is the abuse of electronic messaging systems (including most broadcastmedia, digital delivery systems) to send unsolicited bulk messagesindiscriminately.
(1 Mark for correct explanation)
(c) Differentiate between ftp and http. 1
Ans FTP is a protocol to transfer files over the Internet
HTTP is a protocol which allows the use of HTML to browse web pages inthe World Wide Web.
(1 Mark for any valid differentiation)
469
(d) Out of the following, which is the fastest (i) wired and (ii) wireless medium of
communication?
Infrared, Coaxial Cable, Ethernet Cable, Microwave, Optical Fiber 1
Ans (i) Wired - Optical Fiber
(ii) Wireless - Infrared OR Microwave
(½ Mark each for Wired and Wireless medium of communication)
(e) What is Worm? How is it removed? 1
Ans A worm is a self-replicating computer program. It uses a network to send
copies of itself to other computers on the network and it may do so without
any user intervention.
Most of the common anti-virus(anti-worm) remove worm.
(½ Mark for writing correct meaning of Worm)
(½ Mark for correct definition of removing Worm)
(f) Out of the following, which all comes under cyber crime?
(i) Stealing away a brand new computer from a showroom.
(ii) Getting in someone's social networking account without his consentand posting pictures on his behalf to harass him.
(iii) Secretly copying files from server of a call center and selling it to theother organization.
(iv) Viewing sites on a internet browser.
Ans (ii) & (iii)
(½ Mark for choosing each of the correct options)
Note:
No marks to be given, if all options are there in the answer
½ Mark to be deducted, if one extra option is given along with
the correct options
470
(g) Perfect Edu Services Ltd. is an educational organization. It is planning tosetup its India campus at Chennai with its head office at Delhi. The Chennaicampus has 4 main buildings - ADMIN, ENGINEERING, BUSINESS andMEDIA.
You as a network expert have to suggest the best network related solutionsfor their problems raised in (i) to (iv), keeping in mind the distances betweenthe buildings and other given parameters.
DELHI CHENNAI
Head Office Campus ENGINEERING
ADMIN BUSINESS
MEDIA
Shortest distances between various buildings :
ADMIN to ENGINEERING 55m
ADMIN to BUSINESS 90m
ADMIN to MEDIA 50m
ENGINEERING to BUSINESS 55m
ENGINEERING to MEDIA 50m
BUSINESS to MEDIA 45m
DELHI Head Office to CHENNAI Campus 2175 km
Number of Computers installed at various buildings are as follows :
ADMIN 110
ENGINEERING 75
BUSINESS 40
MEDIA 12
DELHI Head Office 20
471
(i) Suggest the most appropriate location of the server inside the
CHENNAI campus (out of the 4 buildings), to get the best connectivity
for maximum no. of computers. Justify your answer. 1
Ans ADMIN (due to maximum number of computers)
OR
MEDIA (due to shorter distance from the other buildings)
(1 Mark for mentioning Correct building name with reason)
OR
(½ Mark to be deducted for not giving reason)
(ii) Suggest and draw the cable layout to efficiently connect various build-
ings within the CHENNAI campus for connecting the computers. 1
Ans Anyone of the following
(1 Mark for drawing correct layout)
(iii) Which hardware device will you suggest to be procured by the
company to be installed to protect and control the internet uses within
the campus ? 1
Ans Firewall OR Router
(1 Mark for correct Answer)
(iv) Which of the following will you suggest to establish the online face-
to-face communication between the people in the Admin Office of
CHENNAI campus and DELHI Head Office? 1
(a) Cable TV
472
(b) Email
(c) Video Conferencing
(d) Text Chat
Ans Video Conferencing
(1 Mark for correct Option / Answer)
QUESTION PAPER CODE 91EXPECTED ANSWERS
Section-A
(Only for C++ Candidates)
1. (a) Find the correct identifiers out of the following, which can be used for namingVariable, Constants or Functions in a C++ program : 2
For, while, INT, NeW, delete, 1stName, Add+Subtract, name1
Ans For, INT, NeW, namel
(½ Mark for each correct identifier)
Note:
Deduct ½ Mark for writing additional incorrect identifier(s)
No marks to be awarded if all the identifiers are mentioned
(b) Observe the following program very carefully and write the names of thoseheader filets), which are essentially needed to compile and execute thefollowingprogram successfully : 1
typedef char STRING[80];
void main()
{
STRING Txt [] = "We love Peace";
473
int Count=O;
while (Txt[Count] !='\O')
if (isa1pha(Txt[Count]"
Txt[Count++]='@';
else
Txt[Count++]='#';
puts(Txt);
}
Ans ctype, stdio
(½ mark for each header file)
Note: Ignore any additional header file(s)
(c) Observe the following C++ code very carefully and rewrite it after removingany/all syntactical errors with each correction underlined. 2
Note : Assume all required header files are already being included in theprogram.
#Define float MaxSpeed=60.5;
void main()
{
int MySpeed
char Alert='N' ;
cin>>MySpeed;
if MySpeed>MaxSpeed
Alert=' Y' ;
cout<<Alert<<endline;
}
474
Ans #define float MaxSpeed_60.5 ; //Error 1,2,3
void main ()
{
int MySpeed ; //Error 4
char Alert='N' ;
cin>>MySpeed;
if (MySpeed>MaxSpeed) //Error 5
Alert=' Y' ;
cout<<Alert<<endl ; //Error 6
}
(½ Mark for each correction upto a maximum of 4 corrections)
OR
(1 mark for only identifying any 4 errors, without suggesting
corrections).
(d) Write the output of the following C++ program code: 2
Note : Assume all required header files are already being included in the
program.
void Location(int &X,int Y=4)
{
Y+=2;
X+=Y;
}
void main ()
{
475
int PX=10,PY=2;
Location (PY) ;
cout<<PX<<","<<PY<<end1 ;
Location(PX,PY);
cout<<PX<<","<<PY<<end1 ;
}
Ans 10,8
20,8
(½ Mark for each correct value)
Note:
Deduct ½ Mark for not considering any or all end/(s) at properplace(s)
Deduct ½ Mark for not considering any or all ',' at proper place(s)
(e) Write the output of the following C++ program code: 3
Note: Assume all required header files are already being included in theprogram.
class Eva1
{
char Level;
int Point;
public:
Eva1() {Level='E'; Point=O;}
void Sink(int L)
{
Level-=L;
476
}
void Float(int L)
{
Level+=L;
Point++;
}
void Show()
{
cout<<Leve1<<"#"<<Point<<end1;
}
} ;
void main ()
{
Eval E;
E.Sink(3);
E.Show ();
E.Float(7);
E.Show ();
E.Sink(2);
E.Show ();
}
Ans B#0
1#1
G#l
477
(1 Mark for each correct line of output)
Note:
Deduct ½ Mark for not considering any or all end/(s) at proper
place(s)
Deduct ½ Mark for not writing any or all # symbol(s)
(f) Study the following program and select the possible output(s) from the options(i) to (iv) following it. Also, write the maximum and the minimum values thatcan be assigned to the variable VAL. 2
Note:
– Assume all required header files are already being included in theprogram.
– random(n) function generates an integer between 0 and n-l.
void main ()
{
randomize();
int VAL;
VAL=random(3) +2;
char GUESS[]="ABCDEFGHIJK";
for (int I=l;I<=VAL; I++)
{
for(int J=VAL; J<=7;J++)
cout<<GUESS [J] ;
cout<<endl;
}
}
478
(i) (ii) (iii) (iv)
BCDEFGH CDEFGH EFGH FGHI
BCDEFGH CDEFGH EFGH FGHI
EFGH FGHI
EFGH FGHI
Ans (ii) and (iii)
Min Value of VAL = 2
Max Value of VAL = 4
(½ Mark for writing option (ii) )
(½ Mark for writing option (iii) )
Note:
Deduct ½ mark for writing each additional option along with
both correct options
(½ Mark for writing correct Minimum value of VAL)
(½ Mark for writing correct Maximum value of VAL)
2. (a) What is a copy constructor ? Give a suitable example in C++ to illustrate
with its definition within a class and a declaration of an object with the help of
it. 2
Ans A copy constructor is an overloaded constructor in which an object of the
same class is passed as reference parameter.
class Point
{
int x;
public:
479
Point () {x=O; }
Point(Point &p) // Copy constructor
{x=p.x;}
} ;
void main ()
{
Point pl;
Point p2(pl) ;//Copy constructor is called here
//OR
Point p3=pl;//Copy constructor is called here
}
(1½ Mark to be awarded if the copy constructor is explained with anappropriate example)
OR
(1 Mark for correct explanation of copy constructor only without anexample)
(½ Mark for correct declaration of an object)
(b) Observe the following C++ code and answer the questions (i) and (ii) :
class Passenger
{
long PNR;
char Name [201 ;
public:
Passenger () //Function 1
{ cout<<"Ready"<<endl; }
480
void Book(long P,char N[]) //Function 2
{ PNR = P; strcpy (Name, N)·; }
void Print () //Function 3
{ cout<<PNR << Name <<endl; }
~Passenger () //Function 4
{ cout<<"Booking cancelled! "<<endl; }
} ;
(i) Fill in the blank statements in Line 1 and Line 2 to execute Function 2
and Function 3 respectively in the following code : 1
void main()
{
Passenger P;
_____________ //Line 1
_____________ //Line 2
}//Ends here
Ans P. Book (1234567,"Ravi"); //Line 1
P.Print() ; //Line 2
(½ Mark for writing each correct Function)
(ii) Which function will be executed at } / / Ends here ? What is this func-
tion referred as ? 1
Ans Function 4
OR
~Passenger ()
It is a Destructor function.
481
(½ Mark for writing Function 4 OR ~Passenger())
(½ Mark for referring Destructor)
(c) Write the definition of a class Photo ill C++ with following description: 4
Private Members
- Pno //Data member for Picture Number (an integer)
- Category//Data member for Picture Category (a string)
- Location//Data member for Exhibition Location (a string)
- FixLocation //A member function to assign
//Exhibition Location as per category
//as shown in the following table
Category Exhibit
Antique Zaveri
Modern Johnsen
Classic Terenida
Public Members
- Enter() //A function to allow user to enter values
//Pno, category and call FixLocation() function
- SeeAll() //A function to display all the data members
Ans class Photo
{
int Pno;
char Category[20];
char Exhibit[20];
void FixExhibit() ;
482
public:
void Register 0 ;
void ViewA11();
} ;
void Photo::FixExhibit()
{
if (strcmpi (Category, "Antique") ==0)
strcpy(Exhibit,"Zaveri");
else if(strcmpi(Category,"Modern")==0)
strcpy(Exhibit,"Johnsen") ;
else if strcmpi(Category,"Classic")==0)
strcpy(Exhibit,"Terenida") ;
}
void Photo::Register()
{
cin"Pno;
gets (Category) ;
FixExhibit();
}
void Photo:: ViewAll()
{
cout<<Pno<<Category<<Exhibit<<endl;
}
483
(½ Mark for correct syntax for class header)
(½ Mark for correct declaration of data members)
(1 Mark for correct definition of FixExhibit))
(1 Mark for correct definition of Register()) with proper invocation of
FixExhibit() function)
(1 Mark for correct definition of ViewAIl())
NOTE:
Deduct ½ Mark if FixExhibit() is not invoked properly inside
Register() function
No marks to be deducted for defining Member Functions inside
the class
Strcmp()/strcmpi() acceptable
(d) Answer the questions (i) to (iv) based on the following: 4
class Interior
{
int OrderId;
char Address[20];
protected:
float Advance;
public:
Interior();
void Book(); void View();
} ;
class Painting:public Interior
484
{
int Wa11Area,ColorCode;
protected:
char Type;
public:
Painting () ;
void PBook();
void PView();
} ;
class Billing : public Painting
{
float Charges;
void Calculate();
public:
Billing();
void Bill();
void Bi11Print();
} ;
(i) Which type of Inheritance out of the following is illustrated in the above
example?
– Single Level Inheritance
– Multi Level Inheritance
– Multiple Inheritance
485
Ans Multi Level Inheritance
(1 Mark for mentioning correct option)
(ii) Write the names of all the data members, which are directly accessible
from the member functions of class Painting.
Ans WallArea, ColorCode,Type, Advance
(1 Mark for correct answer)
Note:
No marks to be awarded for any partial or additional answer(s)
(iii) Write the names of all the member functions, which are directly accessible
from an object of class Billing.
Ans Bill(), BillPrint(), PBook(), PView(), Book(), View()
(1 Mark for correct answer)
Note: No marks to be awardedfor any partial/additional answer(s)
Constructors can be ignored
(iv) What will be the order of execution of the constructors, when an object
of class Billing is declared ?
Ans Interior, Painting, Billing
(1 Mark for correct answer)
Note: No marks to be awarded for any other order
3. (a) Write the definition of a function Change (int P[], int N) in C++, which should
change all the multiples of 10 in the array to 10 and rest of the elements as 1.
For example, if an array of 10 integers is as follows: 2
P[0] P[l] P[2] P[3] P[4] P[5] P[6] P[7] P[8] P[9]
100 43 20 56 32 91 80 40 45 21
After executing the function, the array content should be changed as follows:
486
P[0] P[l] P[2] P[3] P[4] P[5] P[6] P[7] P[8] P[9]
10 1 10 1 1 1 10 10 1 1
Ans void Change (int P[ ],int N)
{
for (int i=0;i<N;i++)
if(P[i]%10==0)
P[i]=10;
else
P[i]=l;
}
OR
Any other correct equivalent function definition
(½ Mark for correct loop)
(½ Mark for correct checking of divisibility of array elements by 10)
(½ Mark for correct use of else OR correct checking of non divisibility
of array elements by 10 )
(½ Mark for correct assignment of 10 and 1 for multiples and non
multiples of 10 respectively)
(b) A two dimensional array ARR[50][20] is stored in the memory along the rowwith each of its elements occupying 4 bytes. Find the address of the elementARR[30] [10], if the element ARR[10] [5] is stored at the memory location15000. 3
Ans Loc (ARR[I] [J]) along the row
=BaseAddress + W [( I - LBR)*C + (J - LBC)]
(where C is the number of columns, LBR = LBC = 0
487
LOC (ARR[10] [5])
= BaseAddress + W [I*C + J]
15000 = BaseAddress + 4[10*20 + 5]
= BaseAddress + 4[200 + 5]
= BaseAddress + 4 x 205
= BaseAddress + 820
BaseAddress = 15000-820
= 14180
LOC (ARR[30] [10]) = 14180 + 4 [30 * 20 + 10]
= 14180 + 4 * 610
= 14180 + 2440
= 16620
OR
LOC(ARR[30] [10])
= LOC(ARR[10] [5])+ W[( I-LBR)*C + (J-LBC)]
= 15000 + 4 [ (30-10) *20 + (10-5)]
= 15000 + 4[ 20*20 + 5]
= 15000 + 4 *405
= 15000 + 1620
= 16620
OR
Where C is the number of columns and LBR=LBC=l
LOC (ARR[10] [5])
15000 = BaseAddress + W [( I-I) *C + (J-l)]
488
= BaseAddress + 4[9*20 + 4]
= BaseAddress + 4[180 + 4]
= BaseAddress + 4 * 184
= BaseAddress + 736
BaseAddress = 15000 - 736
= 14264
LOC(ARR[30] [10])
= 14264 + 4[(30-1)*20 + (10-1)]
= 14264 + 4[29*20 + 9]
= 14264 + 4[580 + 9]
= 14264 + 4*589
= 14264 + 2356
= 16620
(1 Mark for writing correct formula (for row major) OR substitutingformula with correct values)
( 1 Mark for at least one step of intermediate calculation)
( 1 Mark for final correct address)
(c) Write the definition of a member function PUSH( ) in C++, to add a newbook in a dynamic stack of BOOKS considering the following code is alreadyincluded in the program : 4
struct BOOKS
{
char ISBN[20], TITLE[80];
BOOKS *Link;
} ;
489
class STACK
{
BOOKS *Top;
public:
STACK() {Top=NULL;}
void PUSH();
void POP() ;
~STACK() ;
} ;
Ans void STACK: :PUSH()
{
BOOKS *Temp;
Temp=new BOOKS;
gets (Temp->1SBN) ;
gets (Temp->T1TLE) ;
Temp->Link=Top;
Top=Temp;
}
OR
Any other correct equivalent function definition
(1 Mark for creating a new node of BOOKS dynamically)
(½ Mark for entering value of ISBN)
(½ Mark for entering value of TITLE)
(1 Mark for linking the new node of BOOKS to the Top)
(1 Mark for making the new node of BOOKS as Top)
490
(d) Write a function REVROW(int P[ ][5],int N,int M) in C++ to displaythe content of a two dimensional array, with each row content in reverse
order. 3
For example, if the content of array is as follows :
15 12 56 45 51
13 91 92 87 63
11 23 61 46 81
The function should display output as
51 45 56 12 15
63 87 92 91 13
81 46 61 23 81
Ans void REVROW(int P[] [5],int N,int M)
{
for(int 1=0; 1<Ni 1++)
{ for(int J<M-l; J>=O; J--)
cout<<P[1] [J] ;
cout<<end1;
}
}
OR
void REVROW(int P[ ] [5],int N,int M)
{
for(int I=0; 1<N; 1++)
{
491
for(int J=0; J<M/2; J++)
{
int T = P[1] [J];
P [I] [J] = P[1] [M-J-l];
P [I] [M-J-l] = T;
}
}
for (I=0 i 1<N; 1++)
{
for (int J=0; J<M; J++)
cout<<P [I] [J] ;
cout<<endl;
}
}
(1 Mark for correct nesting of loop(s))
(1½ Mark for correct logic for reversing the content of each row)
(½ Mark for correctly displaying the content)
Note: N and M can be written interchangeably for number of rows
and columns
(e) Convert the following Infix expression to its equivalent Postfix expression,
showing the stack contents for each step of conversion : 2
U * V + R/(S-T)
Ans U * V + R/(S-T)
= ((U * V)+(R/(S-T)))
492
Element Stack Postfix
(
(
U U
* *
V UV
) UV*
+ +
(
R UV*R
/ +/
(
S UV*RS
- +/-
T UV*RST
) UV*RST-
) UV*RST-/
) UV*RST-/+
OR
Element Stack Postfix
U U
* * U
V * UV
493
+ + UV*
R + UV*R
/ +/ UV*R
( +/ ( UV*R
S +/ ( UV*RS
- +/(- UV*RS
T +/(- UV*RST
) +/ UV*RST-
+ UV*RST-/
UV*RST-/+
OR
Any other method for converting the given Infix expression to its
equivalent Postfix expression showing stack contents
(½ mark for converting expression up to each operator)
OR
(1 mark to be given for writing correct answer without showing the
stack content)
4. (a) Write function definition for TOWER( ) in C++ to read the content of a text
file WRITEUP.TXT, count the presence of word TOWER and display the
number of occurrences of this word. 2
Note:
– The word TOWER should be an independent word
– Ignore type cases (i.e. lower/upper case)
Example:
494
If the content of the file WRITEUP.TXT is as follws :
Tower of hanoi is an interesting problem. Mobile
phone tower is away from here. Views from EIFFEL
TOWER are amazing.
The function TOWER( ) should display the following:
3
Ans voidTOWER()
{
int count=0;
ifstream f("WRITEUP.TXT") ;
char s[20];
while (! f .eof () )
{
f>>s;
if (strcmpi (s, "TOWER") ==0)
count++;
}
cout<<count;
f. close () ;
}
OR
Any other correct function definition
(½ Mark for opening WRITEUP. TXT correctly)
(½ Mark for reading each word (using any method) from the file)
495
(½ Mark for comparing the word with TOWER)
(½ Mark for displaying correct count of TOWER)
NOTE:
(½ Mark to be deducted if TOWER is compared without ignoring the
case)
(b) Write a definition for function COSTLY() in C++ to read each record of a
binary file GIFTS.DAT, find and display those items, which are priced more
than 2000. Assume that the file GIFTS.DAT is created with the help of objects
of class GIFTS, which is defined below: 3
class GIFTS
{
int CODE;char ITEM[20]; float PRICE;
public:
void Procure ()
{
cin>>CODE; gets (ITEM);cin>>PRICE;
}
void View()
{
cout<<CODE<<": "<<ITEM<<": "<<PRICE<<endl;
}
float GetPrice() {return PRICE;}.
} ;
496
Ans void COSTLY()
{
GIFTS G;
ifstream fin("GIFTS.DAT",ios::binary);
while (fin.read"char *)&G,sizeof(G)))
{
if (G.GetPrice ()>2000)
G.View();
}
fin. close ();
}
OR
Any other correct equivalent function definition
(½ Mark for opening GIFTS.DAT correctly)
(1 Mark for reading all records from the file)
(1 Mark for checking value of PRICE > 2000 )
(½ Mark for displaying the desired items)
(c) Find the output of the following C++ code considering that the binary file
MEMBER.DAT exists on the hard disk with records of 100 members: 1
class MEMBER
{
int Mno; char Name[20];
public:
void In();void Cut();
497
} ;
void main()
{
fstream MF;
MF.open ("MEMBER. DAT",ios:: binary|ios::in);
MEMBER M;
MF.read((char*)&M, sizeof(M));
MF.read((char*)&M, sizeof(M));
MF.read((char*)&M, sizeof(M));
int POSITION= MF.tellg()/sizeof(M);
cout<<"PRESENT RECORD:"<<POSITION<<end1;
MF.close();
}
Ans PRESENT RECORD: 3
(1 Mark for writing PRESENT RECORD: 3)
OR
(1 Mark for writing only 3)
OR
(½ Mark for writing only PRESENT RECORD:)
Section - B
(Only for Python candidates)
1. (a) How is___init()___different from___del ()___? 2
Ans _init_() is the class constructor or initialization method which is automatically
invoked when we create a new instance of a class.
498
_del_() is a destructor which is automatically invoked when an object(instance) goes out of scope.
For Example:
class Sample:
def __ init __ (self) :
self.data = 79
print('Data:' ,self.data,'created')
def __ del __ (self) :
print (' Data: ' , self. data, 'deleted')
s = Sample ()
del s
(2 Marks for correct differentiation)
OR
(2 Marks for differentiation through example)
OR
(1 Mark for each correct definition)
(b) Name the function/method required to 1
(i) check if a string contains only alphabets
(ii) give the total length of the list
Ans isalpha ()
len()
(½ Mark for each correct function/ method name)
(c) Rewrite the following code in python after removing all syntax error(s).Underline each correction done in the code. 2
def Sum(Count) #Method to ·find sum
499
S=O
for I in Range (1,Count+l) :
S+=I
RETURN S
print Sum[2] #Function Call
print Sum[5]
Ans def Sum(Count) : #Method to find sum #Error 1
S=O
for I in range (1,Count+l): #Error 2
S+=I
return S #Error 3
print Sum (2) #Function Call #Error 4
print Sum (5) #Error 4
(½ Mark for each correction)
OR
(1 mark for identifying all the errors, without suggesting corrections)
(d) Find and write the output of the following python code: 2
for Name in ['John', 'Garima','Seema','Karan']:
print Name
if Name[O]='S':
break
else:
print 'Completed!'
print 'We1done!'
500
Ans John
Garima
Seema
Weldone!
(½ Mark for each correct line)
Note:
Deduct ½ Mark for not considering any or all line breaks at properplace(s)
(e) Find and write the output of the following python code: 3
class Emp:
def_init_(se1f,code,nm): #constructor
se1f.Code=code
se1f.Name=nm
def Manip(self) :
se1f.Code=self.Code+10
se1f.Name='Karan'
def Show (se1f,line) :
print se1f.Code,self.Name,line
s=Emp (25, 'Mamta')
s.Show(l)
s.Manip()
s.Show(2)
print s.Code+1en(s.Name)
501
Ans 25 Mamta 1
35 Karan 2
40
(1 Mark for each correct line)
Note:
Deduct ½ Mark for not considering any or all line break(s) at proper
place(s).
(f) What are the possible outcome(s) executed from the following code?
Also specify the maximum and minimum values that can be assigned to variable
COUNT. 2
TEXT="CBSEONLINE"
COUNT=random.randint(0,3)
C=9
while TEXT[C]!='L' :
print TEXT[C]+TEXT[COUNT]+'*',
COUNT=COUNT+1
C=C-l
(i) (ii) (iii) (iv)
EC*NB*IS* NS*IE*LO* ES*NE*IO* LE*NO*ON*
Ans (i) EC*NB*IS*
(iii) ES*NE*IO*
Minimum COUNT = 0 Maximum COUNT = 3
(½ Mark for writing option (i) )
(½ Mark for writing option (iii) )
502
Note:
Deduct V2 mark for writing each additional option along withboth correct options
(½ Mark for writing correct Minimum value of COUNT)
(½ Mark for writing correct Maximum value of COUNT)
2. (a) Illustrate the concept inheritance with the help of a python code. 2
Ans class Base:
def __ init (self) :
print "Base Constructor at work ... "
def show (self) :
print "Hello Base"
class Der(Base) :
def __ init __ (self) :
print "Derived Constructor at work ... "
def display (self) :
print "Hello from Derived"
(1 Mark for base class)
(1 Mark for derived class)
(b) What will be the output of the following python code ? Explain the try and
except used in the code. 2
A=0
B=6
print 'One'
try:
503
print 'Two'
X=B/A
Print 'Three'
except ZeroDivisionError:
print B*2
print 'Four'
except:
print B*3
print 'Five'
Ans One
Two
12
Four
The code written within try triggers the exception written after except
ZeroDivisionError: in case there is a division by zero error otherwise the default
exception is executed
OR
Any other correct explanation for usage of try and except
(½ Mark for first two lines of correct output)
(½ Mark for next two lines of correct output)
(½ Mark each for correct explanation of try and except)
(c) Write a class PHOTO in Python with following specifications: 4
Instance Attributes
- Pno # Numeric value
- Category # String Value
504
- Exhibit # Exhibition Gallery with String value
Methods:
- FixExhibit() #A method to assign
#Exhibition Gallery as per Category
#as shown in the following table
Category Exhibit
Antique Zaveri
Modern Johnsen
Classic Terenida
- Register() #A function to allow user
#to enter values of Pno, Category
#and call FixExhibit() method
- ViewA11() #A function to display all the data
#members
Ans class PHOTO:
Pno=0
Category=" "
Exhibit=" "
def FixExhibit() :
if self.Category=="Antique":
self. Exhibit="Zaveri"
elif self .Category="Modern": -
self. Exhihit="Johnsen"
elif self.Category=="Classic":
self. Exhihit="Terenida"
505
def Register () :
self.Pno=int(input("Enter Pno:")
self. Category=input ("Enter Name: ")
self. FixExhibit ()
def ViewAll ()
print self.pno,self.Category,self.Exhibit
(½ Mark for correct syntax for class header)
(½ Mark for correct declaration of instance attributes)
(1 Mark for correct definition of FixExhibit())
(1 Mark for correct definition of Register() with proper invocation of
FixExhibit() method)
(1 Mark for correct definition of ViewAll())
NOTE:
Deduct ½ Mark if FixExhibit() is not invoked properly inside Register()
method
(d) What is operator overloading with methods? Illustrate with the help of an
example using a python code. 2
Ans Operator overloading is an ability to use an operator in more than one form.
Examples:
In the following example operator + is used for finding the sum of two integers:
a = 7
b = 5
print (a+b) # gives the output: 12
Whereas in the next example, shown below the same + operator is used to
add two strings:
506
a = 'Indian'
b = 'Government'
print (a+b) # # gives the output: Indian
Government
(1 Mark for correct definition of Operator overloading)
(1 Mark for correct example of Python code to illustrate Operatoroverloading)
(e) Write a method in python to display the elements of list twice, if it is a numberand display the element terminated with '*' if it is not a number. 2
For example, if the content of list is as follows :
MyList=['RAMAN','21','YOGRAJ','3','TARA']
The output should be
RAMAN *
2121
YOGRAJ*
33
TARA*
Ans def fun(L) :
for I in L:
if I.isnumeric():
print(2*I) # equivalently: print (I+I)
else:
print(I+'*')
(½ Mark for correct loop)
(½ Mark for checking numeric/non numeric)
(½ Mark for displaying numeric content)
(½ Mark for displaying numeric content)
507
3. (a) What will be the status of the following list after fourth pass of bubble sortand fourth pass of selection sort used for arranging the following elements indescending order? 3
34,-6,12,-3,45,25
Ans Bubble Sort
34,-6,12,-3,45,25 (Original Content)
i. 34,12,-3,45,25,-6
ii. 34,12,45,25,-3,-6
iii.34,45,25,12,-3,-6
iv. 45,34,25,12,-3,-6
Selection Sort
34,-6,12,-3,45,25 (Original Content)
i. 45,-6,12,-3,34,25
ii. 45,34,12,-3,-6,25
iii.45,34,25,-3,-6,12
iv. 45,34,25,12,-6,-3 (Unsorted status
after 4th pass)
For Bubble Sort
(1½ Mark if (iv) pass is correct)
OR
(½ Mark for (i) pass)
(½ Mark for (ii) pass)
(½ Mark for (iii) pass)
For Selection Sort
(1½ Mark if (iv) pass is correct)
508
OR
(½ Mark for (i) pass)
(½ Mark for (ii) pass)
(½ Mark for (iii) pass)
(b) Write a method in python to search for a value in a given list (assuming thatthe. elements in list are in ascending order) with the help of Binary Searchmethod. The method should return -1, if the value not present else it shouldreturn position of the value present in the list. 2
Ans def bSearch(L, key):
low = 0
high = len(L)-1
found = False
while (low <= high) and (not found) :
mid = (low<=high)//2
if L[mid] == key:
found = True
elif L[mid] < key:
low = mid + 1
else:
high = mid - 1
if found:
return mid+l # may even be 'return mid'
else:
return -1
(½ Mark for correct Initialization of lower and upper bounds)
509
(½ Mark for correct loop)
(½ Mark for reassigning Mid,Low,Up bound)
(½ Mark for returning correct value)
(c) Write PUSH(Names) and POP(Names) methods in python to add Namesand Remove names considering them to act as Push and Pop operations ofStack. 4
Ans def push (Name) :
Stack. append (Name)
print'Element:' ,Name, 'inserted successfully'
def pop () :
if Stack == [] :
print (' Stack is empty! ')
else:
print('Deleted element is',Stack.pop())
(2 Marks for correctly pushing an element into the stack)
(1 Mark for checking empty stack in POP())
(1 Mark for popping element from stack)
(d) Write a method in python to find and display the composite numbers between2 to N. Pass N as argument to the method. 3
Ans def composite_numbers (N):
for I in range (2, N+1) :
M = I // 2
for J in range(2, M+l) :
if I % J == 0:
print (I)
break
510
OR
Any other correct equivalent method definition
(1 Mark for correct loops)
(1 Mark for checking composite numbers between 2 to N)
(1 Mark for displaying the numbers)
(e) Evaluate the following postfix notation of expression. Show status of stack
after every operation. 2
34,23,+,4,5,*,-
Ans Element Stack
34 34
23 34, 23
+ 57
4 57, 4
5 57, 4, 5
* 57, 20
- 37
(1 mark for evaluating till 57)
(½ mark for evaluating till 57, 20)
(½ mark for evaluating till final 37)
Note:
Only 1 mark to be awarded for evaluating final answer as 37 without
showing stack contents
511
4. (a) Differentiate between the following : 1
(i) f = open ('diary.txt', 'a')
(ii) f = open ('diary.txt', 'w')
Ans (i) diary.txt is opened for writing data at the end of file
(ii) diary.txt is opened for writing data from the beginning of file in createmode
(1 mark for writing correct difference)
OR
(½ Mark for each correct explanation of (i) and (ii))
(b) Write a method in python to read the content from a text file story.txt line byline and display the same on screen. 2
Ans def read_file () :
inFile = open('story.txt', 'r' )
for line in inFile:
print line
(½ Mark for opening the file)
(1 Mark for reading all lines)
(½ Mark for displaying all lines)
(c) Consider the following definition of class Student. Write a method in pythonto write the content in a pickled file student.dat. 3
class Student:
def__init__(se1f,A,N) :
se1f.Admno=A
se1f.Name=N
def Show (se1f) :
print (se1f.Admno, "#", self . Name)
512
Ans import pickle
class Student:
def _init_ (self, A, N):
self.Admno = A
self.Name = N
def show (self) :
print (self.Admno, "#" ,self. Name)
def store_data (self) :
piFile = open('student.dat','wb')
pickle.dump(self, piFile)
piFile.close ()
(1 Mark for method header)
(1 Mark for opening the file student.dat in correct mode)
(1 Mark each for writing student details into the file)
SECTION C
[For all candidates]
5. (a) Observe the following table carefully and write the names of the mostappropriate columns, which can be considered as (i) candidate keys and(ii) primary key: 2
Code Item Qty Price Transaction Date
1001 Plastic Folder 14" 100 3400 2014-12-14
1004 Pen Stand Standard 200 4500 2015-01-31
1005 Stapler Mini 250 1200 2015-02-28
1009 Punching Machine Small 200 1400 2015-03-12
1003 Stapler Big 100 1500 2015-02-02
513
Ans Candidate keys : Code, Item
Primary keys : Code
(1 Mark for writing correct Candidate keys)
(1 Mark for writing correct Primary key)
Note:
No marks to be deducted for mentioning Price and/orTransaction Date as additional candidate keys.
(b) Consider the following DEPT and EMPLOYEE tables. Write SQL queriesfor (i) to (iv) and find outputs for SQL queries (v) to (viii). 6
Table : DEPT
DCODE DEPARTMENT LOCATION
DO1 INFRASTRUCTURE DELHI
D02 MARKETING DELHI
D03 MEDIA MUMBAI
DOS FINANCE KOLKATA
D04 HUMAN RESOURCE MUMBAI
Table : EMPLOYEE
ENO NAME DOJ DOB GENDER DCODE
1001 George K 2013-09-02 1991-09-01 MALE DOl
1002 Ryma Sen 2012-12-11 1990-12-15 FEMALE D03
1003 Mohitesh 2013-02-03 1987-09-04 MALE D05
1007 Anil Jha 2014-01-17 1984-10-19 MALE D04
1004 Manila Sahai 2012-12-09 1986-11-14 FEMALE DOl
1005 R SAHAY 2013-11-18 1987-03-31 MALE D02
1006 Jaya Priya 2014-06-09 1985-06-23 FEMALE DOS
514
Note: DOJ refers to date of joining and DOB refers to date of Birth ofemployees.
(i) To display Eno, Name, Gender from the table EMPLOYEE in ascendingorder of Eno.
Ans SELECT Eno, Name, Gender FROM Employee
ORDER BY Eno;
(½ Mark for SELECT Eno, Name, Gender FROM Employee)
(½ Mark for ORDER BY Eno)
(ii) To display the Name of all the MALE employees from the tableEMPLOYEE.
Ans SELECT Name FROM Employee WHERE Gender='MALE' ;
(½ Mark for SELECT Name FROM Employee)
(½ Mark for WHERE Gender=' MALE' )
(iii) To display the Eno and Name of those employees from the tableEMPLOYEE who are born between '1987-01-01' and '1991-12-01'.
Ans SELECT Eno,Name FROM Employee
WHERE DOB BETWEEN '1987-01-01' AND '1991-12-01'
OR
SELECT Eno,Name FROM Employee
WHERE DOB >='1987-01-01' AND DOB <='1991-12-01';
OR
SELECT Eno,Name FROM Employee
WHERE DOB >'1987-01-01' AND DOB <'1991-12-01';
(½ Mark for SELECT Eno,Name FROM Employee)
(½ Mark for
WHERE DOB BETWEEN '1987-01-01' AND '1991-12-01'
515
OR WHERE DOB >='1987-01-01' AND DOB <='1991-12-01'
OR WHERE DOB >'1987-01-01' AND DOB <'1991-12-01')
(iv) To count and display FEMALE employees who have joined after'1986-01-01'.
Ans SELECT count(*) FROM Employee
WHERE GENDER='FEMALE' AND DOJ > '1986-01-01' ;
OR
SELECT * FROM Employee
WHERE GENDER='FEMALE' AND DOJ > '1986-01-01' ;
(Any valid query for counting and/ordisplaying for female employeeswill be awarded 1 mark)
(v) SELECT COUNT (*), DCODE FROM EMPLOYEE
GROUP BY DCODE HAVING COUNT(*)>l;
Ans COUNT DCODE
2 D01
2 D05
(½ Mark for correct output)
(vi) SELECT DISTINCT DEPARTMENT FROM DEPT;
Ans Department
INFRASTRUCTURE
MARKETING
MEDIA
FINANCE
HUMAN RESOURCE
(½ Mark for correct output)
516
(vii) SELECT NAME, DEPARTMENT FROM EMPLOYEE E, DEPT D
WHERE E.DCODE=D.DCODE AND ENO<1003;
Ans NAME DEPARTMENT
George K INFRASTRUCTURE
Ryma Sen MEDIA
(½ Mark for correct output)
(viii) SELECT MAX (DOJ), MIN (DOB) FROM EMPLOYEE;
Ans MAX (DOJ) MIN(DOB)
2014-06-09 1984-10-19
(½ Mark for correct output)
Note: In the output queries, please ignore the order of rows.
6. (a) Verify the following using Boolean Laws : 2
U'+V = U'V'+ U' .V + U.V
Ans L.H.S
=U'+ V
=U'.(V+V') + V. (U' + U)
=U'. V + U' . V' + U' . V + U. V
=U'.V+U'.V'+U.V
=R.H.S
OR
R.H.S
=U' V'+U'. V + U, V
=U'.(V' + V) + U. V
=U'.1 + U. V
=U'+ U.V
517
=U'+ V
=L.H.S
(2 Marks for any valid verification using Boolean Laws)
OR
(1 Mark for partial correct verification using Boolean Laws)
(b) Draw the Logic Circuit for the following Boolean Expression : 2
(X'+Y).Z + W'
Ans
(½ Mark for X' and W')
(½ Mark for (X'+ Y')
(½ Mark for (X'+Y).Z)
(½ Mark for (X'+Y).Z+W')
(c) Derive a Canonical POS expression for a Boolean function F, representedby the following truth table : 1
p Q R F(P,Q,R)
0 0 0 1
0 0 1 0
0 1 0 0
0 1 1 1
1 0 0 1
1 0 1 0
1 1 0 0
1 1 1 1
518
Ans F(P,Q,R)= (P+Q+R')(P+Q'+R)(P'+Q+R')(P'+Q'+R)
OR
F(P,Q,R)= II(1,2,5,6)
(1 Mark for the correct POS form)
OR
(½ Mark for writing any two term correctly)
Note: Deduct ½ mark if wrong variable names are used
(d) Reduce the following Boolean Expression to its simplest form using K-Map: 3
F(X,Y,Z,W)= ∑(0,1,4,5,6,7,8,9,11,15)
Ans
Simplified Expression: Y'Z' + X'Y + XZW
(½ Mark for drawing K-Map with correct variable names)
(½ Mark for placing all 1s at correct positions in K-Map)
519
(½ Mark for each of three grouping Y'Z' , X'Y , XZW)
(½ Mark for writing final expression in reduced/minimal/nonredundant form as Y'Z' + X'Y + XZW )
Note: Deduct ½ mark if wrong variable names are used
7. (a) Illustrate the layout for connecting 5 computers in a Bus and a Star topologyof Networks. 1
Ans
OR any valid illustration of Bus and Star Topology.
(½ Mark for drawing each correct layout)
(b) What kind of data gets stored in cookies and how is it useful? 1
Ans When a Website with cookie capabilities is visited , its server sends certain
information about the browser, which is stored in the hard drive as a text file.
It's a way for the server to remember things about the visited sites.
(1 Mark for correct kind of data stored)
(c) Differentiate between packet switching over message switching? 1
Ans Packet Switching-follows store and forward principle for fixed packets.
Fixes an upper limit for packet size.
Message Switching-follows store and forward principle for complete
message. No limit on block size.
520
(1 Mark for any valid differentiation)
OR
(1 Mark for correct definition of Packet Switching only)
(d) Out of the following, which is the fastest (i) wired and (ii) wireless medium ofcommunication? 1
Infrared, Coaxial Cable, Ethernet Cable, Microwave, Optical Fiber
Ans (i) Wired - Optical Fiber
(ii) Wireless - Infrared OR Microwave
(½ Mark each for Wired and Wireless medium of communication)
(e) What is Trojan Horse? 1
Ans A Trojan Horse is a code hidden in a program, that looks safe but has hidden
side effects typically causing loss or theft of data, and possible system harm.
(1 Mark for writing correct meaning of Trojan)
(f) Out of the following, which all comes under cyber crime? 1
(i) Stealing away a brand new hard disk from a showroom.
(ii) Getting in someone's social networking account without his consentand posting on his behalf.
(iii) Secretly copying data from server of an organization and selling it tothe other organization.
(iv) Looking at online activities of a friends blog.
Ans (ii) & (iii)
(½ Mark for choosing each of the correct options)
Note:
No marks to be given, if all options are there in the answer
½ Mark to be deducted, if one extra option is given along with
the correct options
521
(g) Xcelencia Edu Services Ltd. is an educational organization. It is planning toset up its India campus at Hyderabad with its head office at Delhi. TheHyderabad campus has 4 main. buildings - ADMIN, SCIENCE, BUSINESSand ARTS. You as a network expert have to suggest the best network relatedsolutions for their problems raised in (i) to (iv), keeping in mind the distancesbetween the buildings and other given parameters.
DELHI HYDERABAD
Head Office Campus SCIENCE
ADMIN BUSINESS
ARTS
Shortest distances between various buildings :
ADMIN to SCIENCE 65m
ADMIN to BUSINESS 100m
ADMIN to ARTS 60m
SCIENCE to BUSINESS 75m
SCIENCE to ARTS 60m
BUSINESS to ARTS 50m
DELHI Head Office to HYDERABAD Campus 1600Km
Number of computers installed at various buildings are as follows:
ADMIN 100
SCIENCE 85
BUSINESS 40
ARTS 12
DELHI Head Office 20
522
(i) Suggest the most appropriate location of the server inside the
HYDERABAD campus (out of the 4 buildings), to get the best
connectivity for maximum number of computers. Justify your answer. 1
Ans ADMIN (due to maximum number of computers)
OR
ARTS (due to shorter distance from the other buildings)
(1 Mark for mentioning Correct building name with reason)
OR
(½ Mark to be deducted for not giving reason)
(ii) Suggest and draw the cable layout to efficiently connect various
buildings within the HYDERABAD campus for connecting the com-
puters. 1
Ans Anyone of the following
(1 Mark for drawing correct layout)
(iii) Which hardware device will you suggest to be procured by the
company to be installed to protect and control the internet uses within
the campus? 1
Ans Firewall OR Router
(1 Mark for correct Answer)
(iv) Which of the following will you suggest to establish the online face-
to-face communication between the people in the Admin Office of
HYDERABAD campus and DELHI Head Office? 1
523
(i) E-mail
(ii) Text Chat
(iii) Video Conferencing
(iv) Cable TV
Ans Video Conferencing
(1 Mark for correct Option / Answer)