Recursivitate

Quiz
•
Computers
•
11th Grade
•
Hard
Laurentiu Lambrinoc
Used 1+ times
FREE Resource
9 questions
Show all answers
1.
MULTIPLE CHOICE QUESTION
5 mins • 1 pt
Subprogramele f1, f2 și f3 sunt definite mai jos.
int f1(int n) { return n*(n+1)/2; }
int f2(int n) { if(n!=0) return n+f2(n-1); return 0; }
int f3(int n) { if(n==0) return 0; if(n%2==1) return n+f3(n-1); return n*n/4+2*f3(n/2); }
Pentru n=24, se obține aceeași valoare la apelul subprogramelor:
f1 și f2
f1 și f3
f2 și f3
a. f1, f2 și f3
2.
MULTIPLE CHOICE QUESTION
2 mins • 1 pt
Subprogramul f este definit alăturat. Indicați valoarea f(3,2).
int f(int x, int y) { int z; if (y==0) return 1; z=f(x,y/2); if (y%2!=0) return z*z*x; return z*z; }
1
2
9
18
3.
MULTIPLE CHOICE QUESTION
2 mins • 1 pt
Subprogramul f este definit alăturat. Indicați valoarea lui f(2023).
int f(int n) { if(n==0) return 0; if(n%10==2) return f(n/10)*10+3; return f(n/10)*10+2; }
3232
2303
3332
5355
4.
MULTIPLE CHOICE QUESTION
2 mins • 1 pt
Subprogramul f este definit alăturat. Indicați valoarea f(35,3).
int f(int n,int k) { if(n==0 || k==0) return 0; return n%k+10*f(n/k,k); }
33
355
102
1022
5.
MULTIPLE CHOICE QUESTION
3 mins • 1 pt
Subprogramul f este definit alăturat. Indicați un apel în urma căruia în șirul afișat există două valori egale cu 23.
void f(int m, int n) { cout<<(m+n)/2><<' '; if(m<=n) f(m+1,n-2); }
f(20,23);
f(20,26);
f(21,25);
f(21,27);
6.
MULTIPLE CHOICE QUESTION
2 mins • 1 pt
Subprogramul f este definit alăturat. Indicați valoarea parametrului x pentru care f(x,3) are valoarea 2022. int f(int n,int p) { if(n==0) return 0; else if(p==0) return n*10+2; else return f(n/10,p-1); }
120234
122023
220223
202345
7.
MULTIPLE CHOICE QUESTION
3 mins • 1 pt
Subprogramul f este definit alăturat.
int f(int st,int dr,int v[]) { if(st==dr) if(v[st]==st)return 1; else return 0; else return f(st,(st+dr)/2,v) + f(1+(st+dr)/2,dr,v); }
Știind că variabila x memorează un tablou unidimensional cu elementele (7,1,2,5,4), în această ordine, numerotate de la 0 la 4, indicați valoarea f(0,4,x).
2
3
4
5
8.
MULTIPLE CHOICE QUESTION
1 min • 1 pt
Subprogramul f este definit alăturat, parțial. Indicați o expresie care poate înlocui punctele de suspensie astfel încât, f(2021, 1880) să aibă valoarea celui mai mare divizor comun al numerelor 2021 și 1880.
int f (int x, int y) { if(y==0) return x; else return.............; }
f(x,y%x);
f(y,x%y);
f(x%y,y);
f(y%x,x)
9.
MULTIPLE CHOICE QUESTION
2 mins • 1 pt
Subprogramul afis este definit alăturat. Indicați ce se afișează în urma apelului de mai jos. afis(12345);
void afis (int a) { cout<<”+”; if(a>0) { afis(a/1000); cout<<a;} cout<<”+”;}
+12345+123+1+
+1+123+12345+
++++12+12345+
++++112312345
Similar Resources on Wayground
10 questions
Objects & Classes

Quiz
•
11th - 12th Grade
10 questions
Recursion in Java (AP Computer Science A)

Quiz
•
9th - 12th Grade
12 questions
C++ References

Quiz
•
6th - 12th Grade
6 questions
Прогаем задания ЕГЭ

Quiz
•
11th Grade
14 questions
Python Topics 1 & 2

Quiz
•
11th Grade
10 questions
Ввод, вывод данных

Quiz
•
9th - 12th Grade
6 questions
Topic 6.1 Video 2

Quiz
•
11th Grade
10 questions
Python User Input Quiz

Quiz
•
6th Grade - University
Popular Resources on Wayground
10 questions
Lab Safety Procedures and Guidelines

Interactive video
•
6th - 10th Grade
10 questions
Nouns, nouns, nouns

Quiz
•
3rd Grade
10 questions
9/11 Experience and Reflections

Interactive video
•
10th - 12th Grade
25 questions
Multiplication Facts

Quiz
•
5th Grade
11 questions
All about me

Quiz
•
Professional Development
22 questions
Adding Integers

Quiz
•
6th Grade
15 questions
Subtracting Integers

Quiz
•
7th Grade
9 questions
Tips & Tricks

Lesson
•
6th - 8th Grade
Discover more resources for Computers
20 questions
Digital Citizenship

Quiz
•
8th - 12th Grade
35 questions
Computer Baseline Examination 2025-26

Quiz
•
9th - 12th Grade
13 questions
Problem Solving Process

Quiz
•
9th - 12th Grade
10 questions
Understanding Algorithms with Pseudocode and Flowcharts

Interactive video
•
9th - 12th Grade
19 questions
AP CSP Unit 1 Review (code.org)

Quiz
•
10th - 12th Grade