11. Given the following lines of code pseudocode:
N = 10
FOR i = 1 TO 5:
FOR j = 1 TO i:
output(i*j)
- O(Log N)
- O(1)
- O(n^2)
12. Given the following lines of code pseudocode: output(N)
N = 7
FOR i = 1 TO N:
FOR j = 1 TO N:
output(N)
- O(1)
- O(N)
- O(n^2)
Knowledge check: Space complexity
13. Given an array that holds 12 integers at 4bytes per integer, contains an additional 12 bytes for the header and 4 bytes for padding. What is the total space complexity for this data structure?
- 16
- 48
- 64
14. A program requires two arrays to compute a function. First array has a header of 12 bytes, and padding of another 4 bytes. It contains 8 integers of 4 bytes each. The second array also has a header of 12 bytes and 4 bytes padding. The second array contains 24 integers of 4 bytes each. What is the input space of this function?
- 160
- 128
- 32
15. Changing the values in an array leads to greater space complexity over creating a new array and copying in the values?
- True
- False
17. What does auxiliary space refer to?
- Virtual memory
- The space used to store data that the CPU is processing
- It is the space required to hold any additional variables used in the computations of an application.
Module quiz: Introduction to the coding interview
18. What should be done when presented with a technical problem where the solution is not immediately obvious?
- Ask the interviewer how they would solve the problem.
- Ask questions.
- Move the conversation along and try not to draw attention.
Shuffle Q/A 2
19. During a technical interview, is it better to rely on the work of others, or code everything yourself?
- Use code written by others.
- Use the data structures, but don’t use any other external implementation.
- Write as much code as you can to show off your skills.
20. Given an array that represents sock colors: Sock_colors = [3,3,2,1,1,3,5,1,4,2], how many pairs of the same color socks exist?
- 4
- 3
- 2