Miscellaneous Programming Quiz

(This quiz does not cover object-oriented programming or sorting algorithms.)

1. What is a sink in a directed graph?
__________________

2. What is the difference between a vertex and a node?
__________________

3. Space complexity of a program, or its memory usage requirements, are often irrelevant compared to the computational complexity of the solution.

True
False

4. What usually happens when a data set is too large for memory but the data set need to be ordered?

______________________________

5. How is an anchor case different from a base case in recursion?

a. An anchor case ensures the recursion doesn't go on forever, and the base case handles the iterations (the main benefit of recursion).
b. The case ensures the recursion doesn't go on forever, and the anchor case handles the iterations (the main benefit of recursion).
c. There is no such thing as an "anchor" case in recursion.
d. There is no such thing as a "base" case in recursion.
e. None of the above as they are synonyms.

6. What is the computational complexity of an operation going through a list of m lists with n items?

a. O(m)
b. O(n)
c. O (m log n)
d. O(n*m) (a quadratic)

7. What is the space complexity of an algorithm with an operation that exists simultaneously on the call stack for every list of m lists and every n item of those lists when the lists have a length of n?

a. O(1)
b. O(N)
c. O(m log n)
d. O(n log m)
e. O(n*m)

8. What is the space complexity of an operation going through a list of m lists where each list has n items with no simultaneous calls to the stack? The operation happens one at a time and does not simultaneously keep each individual operation on the stack.

a. O(1)
b. O(N)
c. O(m log n)
d. O(n log m)
e. O(n*m)

9. What is the significance of 10**9 + 7?

a. The highest integer value for a float.
b. The way to calculate pi to 9 decimal places.
c. 1000000007, a very large prime number used regularly in computer programming.
d. The largest known prime number.
e. None of the above

10. Can a Boolean conditional statement be considered ternary operator if there is one expression for True and one expression for False?

Yes.
No.

11. To do CI, you must have automated testing.

True
False

12. What could be the best space complexity of a given "for" loop that iterates through n items calling a function each time?

a. O(1)
b. O(n)
c. O(nlog(n))
d. None of the above.

13. What is a mutex?

a. A binary semaphore
b. A system-wide lock
c. A mutually exclusive lock
d. A concept for thread synchronization in multi-threading programming
e. All of the above.
f. None of the above

14. Which of the following statements is true for programs that solve problems with subproblems?

a. Dynamic programming excels when you do not need to compute every sub-problem and memoization is preferred when every sub-problem must be solved.
b. Memoization excels when you do not need to compute every sub-problem and dynamic programming is preferred when every sub-problem must be solved.
c. Dynamic programming is optimal compared to memoization.
d. Memoization is optimal compared to dynamic programming.
e. None of the above.

15. What is the computational complexity of looking for a node in a heap?

a. O(1)
b. O(log n)
c. O(n log n)
d. O(n)
e. None of the above.

16. What book says that "Representation is the essence of programming."?

a. The Art of Programming
b. The Mythical Man-Month
c. The Cathedral and the Bazaar
d. The DevOps Handbook
e. Refactoring by Beck and Fowler
f. Design Patterns: Elements of Reusable Object-Oriented Software
g. None of the above.

17. What are the differences between "string interpolation", "variable interpolation", "variable substitution", and "variable expansion"?
____________________


To see the answers, see this page.

Leave a comment

Your email address will not be published. Required fields are marked *