Académique Documents
Professionnel Documents
Culture Documents
(AUTONOMOUS)
DEPARTMENT OF COMPUTER SCIENCE AND ENGINEERING
Subject Name: U14CS305 & Programming and Data structures
Year: II
Semester: III
Batch:2014-18
UNIT-1-QUESTION BANK
PART A-ONE MARK QUESTIONS
1.
2.
3.
4.
5
6.
7.
8.
9.
10.
11.
12
13
14
15
16
17
18
19
20
2.
3.
4.
5.
6.
a)
b)
c)
d)
O(2n)
O(n)
O(n3)
O(n2)
7.
8.
9.
10.
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.
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