1.Recursion[Mc00011
Which of the following is a reason that one might prefer a tail-recursive function over a function that is not tail-recursive?Pick ONE option
a tail-recursive function cannot cause an infinite loop
a (safely written) tail-recursive function will not produce a stack overflow
a tail-recursive function always requires fewer arguments than an equivalent
non-tail-recursive function there are some functions that can only be implemented using tail recursion
2. Stacks [MC0002]
For which of the following use cases would one employ a stack? Select all that apply.Pick ONE OR MORE options
buffering incoming messages, where earlier messages are to be processed before later ones
implementing a fixed-size ring buffer
checking if a string has balanced parentheses, brackets, and/or curly braces
performing a breadth-first search over a tree or a graph
reversing a singly-linked list
3. Mocking [Mc0007]
Which of the following components would one want to mock in a unit test? Select all that apply.Pick ONE OR MORE options
a component that interfaces with an external resource, such as a database, the file system, or the internet
a random number generator
algorithms from the C++ standard library
a logger
a component that exposes the current date and/or time
4.Algorithmic Complexity[Mc0010]
Which of the following is true of two distinct functions fn1 and fn2 that both exhibit 0 (m?) average time complexity? Pick ONE option
fn1 may be insertion sort, and fn2 may be bubble sort
ifll not capture anything from the surrounding scope
a lambda can be forward-declared, just like a functor class or struct
the call operator of a lambda is virtual
10.ODR IMC0034]
Which of the following are ways to avoid violating the one-definition rule? Select all that apply.Pick ONE OR MORE options
avoid using namespace declarations at global scope in header files
if a function is declared in Foo.h, define the function Foo.cpp
mark free, non-templated functions that are defined in header files with the inline keyword
never define a templated function and a non-templated function in the same namespace with the same name
declare global constants as either extern or constexpr inline
prefix macros with a custom sequence, such as a project slug or the author's initials |