Ace
Learns
Theme
light_mode
dark_mode
light_mode
Light
dark_mode
Dark
monitor
Auto
Open main menu
menu_open
×
Home
History
Geography
Astronomy
Physics
Chemistry
Biology
Agriculture
Sports
Computer Science
Articles
Contact Us
MCQ Categories
Articles
Home
Contact Us
Home
»
Computer Science
»
Analysis and Design of Algorithms
»
Space Complexity of Algorithms
Analysis and Design of Algorithms
unfold_more
double_arrow
Asymptotic Notations
double_arrow
Space Complexity of Algorithms
double_arrow
Time Complexity of Algorithms
quiz
Space Complexity of Algorithms
1.
What does space complexity in algorithms include?
A)
Input memory space
B)
Output memory space
C)
Both input space and auxiliary memory space
D)
The memory space used by the algorithm's variables
Answer
keyboard_arrow_down
keyboard_arrow_up
C) Both input space and auxiliary memory space
Explanation
2.
Which of the following indicates the most efficient use of memory in terms of input size n?
A)
O(1)
B)
O(logn)
C)
O(n)
D)
O(n
2
)
Answer
keyboard_arrow_down
keyboard_arrow_up
A) O(1)
Explanation
3.
What is the space complexity of an algorithm for storing elements in an array of size n?
A)
O(n)
B)
𝑂(1)
C)
O(logn)
D)
O(n
2
)
Answer
keyboard_arrow_down
keyboard_arrow_up
A) O(n)
Explanation
4.
What is the space and time complexity of the following code?
void example(int n) { int i, j; for (i = 0; i < n; i++) { printf("%d ", i); } for (j = 0; j < n; j++) { printf("%d ", j); } }
A)
Time Complexity: O(n), Space Complexity: O(n)
B)
Time Complexity: O(n), Space Complexity: O(1)
C)
Time complexity: O(n
2
), Space complexity: O(1)
D)
Time complexity is O(1), but space complexity is O(n)
Answer
keyboard_arrow_down
keyboard_arrow_up
B) Time Complexity: O(n), Space Complexity: O(1)
Explanation
Quick Links
Geography
chevron_right
Oceanography
chevron_right
Climatology
chevron_right
Geopolitics and Global Issues
chevron_right
Geomorphology
Sports
chevron_right
Football
chevron_right
Cricket
chevron_right
Common Wealth Games
chevron_right
Olympics
Chemistry
chevron_right
States of Matter and Solutions
chevron_right
Matter and Measurements
chevron_right
Acids Bases and Salts
chevron_right
Electronic Structure and Periodicity
History
chevron_right
Revolution and Counter-Revolution
chevron_right
Industrialization
chevron_right
Enlightenment and Modern ideas
chevron_right
Medieval World History