Python Round 4

Quiz
•
Computers
•
University
•
Hard
Noor Malik
FREE Resource
7 questions
Show all answers
1.
MULTIPLE CHOICE QUESTION
2 mins • 3 pts
What is the time complexity of the following C code snippet?
for (int i = 0; i < n; i++) {
for (int j = 0; j < n; j++) {
printf("%d, %d\n", i, j);
}
}
O(n)
O(n log n)
O(n^2)
O(2^n)
2.
MULTIPLE CHOICE QUESTION
2 mins • 3 pts
In a C++ program, if you have a loop that iterates through an array of size 'n' and performs a constant number of operations inside the loop, what is the time complexity of this operation?
O(1)
O(n)
O(log n)
O(n^2)
3.
MULTIPLE CHOICE QUESTION
2 mins • 3 pts
Consider the following C++ code snippet:
cpp
for (int i = 0; i < n; i++) {
for (int j = 0; j < m; j++) {
// Constant time operations
}
}
What is the time complexity of this code snippet?
O(n)
O(m)
O(n + m)
O(n * m)
4.
MULTIPLE CHOICE QUESTION
2 mins • 3 pts
You need to store a potentially very large number of records, with data being added as it arrives. You must retrieve a record by its primary key, which arrives randomly. Records may be deleted randomly, and all modifications need to be completed promptly after submission. The dataset size is unknown, and the implementation needs to be ready in a few weeks. Who is designing the program, but a co-op student will do the programming.
Which data structure would be most suitable for this scenario?
Ordered array
Heap
Hash table
Binary search tree
Unordered
5.
MULTIPLE CHOICE QUESTION
2 mins • 3 pts
You need to store a potentially very large number of records, with data being added as it arrives. You must retrieve a record by its primary key, which arrives randomly. Records may be deleted randomly, and all modifications need to be completed promptly after submission. The dataset size is unknown, and the implementation needs to be ready in a few weeks. Who is designing the program, but a co-op student will do the programming.
Which data structure would be most suitable for this scenario?
Unordered
Ordered array
Heap
Hash table
Binary seach tree
6.
OPEN ENDED QUESTION
2 mins • 3 pts
Optimize the given code using for loop instead of if else :-
def factorial(n):
if n == 0:
return 1
else:
return n * factorial(n - 1)
num = 5
result = factorial(num)
print(f"Factorial of {num} is: {result}")
Evaluate responses using AI:
OFF
7.
OPEN ENDED QUESTION
3 mins • 3 pts
Optimize the given code using for loop instead of if else :-
def factorial(n):
if n == 0:
return 1
else:
return n * factorial(n - 1)
num = 5
result = factorial(num)
print(f"Factorial of {num} is: {result}")
Evaluate responses using AI:
OFF
Similar Resources on Wayground
10 questions
csharp

Quiz
•
University
10 questions
Python Control Statements

Quiz
•
University
10 questions
Arrays in C (II yr 02.07.2020)

Quiz
•
University
10 questions
C Program Array and strings

Quiz
•
University
10 questions
T_4.2 Identifier, Data Types, Operators & Expressions

Quiz
•
12th Grade - University
11 questions
Quiz 2

Quiz
•
University
12 questions
C Basics

Quiz
•
University
10 questions
Lakshya2K24

Quiz
•
University
Popular Resources on Wayground
12 questions
Unit Zero lesson 2 cafeteria

Lesson
•
9th - 12th Grade
10 questions
Nouns, nouns, nouns

Quiz
•
3rd Grade
10 questions
Lab Safety Procedures and Guidelines

Interactive video
•
6th - 10th Grade
25 questions
Multiplication Facts

Quiz
•
5th Grade
11 questions
All about me

Quiz
•
Professional Development
20 questions
Lab Safety and Equipment

Quiz
•
8th Grade
13 questions
25-26 Behavior Expectations Matrix

Quiz
•
9th - 12th Grade
10 questions
Exploring Digital Citizenship Essentials

Interactive video
•
6th - 10th Grade
Discover more resources for Computers
15 questions
Let's Take a Poll...

Quiz
•
9th Grade - University
2 questions
Pronouncing Names Correctly

Quiz
•
University
12 questions
Civil War

Quiz
•
8th Grade - University
18 questions
Parent Functions

Quiz
•
9th Grade - University
21 questions
Mapa países hispanohablantes

Quiz
•
1st Grade - University
19 questions
Primary v. Secondary Sources

Quiz
•
6th Grade - University
25 questions
Identifying Parts of Speech

Quiz
•
8th Grade - University
20 questions
Disney Trivia

Quiz
•
University