Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

c++ Consider each of the following questions carefully. You are required to give

ID: 3850549 • Letter: C

Question

c++

Consider each of the following questions carefully. You are required to give the answer true or false and justify your answer. If it is true, explain why it is true. i. Linked lists are statically allocated. ii. Automatic variables are destroyed (deallocated) by the C++ runtime system. iii. You cannot make a reference to unallocated memory when using a vector. iv. The virtual keyword turns off runtime checking v. A doubly linked list uses twice as much space as a singly inked list. (b) Write a loop that will search an array of int values, myArray, to determine if it contains the integer value stored in a variable myInt and display the message "Found" if it finds it. Clearly comment your code. You may assume the myArray and myInt are both declared and initialised.

Explanation / Answer

a)

i. False

Linked lists are dynamically allocated because in Linked lists we don't know the quantity of data prior to the execution.

ii) True

Automatic variables in c++ will be automatically allocated and deallocated by runtime when the variable scope is completed.

iii) True

We can't make the reference to unallocated memory. Even if we do the program will crash or it will give undefined behaviour or it will throw an error. Sometimes it might compile also but will give undefined results.

iv) False

Virtual keyword is used to implement virtual function which makes the base class behaviour be overridden during the runtime.

v) True

Because in double linked list we need to store the previous node address also but in single linked list it only stores the next node address. So that double linked list takes twice space than single linked list.

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote