נתונות שתי פעולות רקורסיביות הבאות:
נתונות שתי פעולות רקורסיביות הבאות:
language_variants: codeBlockOneTwo:
public static void One(Stack<int> s, int x){
if(s.IsEmpty())
s.Push(x);
else
{
int temp=s.Pop();
One(s,x);
s.Push(temp);
}
}
public static void Two(Stack<int> s){
if(!s.IsEmpty())
{
int x = s.Pop();
Two(s);
One(s,x);
}
}
codeBlockThree:
public static bool Three(Stack<int> s){
if(s.IsEmpty())
return true;
int x = s.Pop();
Two(s);
if(s.IsEmpty())
return true;
int y = s.Pop();
if(x % y != 0)
return false;
Two(s);
return Three(s);
}
namingConventionNote: In C# this paper capitalizes the method names One/Two/Three (matching the class-naming convention exactly) rather than the more common camelCase seen elsewhere in this exam's C# sections — still a casing-only delta, but flagged since it breaks the usual PascalCase-first-letter-only-differs-from-camelCase pattern seen in every other question (here the FULL identifier, including what would be a lowercase method name in idiomatic C#, is capitalized to literally match Java's method name capitalized).
מה יהיה התוכן של המחסנית s1 אחרי זימון הפעולה one(s1,10)/One(s1,10)? יש להראות מעקב אחרי ביצוע הפעולה one/One.
exampleFigure: s1: [3, -1, 7, 2]
confidence: MEDIUM — hand-drawn stack box, values read top-to-bottom, re-verify visually before use as a solve-oracle input.
מה מבצעת הפעולה one(s,x)/One(s,x) עבור מחסנית s של מספרים שלמים ומספר שלם x?
מה יהיה התוכן של המחסנית s1 אחרי זימון הפעולה two(s1)/Two(s1)? יש להראות מעקב אחרי ביצוע הפעולה two/Two. אין צורך במעקב אחרי הפעולה one/One.
מה מבצעת הפעולה two(s)/Two(s) עבור מחסנית s של מספרים שלמים?
מה תהיה תוצאת זימון הפעולה three(s2)/Three(s2)? יש להראות מעקב אחרי ביצוע הפעולה three/Three. אין צורך במעקב אחרי הפעולה two/Two.
exampleFigure: s2: [3, 6, 14, 2, 6, 3, 1]
שאלות ותגובות על השאלה
🎓 לא הבנתם משהו? קבלו הסבר נוסף ממרצה לתכנות
שאלו כאן — ותקבלו מענה מוסמך.