Recuasrov
whet ig meant by Rewesion 2
when a funckion /Proteduce cols ite lt
Fundion — Recwsar [num tteger) — Renane Boncan
=~ = VE willl not chop
a - Recuccion Cnumat)
Enpeviercon
Note: The dota ewer the _cecursion gets store d in stacks
UE the fonction coll itsel® boo many Qenes
It tung oul of stads Space } chad over Pou
Base Gse: kis a caoditions! ctalement ubich is wed to
skop the _cecucsion Prom conkinuiny forever
Gewerar Cass = (s the elec chere the cenursive lds ac
made and beyestually cedues be base case.
)Pronusm
Recursion Wterabion Cmpecabive\
Bose Gost Qooes,
Genero Coxe,
Whol- is meant by CecurSive algorthens fest
Have a bag, se
work A cose | Ken cone
GMs _ikselé
(2) The olin racine poondure puts every IRAE on the positive parameter
The procedure checks ifthe integer parameter is ithe number is
——}—— _ odd, the procedure converts it to anis¥@iiniamibsr ——
The function Mon (ThisNum : INTEGER, ThisDiv : INTEGER) retums the remainde
value when ‘7h .stvum is divided by Thi sDiv.
| _ complete the pseudocode for the recursive procedure
PRoceDuRE count (ayvaive Number. 4. ; anteceR)
i. ~ ir Mon. (Number, 2) <> ott L 7 >
—— ae L
Herero aes seated
_| ENDIF
coreur ..... amber
| i ee oe
ENDIF
=
GL ; Ste
ENDIF
ENDPROCEDURE
ol
Question 2
(€) A program allows guests to input a meal option at a wedding.
Guests can choose meal option 1 or meal option 2.
‘The program will keep 8Uilof the numbers of each meal option chosen.
‘The program ends when a value other than ijor is entered. ERRERTSUIBUtsitnereountoRech
PROCEDURE MealsCount (BYREF MealOptionl : INTEGER, MealOption2 : INTEGER)
DECLARE Mealoption : INTEGER
DECLARE MoreMeals : BOOLEAN
MoreMeals «= True
WHILE MoreMeals = True
INPUT MealOption
IF Mealoption = 1
THEN
Mealoption! ¢ Mealoptionl + 1
ELSE
IF Mealoption = 2
THEN
Mealoption2 € Mealoption2 + 1
ELSE
OUTPUT Mealoptionl, " ", Mealoption2
MoreMeals < False
ENDIF
ENDIFFRoceovac Meals cast (Bye Neakeion 1 + integer Mealogian 2 ntegee )
Inpul Mealoption
AF mealoption
“1
Tren
ToveseToe (Weel Rectpittes) “tettppiater )
Evo
Outul “Wree C Reotesh leer | Dolo
VE “Tree Cot print esl - Right pointer <7 -1
Then
Traversctree (Weef rock goitter J+ right pace)
Svolr
Buwrroce nurs »
"Oy The Wa it sores Ls cds aeons ABabeOCaT Oa OT Bayer The as nade We
ist aways has a Pec value of 1. The poston ofthe rst node te irked its
‘Ano some processing, the ara a variabes ae inte sat a folows
Arwcuraive uncon vaveres te inked et to search ra payer.
‘An oxampe ol cating te uncon, using pseudocnde.
‘Complete the following pseudocode to implement the function Seas:
Thee
FUNCTION SearchList (Find 1 STRIW
IF scorer{Position) .player = AN.
seruan Positionaezuan Pasition,
ton © searentise (rina, SOCSE Baten] - ithe,
enon Reston
serum 99,
ERoFUNCTION
6
File 4
Fue 2
Quest on 2 Quebion 20
Sucstion 4 Question 23
Quostion 7 Qxedion 37
Queston 3
Question 47