DAA Quiz 1

Quiz
•
Computers
•
University
•
Hard
Aksheya Suresh
Used 26+ times
FREE Resource
10 questions
Show all answers
1.
MULTIPLE CHOICE QUESTION
30 sec • 1 pt
What is time complexity of fun()?
int fun(int n)
{
int count = 0;
for (int i = n; i > 0; i /= 2)
for (int j = 0; j < i; j++)
count += 1;
return count;
}
O(n2)
O(nLogn)
O(n)
O(nLognLogn)
2.
MULTIPLE CHOICE QUESTION
30 sec • 1 pt
What is the time complexity of fun()?
int fun(int n)
{
int count = 0;
for (int i = 0; i < n; i++)
for (int j = i; j > 0; j--)
count = count + 1;
return count;
}
Theta (n)
Theta (n2)
Theta (nLogn)
Theta (nLognLogn)
3.
MULTIPLE CHOICE QUESTION
20 sec • 1 pt
The recurrence relation capturing the optimal time of the Tower of Hanoi problem with n disc’s is
T(n)=2T(n–2)+2
T(n) = 2T(n – 1) + n
T(n)=2T(n/2)+1
T(n) = 2T(n – 1) + 1
4.
MULTIPLE CHOICE QUESTION
30 sec • 1 pt
Let w(n) and A(n) denote respectively, the worst case and average case running time of an algorithm executed on an input of size n. which of the following is ALWAYS TRUE?
A(n)=Omega(W(n))
A(n)=Theta(W(n))
A(n)=O(W(n))
None of these
5.
MULTIPLE CHOICE QUESTION
30 sec • 1 pt
Which of the given options provides the increasing order of asymptotic complexity of functions f1, f2, f3 and f4?
f1(n) = 2^n
f2(n) = n^(3/2)
f3(n) = nLogn
f4(n) = n^(Logn)
f3, f2, f4, f1
f3, f2, f1, f4
f2, f3, f1, f4
f2, f3, f4, f1
6.
MULTIPLE CHOICE QUESTION
30 sec • 1 pt
What is the best case time complexity of fun()?
void fun(int n, int arr[])
{
int i = 0, j = 0;
for(; i < n; ++i)
while(j < n && arr[i] < arr[j])
j++;
}
O(n)
O(n2)
O(nlogn)
O(n(logn)2)
7.
MULTIPLE CHOICE QUESTION
30 sec • 1 pt
In a competition, four different functions are observed. All the functions use a single for loop and within the for loop, same set of statements are executed. Consider the following for loops, If n is the size of input(positive), which function is most efficient (if the task to be performed is not an issue)?
for(i = 0; i < n; i++)
for(i = 0; i < n; i += 2)
for(i = 1; i < n; i *= 2)
for(i = n; i > -1; i /= 2)
Create a free account and access millions of resources
Similar Resources on Wayground
15 questions
ARRAYS AND FUNCTIONS

Quiz
•
University
10 questions
Basics of C

Quiz
•
University
9 questions
IPC144 SLG -- Week2

Quiz
•
University
15 questions
Actividad de Repaso - Semana 6

Quiz
•
University
10 questions
cp06-01-1D-Array

Quiz
•
University
15 questions
Searching and Sorting

Quiz
•
University - Professi...
10 questions
Java Arrays

Quiz
•
University
10 questions
Weekly Contest #6 - TechXNinjas

Quiz
•
University
Popular Resources on Wayground
10 questions
Video Games

Quiz
•
6th - 12th Grade
20 questions
Brand Labels

Quiz
•
5th - 12th Grade
15 questions
Core 4 of Customer Service - Student Edition

Quiz
•
6th - 8th Grade
15 questions
What is Bullying?- Bullying Lesson Series 6-12

Lesson
•
11th Grade
25 questions
Multiplication Facts

Quiz
•
5th Grade
15 questions
Subtracting Integers

Quiz
•
7th Grade
22 questions
Adding Integers

Quiz
•
6th Grade
10 questions
Exploring Digital Citizenship Essentials

Interactive video
•
6th - 10th Grade
Discover more resources for Computers
20 questions
Definite and Indefinite Articles in Spanish (Avancemos)

Quiz
•
8th Grade - University
7 questions
Force and Motion

Interactive video
•
4th Grade - University
36 questions
Unit 5 Key Terms

Quiz
•
11th Grade - University
7 questions
Figurative Language: Idioms, Similes, and Metaphors

Interactive video
•
4th Grade - University
15 questions
Properties of Equality

Quiz
•
8th Grade - University
38 questions
WH - Unit 3 Exam Review*

Quiz
•
10th Grade - University
21 questions
Advise vs. Advice

Quiz
•
6th Grade - University
12 questions
Reading a ruler!

Quiz
•
9th Grade - University