נתונה השרשרת הבאה:
נתונה השרשרת הבאה:
exampleFigure: chain: [10, 12, 5, 3, 6, 1, 4]
confidence: HIGH — clean typeset boxes with arrows.
sourceErrataNote: GENUINE PAPER DEFECT (not a transcription error): in the C# section (page 21), all three method signatures — One, Two, Three — are printed using
Node<Integer>(Java's boxed generic type) instead of the correct C#Node<int>. Every method BODY call (HasNext(),SetValue(),GetNext(),GetValue()) is correctly C#-PascalCase; only the generic type-argument token is wrong, strongly suggesting a copy-paste-from-Java artifact left uncorrected by the exam's authors. Preserved verbatim below (Node<Integer>in the csharp variant) rather than silently 'fixed' toNode<int>— flagged here so this is not mistaken for our own transcription slip at solve/upload time.
עקבו אחרי זימון הפעולה הרקורסיבית one(chain) הבאה וכתבו איך תיראה השרשרת אחרי ביצוע הפעולה. כמו כן, כתבו מה מבצעת הפעולה one באופן כללי? יש להראות מעקב אחרי ביצוע הפעולה!
codeBlock:
public static void one(Node<Integer> n){
if(n.hasNext())
{
n.setValue(n.getNext().getValue());
one(n.getNext());
}
else
{
n.setValue(0);
}
}
נתונה הפעולה הרקורסיבית two הבאה, עקבו אחרי זימון הפעולה two(chain,10) ורשמו איך תיראה השרשרת אחרי ביצוע הפעולה? רשמו כמו כן מה מבצעת הפעולה באופן כללי! יש להראות מעקב אחרי ביצוע הפעולה!
codeBlock:
public static void two(Node<Integer> n, int num){
if(n.hasNext())
{
two(n.getNext(), num);
}
else
{
n.setValue(num);
}
}
exampleCall: two(chain, 10) / Two(chain, 10)
נתונה הפעולה three הבאה, מה יהיה תוכן השרשרת chain אחרי זימון הפעולה three(chain)? כתבו מה מבצעת הפעולה באופן כללי!
codeBlock:
public static void three(Node<Integer>n){
int x = n.getValue();
one(n);
two(n,x);
}
שאלות ותגובות על השאלה
🎓 לא הבנתם משהו? קבלו הסבר נוסף ממרצה לתכנות
שאלו כאן — ותקבלו מענה מוסמך.