Questions
Questions

CPT_S-355-PULLM-1-LEC Scheduled Quiz 1

Single choice

Why is the following function `impure`?

Options
A.Because it allocates memory dynamically when creating a vector of integers.
B.Because it prints the content of the vectors using a loop into the console output
C.Because it uses loops instead of recursion.
D.Because it depends on an external data source whose contents may change between calls.
Question Image
View Explanation

View Explanation

Verified Answer
Please login to view
Step-by-Step Analysis
To evaluate why the function is impure, we need to inspect what the function does and whether its behavior can vary across calls. Option 1: 'Because it allocates memory dynamically when creating a vector of integers.' Dynamic memory allocation by itself does not necessarily imply impurity; in many languages and contexts, it can be considered a normal, pure operation as long as it doesn't depend on external state or mutate shared state. On its own, al......Login to view full explanation

Log in for full answers

We've collected over 50,000 authentic exam questions and detailed explanations from around the globe. Log in now and get instant access to the answers!

More Practical Tools for Students Powered by AI Study Helper

Join us and instantly unlock extensive past papers & exclusive solutions to get a head start on your studies!