
DSA QUIZ 2
Authored by PUSHPALATHA C2114
Computers
University
Used 1+ times

AI Actions
Add similar questions
Adjust reading levels
Convert to real-world scenario
Translate activity
More...
Content View
Student View
10 questions
Show all answers
1.
MULTIPLE CHOICE QUESTION
30 sec • 1 pt
1.What will be the output of the following code snippet?
void solve() { int a[] = {1, 2, 3, 4, 5}; int sum = 0; for(int i = 0; i < 5; i++) { if(i % 2 == 0) { sum += a[i]; } } cout << sum << endl; }
5
15
9
12
2.
MULTIPLE CHOICE QUESTION
30 sec • 1 pt
2.
What is the output of the following code snippet?
void solve()
{
stack<int> s;
s.push(1);
s.push(2);
s.push(3);
for(int i = 1; i <= 3; i++)
{
cout << s.top() << “ “; s.pop();
}
}
3 2 1
1 2 3
3
1
3.
MULTIPLE CHOICE QUESTION
30 sec • 1 pt
3.What will be the output of the following code snippet?
void solve()
{
int n = 24;
int l = 0, r = 100, ans = n;
while(l <= r)
{
int mid = (l + r) / 2;
if(mid * mid <= n)
{
ans = mid;
l = mid + 1;
}
else
{
r = mid - 1;
}
}
cout << ans << endl;
}
5
4
6
3
4.
MULTIPLE CHOICE QUESTION
30 sec • 1 pt
4.What will be the value of “sum” after the following code snippet terminates?
void solve(ListNode* root)
{ /* The LinkedList is defined as:
root-> val = value of the node
root-> next = address of next element from the node The List is 1 -> 2 -> 3 -> 4 -> 5 */
int sum = 0;
while(root -> next != NULL)
{
sum += root -> val;
root = root -> next;
}
cout << sum << endl;
}
10
20
5
1
5.
MULTIPLE CHOICE QUESTION
30 sec • 1 pt
5.Which data structure is mainly used for implementing the recursive algorithm?
stack
queue
array
list
6.
MULTIPLE CHOICE QUESTION
30 sec • 1 pt
6.Consider a situation where a client receives packets from a server. There may be differences in speed of the client and the server. Which data structure is best suited for synchronization?
Circular Linked List
Queue
Stack
Priority Queue
7.
MULTIPLE CHOICE QUESTION
30 sec • 1 pt
7.A list of n strings, each of length n, is sorted into lexicographic order using merge - sort algorithm. The worst case running time of this computation is :
O(n log n)
O(n2log n)
O(n2 + log n)
O(n3)
Access all questions and much more by creating a free account
Create resources
Host any resource
Get auto-graded reports

Continue with Google

Continue with Email

Continue with Classlink

Continue with Clever
or continue with

Microsoft
%20(1).png)
Apple
Others
Already have an account?
Similar Resources on Wayground
10 questions
conversiones de bases
Quiz
•
University
14 questions
BÀI 14- THUẬT TOÁN TÌM KIẾM TUẦN TỰ
Quiz
•
6th Grade - University
10 questions
Adobe Photoshop
Quiz
•
University
10 questions
Choose the level of Bloom’s Taxonomy
Quiz
•
University
15 questions
After Effect Intoduction
Quiz
•
10th Grade - University
10 questions
Aprendeu ou disfarçou?
Quiz
•
12th Grade - Professi...
12 questions
Spreadsheet Starter
Quiz
•
7th Grade - University
15 questions
Archivos y Colecciones
Quiz
•
University
Popular Resources on Wayground
15 questions
Fractions on a Number Line
Quiz
•
3rd Grade
20 questions
Equivalent Fractions
Quiz
•
3rd Grade
25 questions
Multiplication Facts
Quiz
•
5th Grade
54 questions
Analyzing Line Graphs & Tables
Quiz
•
4th Grade
22 questions
fractions
Quiz
•
3rd Grade
20 questions
Main Idea and Details
Quiz
•
5th Grade
20 questions
Context Clues
Quiz
•
6th Grade
15 questions
Equivalent Fractions
Quiz
•
4th Grade