The term used for the instantiation of a class. Example: Car Porsche;
What is an object?
This is the correct syntax to access the third element of a dynamic array arr.
What is arr[2]?
A symbol that can be placed before a variable to give its address in memory.
What is &?
This condition must be met to stop a recursive function from calling itself indefinitely.
What is the base case?
What keyword in C++ is used to define a constant variable whose value cannot be changed?
What is const?
This keyword is used to return memory to the system that was previously allocated using new.
What is delete?
This keyword is used to allocate memory for a dynamic array.
What is new?
A symbol that can be added in front of a pointer to retrieve data that pointer is pointing to (Deferencing).
What is *?
Recursion is often used to solve problems that can be broken down into these.
What are smaller subproblems?
In which algorithm are elements repeatedly swapped to sort the array until no more swaps are needed?
What is bubble sort?
This special function automatically cleans up the memory when an object is destroyed in C++.
What is a destructor?
A dynamic array-like container that is part of a C++ library and allows for dynamic sizing and automatic memory management
What is a vector?
This pointer is used in a linked list to point to the next node in the sequence.
What is the next pointer?
In recursion, this space is used to store information about each recursive call, such as parameters, return addresses, and local variables.
What is the call stack?
What is the term for the memory region where dynamically allocated memory (using new or malloc) is stored?
What is the heap?
This operator is used to access a member of a struct or class using a pointer to that object.
What is the arrow operator (->)?
A member function of the vector class, and is used to add an element to the end of the vector, dynamically increasing its size.
What is push_back()?
Inserting a node at the end of a linked list typically requires traversal starting from this.
What is the head node?
This is a recursive algorithm used for sorting that divides the array into halves.
What is Merge Sort (or Quicksort)?
This special function is used to create a new object as a copy of an existing object, ensuring that all member variables are correctly duplicated.
What is a copy constructor?
Given the following code snippet, what is the output?
struct Rectangle {
int width, height;
Rectangle(int w, int h) {
width = w;
height = h;
}
int area() { return width * height; }
};
int main() {
Rectangle rect(5, 10);
cout << rect.area();
}
What is 50?
Given the following code snippet, what is the output?
int* arr = new int[4]{5, 12, 3, 9};
int max = arr[0];
for (int i = 1; i < 4; i++) {
if (arr[i] > max) max = arr[i];
}
cout << "Max: " << max;
delete[] arr;
What is 12?
What does the following code print?
int main() {
int y = 5;
int x = 10;
int* ptr = &x;
int** ptr2 = &ptr;
cout << "Value of x: " << **ptr2 - y << endl;
return 0;
}
What is 5?
int fibonacci(int n) {
if (n == 0 || n == 1) {
return n;
}
?
}
This one line of code is the recursive part of the recursive function that calculates the nth Fibonacci number. And is represented by the ? above.
What is return fibonacci(n - 1) + fibonacci(n - 2); ?
What is the content of the vector after the following operations?
What is "9 3 12 8 5 4"?