Correct. 2024/2025.
Given this snippet of code, identify the stopping condition and the return value.
void deleteList(struct contact* node) {
if (node == NULL) return;
else {
deleteList(node->next);
free(node);
}
}
if (node == NULL) return;
A merge-sort is typically implemented using
a function with two recursive calls.
A tail-recursive function is structurally equivalent to
a while loop
Which recursive functions require us to define more than one size-m problem?
Hanoi tower,Mergesort function
What is the time complexity of the insertion sort algorithm?
O(n*n)
The function searching a binary search tree can be easily implemented using a
a recursive function with two recursive calls.
The search algorithm will be more efficient if a binary search tree is
a balanced binary tree.
The complexity of searching a balanced binary search tree is the order of
O(lg n)
What are the key features of object orientation in programming languages? Select all that apply.
Dynamic memory allocation, Encapsulation of state
The purpose of the scope resolution operator is to allow a function to be
placed outside the class.
Which C/C++ operations will acquire memory from heap? Select all that apply. Choices: (malloc,
new, free, declaration)
malloc, new
, If a function calls another function, the local variables in these two functions use the memory from
different stack frames.
How is Java's garbage collection implemented?
It uses a reference counter to indicate if an object is still referenced by any variable.
What is the key difference between a static variable and a global variable?
They come from different parts of memory.
Given the snippet of code:
int x = 5;
int bar(int j) {
int *k = 0, m = 5;
k = &m;
return (j+m);
}
void main(void) {
static int i =0;
i++;
i = bar(i) + x;
}
Which variables obtain their memory from the stack? Select all that apply. Choices(I,j,k,m,x)
j,k,m
What is the best way of deleting a linked list of objects in C++?
Use a loop to delete every object in the linked list.
We need to write a destructor for a class, if
heap memory is used in the constructor of the class.
A piece of memory must be explicitly garbage-collected, if it comes from
heap
What is the best way of deleting an array created by "p = new StructType[size];" in C++?
delete[] p;
What members of a base class can be redefined in the derived classes?
virtual members
The semantics of multiple inheritance becomes complex and error prone, if the base classes have
overlapped members.
Given the code as follows:
main()
{
int i = 3, n;