KEMBAR78
Quiz 1 - Data Structures & Algorithms (EL3101) | PDF | Algorithms | Applied Mathematics
0% found this document useful (0 votes)
72 views9 pages

Quiz 1 - Data Structures & Algorithms (EL3101)

Uploaded by

Bappy Agarwal
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
72 views9 pages

Quiz 1 - Data Structures & Algorithms (EL3101)

Uploaded by

Bappy Agarwal
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 9

Quiz 1 | Data Structures & Algorithms

(EL3101)
20 Marks | B. Tech. ELC 5th Semester | 3:10 PM to 3:40 PM

* Required

1. Name of the Student *

2. Registration Number *

3. Which of the following is true about Pseudo-code: * (1 Point)

It is a simplified, informal way of describing an algorithm.

It uses plain language mixed with programming constructs.

It is a high-level overview of a procedure applicable in several programming


languages

It is a set of guidelines, or a methodical process intended to accomplish a


certain task or solve a given problem
4. Let us consider a problem of finding the sum of marks secured by
student in all the courses. Consider the following Algorithm for the
above problem. What will be the Step 2 in the following Algorithm?

Algorithm
1.Initialize a variable total_sum to 0. This variable will store the
cumulative sum of the marks.
2.___________________________________.
3.For each mark, add its value to total_sum.
4.After the loop ends, total_sum will contain the sum of all the
marks. * (1 Point)

5. Which of the following is correct for computational complexity of


algorithms:
Statement 1: The amount of resources (such as time and space)
required for running them
Statement 2: Time Complexity measures the amount of memory an
algorithm uses as a function of the length of the input.
Statement 3: Space Complexity measures the amount of time an
algorithm takes to complete as a function of the length of the
input * (2 Points)

Statement 1 is correct

Statement 2 is correct

Statement 3 is correct

Statement 1 is not correct

Statement 2 is not correct

Statement 3 is not correct


6. Which of the following is true regarding Common Asymptotic
Notations:
Statement 1: Theta Notation (Θ) describes the upper bound of the
complexity. It gives the worst-case scenario of an algorithm's
running time.
Statement 2: Omega Notation (Ω) describes the lower bound of the
complexity. It gives the best-case scenario of an algorithm's
running time.
Statement 3: Big O Notation (O) describes the tight bound of the
complexity. It provides both the upper and lower bounds, giving an
exact asymptotic behavior.
* (2 Points)

Statement 1 is correct

Statement 2 is correct

Statement 3 is correct

Statement 1 is not correct

Statement 2 is not correct

Statement 3 is not correct


7. Match the correct Graphical Representation for Big O notation *
(1 Point)

Constant time Quadratic time

O(1)

O(n^2)

O(2^n)
8. Calculate the Big O notation time complexity for the following
code snippet:
def example(arr):
n = len(arr)
for i in range(n):
for j in range(n):
print(i, j)
* (1 Point)

O(n^2)

O(n)

O(2^n)

O(1)

9. What will be the Output of the following Code:

#include <stdio.h>
int sum_recursive(int n) {
if (n == 0) {
return 0;
} else {
return n + sum_recursive(n - 2);
}
}
int main() {
int n = 10;
printf("%d\n", sum_recursive(n));
return 0;
} * (1 Point)

30

55

Error
10. What will come in the fill in the blank of the following Code such
that the output is 35.

#include <stdio.h>
int drs(int n) {
if (n == 0) {
return 0;
} else {
return __________ + drs(n - 1);
}
}
int main() {
int n = 10;
printf("%d\n", drs(n));
return 0;
} * (1 Point)

11. What will come in the fill in the blank of the following Code such
that the output is 360.

#include <stdio.h>
int drs(int n) {
int result = 1;
for (int i = 1; i <= n; i++) {
result *= _________;
}
return result;
}
int main() {
int n = 4;
printf("%d\n", drs(n));
return 0;
} * (2 Points)
12. Consider a software firm developing a tool to generate a unique
password every time a user logs in some platform. Suppose
following code snippet generates a unique password at every
execution. What will come in the fill in the blanks A and B?

#include <stdlib.h>
#include <time.h>
int main() {
_______A______; // Fill in the blank A
printf("%d\n", _______B______); // Fill in the blank B
return 0;
} * (2 Points)

A is srand(time(0))

B is rand()

A is rand()

B is srand(time(0))

A is time(0)

B is time(rand())

A and B are rand()

A and B are srand()

A and B are srand(time(0))


13. What will be the output of the following code:
include <stdio.h>
int main() {
int abc[2][4] ={ {0,1,2,3}, {4,5,6,7}};
printf("%d ",abc[1]);
return 0;
} * (1 Point)

Memory address in hex

Memory address in integer

{4,5,6,7}

14. What is the maximum number of elements that can be stored in an


array in C? * (1 Point)

Depends on Memory

256

1000

Unlimited

15. What is the output of printf("%d",sizeof("Hello")); in C? * (1 Point)

2
16. What is the result of the expression sizeof(int) in C? * (1 Point)

16

17. How do you access the last element of an array arr with n elements
in C? * (1 Point)

arr[n]

arr[n-1]

arr[n+1

arr[last]

18. What will be the output of the program?


#include<stdio.h>
void main()
{
int a[5]={5,1,15,20,25};
int i,j,m;
i=++a[1];
j=a[1]++;
m=a[i++];
printf("%d,%d,%d",i,j,m);
} * (1 Point)

3,2,15

2,3,20

2,1,15

1,2,5
This content is neither created nor endorsed by Microsoft. The data you submit will be sent to the form owner.

Microsoft Forms

You might also like