Vous êtes sur la page 1sur 3

VIVEKANANDHA COLLEGE OF ENGINEERING FOR WOMEN

(AUTONOMOUS)
DEPARTMENT OF COMPUTER SCIENCE AND ENGINEERING
Subject Name: U14CS305 & Programming and Data structures
Year: II

Semester: III

Branch: BE [CSE & EEE]

Batch:2014-18

UNIT-1-QUESTION BANK
PART A-ONE MARK QUESTIONS
1.
2.

3.
4.
5

6.

7.

C++ name was suggested by


a)
Ken Thompson
b) Rrick Mascitti
c)
Bjarne Stroustrup
d) Donald Knuth
When an object goes out of scope or is subjected to a delete is called _______
a)
constructor
b)
class
c)
method
d)
destructor
The process of building new class from the existing class
a)
Polymorphism
b) Structure
c)
Inheritance
d)Cascading
In C++, dynamic memory allocation is accomplished with the operator
a)
new
b) this
c) malloc
d) delete
A variable defined within a block is visible
a)
from the point of definition onward in the program
b)
from the point of definition onward in the function
c)
from the point of definition onward in the block
d)
None of these
The break statement cause an exit
a)
from the innermost loop only
b)
only from the innermost switch
c)
from all innermost loop and switch
d)
from all innermost loop or switch
Which of the following cannot be legitimately passed to a function
a)
A constant
b) A variable
c)
A structure
d) A header file

8.

9.
10.
11.
12
13
14

15

----------- is automatically called when object is created


a)
constructor
b)
class
c)
method
d)
destructor
Identify the operator that is NOT used with pointers
a)
->
b) &
c)*
d)>>
How many types of files used in C++
a) 4
b) 3
c)2
d)1
Which symbol is used before destructor
a)
^
b) &
c) ~
d) *
The operator that cannot be overloaded is
a)
++
b) ::
c) ~
d) ()
The members of a class by default are
a)
public
b) protected
c)
private
d) mandatory to specify
Big-Omega notation expresses
a)
tight bounds
b)
upper bounds
c)
lower bounds
d)
worst cases
Big-O notation expresses
a)
tight bounds
b)
upper bounds
c)
lower bounds
d)
worst cases
1

16

Best case for an algorithm


a)
takes the same time for all data;
b)
assumes the data that the algorithm handles in the greatest time;
c)
assumes the data that the algorithm handles in the least time;
d)
is the expected time considering all possible input data;
Worst case for an algorithm
a)
takes the same time for all data;
b)
assumes the data that the algorithm handles in the greatest time;
c)
assumes the data that the algorithm handles in the least time;
d)
is the expected time considering all possible input data;
Average case for an algorithm
a)
takes the same time for all data;
b)
assumes the data that the algorithm handles in the greatest time;
c)
assumes the data that the algorithm handles in the least time;
d)
is the expected time considering all possible input data;
Which indicates how fast the algorithm runs?
a)
Time Efficiency
b)
Space Efficiency
c)
Big-Omega notation
d)
Big-O notation
Which indicates how much extra memory the algorithm needs?
a)
Time Efficiency
b)
Space Efficiency
c)
Big-Omega notation
d)
Big-O notation

17

18

19

20

PART-B TWO MARKS


1.

2.

3.

4.

5.

6.

What is the output of the following code


char symbol[3] = {a,b,c};
For(int index=0;index<3;index++)
Cout<<symbol[index];
a) abc
b) abc
c)a b c
d)abc
If the variable count exceeds 100, a singly statement that prints Too many is
a)
If (count<100) cout<<Too many;
b)
If (count>100) cout>>Too many;
c)
If (count>100) cout<<Too many;
d)
None of these
If an array is declared as
int a[4] = {3,0,1,2}, then values assigned to a[0] & a[4] will be
a)
3,2
b) 0,2
c)
3,0
d) 0,4
Function g is a lower bound on function f if for all x
a)
g(x) f (x);
b)
g(x) f (x);
c)
f = O(g);
d)
g = (f);
What is the frequency count for the following code?
For(i=0;i<n; i++)
{
sum=sum+a[i];
}
a)
O(2n)
b)
O(n)
c)
O(n3)
d)
O(n2)
What is the Time Complexity for the following code?
for(i=0;i<n;i++) {
For(j=0;j<n;j++)
{ c[i][j]=a[i][j]+b[i][j];
}
}
2

a)
b)
c)
d)

O(2n)
O(n)
O(n3)
O(n2)

7.

8.

9.

10.

The Condition 0 f(n) cg(n) represents


a)
Asymptotic lower bound
b)
Asymptotic Upper bound
c)
Asymptotic Tight bound
d)
None of these
Find the Time Complexity of the following Recurrence relation.
T(n)=9T(n/3) + n
a)
O(2n)
b)
O(n)
c)
O(n3)
d)
O(n2)
Function g is a upper bound on function f if for all x
a)
g(x) f (x);
b)
g(x) f (x);
c)
f = O(g);
d)
g = (f);
What would be the output of the following?
#include<iostream.h>
void main() {
char *ptr=abcd
char ch;
ch = ++*ptr++;
cout<<ch; }
a)
a
b) b
c)c d)d

PART-C
1. For each of the following three program fragment give an analysis of the running time
calculation,
i)

sum=0;
for(i=0;i<n;i++)
for(j=0;j<n*n;j++)
sum++;
ii) sum=0;
for(i=0;i<n;i++)
for(j=0;j<i*i;j++)
for(k=0;k<j;k++)
sum++;
iii) sum=0;
for(i=1;i<n;i++)
for(j=1;j<i*i;j++)
if(j%i==0)
for(k=0;k<j;k++)
sum++;
2. a)Differentiate Time Complexity and Space Complexity with suitable example.(5)
b)In C++ , When the Default do not work?(5)
3.

Illustrate with an example theBig Three:Destructor,Copy Constructor,Operator =.(10)

4. Explain how Objects can be created dynamically. Write a C++ program to implement the
concept of constructor.
5. Characterize the asymptotic notations used for best case, average case and worst case
analysis of algorithm.
6. Estimate the resource use of algorithm with the help of mathematical definition.
7. Elucidate three parameter passing mechanisms and illustrate the following function
declaration that returns the average of the first n integers in arr, and sets errorFlag to true if n
is larger than arr.size() or smaller than1.
double avg (const vector<int> &arr, int n ,bool & errorFlag);
8. Illustrate the explicit constructor and constant member function with example
3

Vous aimerez peut-être aussi