What fundamental runtime characteristic differentiates a recursive function from an iterative loop performing an equivalent repetitive computation?
Algorithm Design And Computational Complexity
Question · Easy
What is the primary operational role of the base case (condiție de oprire) in a recursive subprogram?
Consider the following recursive C++ function: int f(int n) { if (n <= 1) return 1; return n + f(n - 2); } What is the integer value returned by the call f(7)?
Question · Medium
When applying the Euclidean algorithm using modulo division to find the greatest common divisor (GCD) of 84 and 30, how many modulo/division operations are executed, and what is the final GCD?
Consider the following algorithm expressed in pseudocode: s = 0 while n > 0 do d = n mod 10 if d mod 2 == 0 then s = s + d end if n = n div 10 end while return s What value is returned when the algorithm is executed with the input n = 4728?
In standard modern 32-bit and 64-bit C++ environments, what is the typical memory footprint and signed integer numerical range of the standard int data type?
Structured Programming And Implementation
What are the evaluated numerical results of the integer division 19 / 4 and modulo 19 % 4 in standard C++?
Which Boolean logical operator evaluates to true if and only if BOTH operands evaluate to true?
In C++, what occurs when a case block within a switch statement does NOT conclude with a break statement?
What operational guarantee fundamentally distinguishes a post-test loop (do-while in C++, repeat-until in Pascal) from a pre-test loop (while)?
In C++, what is the primary consequence of passing an argument to a function parameter declared by reference (e.g., void compute(int &x)) versus by value (void compute(int x))?
What is the scope and storage lifetime of an ordinary (non-static) local variable declared inside a block in a C++ function?
What is the value of the integer variable result after executing the following expression in C++? int result = 5 + 3 * 4 - 14 / 4 % 3;
What is printed to standard output when the following C++ code executes? int a = 0, b = 10; if (a != 0 && (b / a > 2)) { cout << "Yes"; } else { cout << "No"; }
How many total times will the body of the following for loop execute in C++? for (int i = 2; i <= 26; i += 4) { // loop body }
Trace the following nested conditional logic in C++ for an input score of 78: string grade; if (score >= 90) grade = "A"; else if (score >= 80) grade = "B"; else if (score >= 70) grade = "C"; else if (score >= 60) grade = "D"; else grade = "F"; What string value is assigned to grade?
What is the structural and semantic distinction between a C++ void function (or Pascal procedure) and a non-void function (or Pascal function)?
Consider the following C++ program: void modify(int a, int &b) { a = a + 5; b = b + 10; } int main() { int x = 10, y = 20; modify(x, y); cout << x << " " << y; return 0; } What is printed to standard output?
Consider the following C++ variable initialization: int a = 9, b = 2; double result = a / b; What value is stored in result?
How does the evaluation logic of the exit condition in a Free Pascal repeat ... until (condition) loop differ from a C++ do ... while (condition) loop?
What happens when a programmer attempts to assign a new value to a variable declared with the const qualifier in C++ (e.g., const int MAX = 100; MAX = 200;)?
Consider the following recursive function with a reference parameter: void p(int &x, int y) { if (y > 0) { x += 2; p(x, y - 1); x += 1; } } If int a = 0; is defined and p(a, 3); is called, what is the final value of variable a in the caller?
Question · Hard
How does array indexing fundamentally differ between C++ arrays and standard Free Pascal arrays?
Data Structures And File Processing
Given the 0-indexed array int arr[6] = {12, 45, 7, 89, 23, 89};, what is the zero-based index of the FIRST occurrence of the maximum value?
In an n x n square matrix represented as a 2D array matrix[i][j] (where 0 <= i, j < n), which condition uniquely identifies elements situated on the main (principal) diagonal?
In an n x n square matrix in C++ with 0-based row and column indices (0 <= i, j < n), which index relationship characterizes elements located on the secondary diagonal?
In C++, what character is placed in memory to designate the termination of a standard C-style character string (null-terminated string)?
What integer value is returned by the standard C++ library function strlen("Moldova")?
In C++, which file opening mode flag ensures that newly written data is appended to the end of an existing file without truncating or overwriting its prior contents?
In Free Pascal, which built-in Boolean function returns true when the file read cursor has reached or passed the end of an open text file?
Which loop structure and swap statement correctly reverses the elements of a 1D array arr of size n in place in C++?
To delete an element at index k (where 0 <= k < n) from a 1D array of size n in C++, which shifting operation must be performed before decrementing n?
Consider the following 4x4 matrix M: 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 What is the arithmetic sum of the elements situated STRICTLY ABOVE the principal diagonal (i < j)?
In a 3x3 matrix M with elements: 1 2 3 4 5 6 7 8 9 Which set of elements is situated STRICTLY BELOW the secondary diagonal (i.e., where i + j > n - 1 with n = 3)?
Which nested loop structure correctly transposes an n x n square matrix A in place without redundantly swapping elements back to their initial positions?
When using the standard C-string library function strcat(dest, src) in C++, what critical safety prerequisite must the programmer verify?
What does the standard function strcmp(s1, s2) return when string s1 is lexicographically GREATER than string s2 (e.g., strcmp("zebra", "alpha"))?
Consider the following C++ function designed to test whether a C-string is a palindrome: bool isPalindrome(char s[], int len) { for (int i = 0; i < len / 2; i++) { if (s[i] != s[len - 1 - i]) return false; } return true; } What are the returned Boolean values for the calls isPalindrome("radar", 5) and isPalindrome("bac", 3)?
Consider the following structured data type definition in C++: struct Student { char name[30]; int grade; double avgScore; }; Student s = {"Elena", 12, 9.45}; Which expression correctly updates the student's avgScore to 9.80?
Given an array of structures Student list[100];, which comparison condition inside a standard sorting algorithm sorts students in DESCENDING order of their avgScore?
In C++, what is the standard, idiomatic loop construct used to read whitespace-delimited integers sequentially from an open input file stream ifstream fin("numbers.in"); until EOF?
A square matrix A of dimensions n x n is mathematically symmetric with respect to its principal diagonal if and only if which property is satisfied for all indices 0 <= i, j < n?
In a 2D matrix of dimensions m rows by n columns (where m > 1 and n > 1), what formula computes the total count of boundary (contour / perimetru) elements located on the outer border?
What is the optimal asymptotic time complexity of merging two previously sorted 1D arrays of sizes m and n into a single sorted array of size m + n using the two-pointer technique?
In Free Pascal, how does a typed binary file (file of SomeType) fundamentally differ in storage and access from a standard text file (text)?
What is the decimal (base 10) representation of the unsigned binary number 101101_2?
Information Technology Databases And Systems
What is the hexadecimal (base 16) representation of the decimal integer 250?
What is the defining truth condition for the Boolean XOR (Exclusive OR) logical operation between two inputs A and B?
Loading more…