Rapid-Fire Challenge 1: Arrays and Vectors
Rapid-Fire Challenges
Rapid-fire challenges are a list of questions that aim to test your competency and higher-order thinking skills, applying the information you have learned throughout the course.
Challenge 1: Time Complexity And Sorting
Difficulty: Easy
Suppose that you are given an unsorted array. You are tasked to order the array elements using an algorithm such that you go through the array, find the smallest element, and emplace_back
said element to a second array of the same length. Determine the time complexity of this algorithm.
A. , because we just need to iterate through the array times.
B. , because the time will remain the same regardless of input size.
C. , because we will be iterating through the array of the input size.
D. , because we will need to iterate the array multiple times the input size in order to find the right order, considering that the array is unsorted.
Reveal Answer
C. , because we will be iterating through the array of the input size.
Challenge 2: N-Dimensional Time Complexity
Difficulty: Easy
You are given an 2-dimensional array. What is the time complexity of iterating over all the items in the 2-dimensional array?
A.
B.
C.
D.
Reveal Answer
A.
Challenge 3: Array Access
Difficulty: Hard
As mentioned earlier in the course, arrays are contiguous in memory. Take note of this. What might be the reason why index access in arrays are cheap? Choose the BEST answer.
A. Because arrays inherently provide an interface for easy indexing.
B. Because arrays are contiguous in memory, we can easily locate the nth index by skipping n times in memory.
C. Because it’s easier for the computer to remember where an element is in memory, since the elements are nearer to each other, in contrast to searching through the entire memory unit.
D. Because arrays are contiguous in memory, we can easily determine the nth index since it’s easier to iterate and move around in memory.
Reveal Answer
B Because arrays are contiguous in memory, we can easily locate the nth index by skipping n times in memory.
0%
CompletedYou have 20 sections remaining on this learning path.