This operator is used with cin to extract input from the user.
What is >> (extraction operator)?
I'm like a class but with data members defaulting to public.
What is a struct?
This is the name of the first node in a linked list.
What is the head?
A function is said to be recursive if it does this.
What is calls itself?
This algorithm sorts elements by repeatedly swapping adjacent ones if they are in the wrong order.
What is Bubble Sort?
This operator is used with cout to display output.
What is << (insertion operator)?
A class that cannot be instantiated and is meant to be inherited is called this.
What is an abstract class?
In a singly linked list, each node contains these two components.
What are data/value and a pointer to the next node?
If recursive function does not cover this case, it will result in infinite recursion and stack overflow.
What is a base case?
This sorting algorithm repeatedly finds the smallest element from an unsorted part of the array and swaps it with the first unsorted element.
What is Selection Sort?
This header file must be included to use ifstream and ofstream
What is #include <fstream>
A function in a base class that is meant to be overridden in derived classes should be declared as this.
What is a virtual function?
A section of contigious/adjacent memory in which a pointer is incremented to iterate through the data structure.
What is an array?
This recursive algorithm is used to search an element in a sorted array in O(log n) time.
What is binary search?
The worst/average runtime of this algorithm is O(n^2)
What is bubble sort or what is selection sort?
Doing this at the end of file, which ensures data integrity, prevents resource leaks, and avoids potential conflicts.
What is closing a file?
This type of constructor initializes an object by copying another existing object.
What is a copy constructor?
I don't have to be used when I'm in the context of a class function, but I can help show I'm referencing the current instance of the class.
What is a 'this' pointer?
In recursion, the function calls are stored in this data structure
What is a stack?
This algorithm involves splitting an array until every subarray is sorted (i.e. consisting of 1 element).
What is merge sort?
What does count represent in this code snippet?
ifstream inputFile("input.txt");
if (!inputFile) {
cerr << "Error opening file!" << endl;
return 1;
}
char ch;
int count = 0;
while (inputFile.get(ch)) {
if (ch == 'a' || ch == 'A')
count++;
}
inputFile.close();
cout << count << endl;
return 0;
}
What is the number of time's the letter 'a' case insensitive occurred in the input file?
This snippet of code shows a class functionality example of:
TimeHrMn time1(3, 22);
TimeHrMn time2(2, 50);
TimeHrMn timeTot;
timeTot = time1 + time2;
timeTot.Print();
Operator Overloading
This code is an example of what:
~LinkedList() {
Node* current = head;
while (current) {
Node* temp = current;
current = current->next;
delete temp;
}
A destructor
int functionName(int n) {
if (n == 0 || n == 1) // Base case
return 1;
return n * functionName(n - 1); // Recursive case
}
The factorial of a number
void alg(vector<int>& arr) {
int n = arr.size();
for (int i = 0; i < n - 1; ++i) {
int minIndex = i;
for (int j = i + 1; j < n; ++j) {
if (arr[j] < arr[minIndex]) {
minIndex = j;
}
}
if (minIndex != i) {
swap(arr[i], arr[minIndex]);
}
}
}