לפניך המחלקה טבעת - Ring שלה שתי תכונות:
Java Code:
java1public class Ring 2{ 3 private String size; // גודל הטבעת 4 private int color; // צבע הטבעת 5 public Ring() 6 { 7 this.size = "L"; 8 this.color = 0; 9 } 10 public Ring(String str, int c) 11 { 12 this.size = str; 13 this.color = c; 14 } 15 public String getSize() 16 { 17 return this.size; 18 } 19 public int getColor() 20 { 21 return this.color; 22 } 23}
C# Code:
csharp1public class Ring 2{ 3 private string size; // גודל 4 private int color; // צבע הטבעת 5 public Ring() 6 { 7 this.size = "L"; 8 this.color = 0; 9 } 10 public Ring(string str, int c) 11 { 12 this.size = str; 13 this.color = c; 14 } 15 public string GetSize() 16 { 17 return this.size; 18 } 19 public int GetColor() 20 { 21 return this.color; 22 } 23}
לפניך ממשק המחלקה מוט Pole:
public Pole()public Pole()public void add(Ring r)public void Add(Ring r)public Ring remove()public Ring Remove()public boolean isEmpty()public bool IsEmpty()public void sort()public void Sort()ממש את הפעולה sort() ב-Java או Sort() ב-C# שבמחלקה Pole. אתה יכול להשתמש בפעולות הנוספות של המחלקה Pole בלי לממש אותן. בתשובתך השתמש רק בפעולות המחלקות Pole ו-Ring.
מהי סיבוכיות זמן הריצה של הפעולה שמימשת בסעיף א? נמק את תשובתך.
לפניך המחלקה טבעת - Ring שלה שתי תכונות:
Java Code:
java1public class Ring 2{ 3 private String size; // גודל הטבעת 4 private int color; // צבע הטבעת 5 public Ring() 6 { 7 this.size = "L"; 8 this.color = 0; 9 } 10 public Ring(String str, int c) 11 { 12 this.size = str; 13 this.color = c; 14 } 15 public String getSize() 16 { 17 return this.size; 18 } 19 public int getColor() 20 { 21 return this.color; 22 } 23}
C# Code:
csharp1public class Ring 2{ 3 private string size; // גודל 4 private int color; // צבע הטבעת 5 public Ring() 6 { 7 this.size = "L"; 8 this.color = 0; 9 } 10 public Ring(string str, int c) 11 { 12 this.size = str; 13 this.color = c; 14 } 15 public string GetSize() 16 { 17 return this.size; 18 } 19 public int GetColor() 20 { 21 return this.color; 22 } 23}
לפניך ממשק המחלקה מוט Pole:
public Pole()public Pole()public void add(Ring r)public void Add(Ring r)public Ring remove()public Ring Remove()public boolean isEmpty()public bool IsEmpty()public void sort()public void Sort()ממש את הפעולה sort() ב-Java או Sort() ב-C# שבמחלקה Pole. אתה יכול להשתמש בפעולות הנוספות של המחלקה Pole בלי לממש אותן. בתשובתך השתמש רק בפעולות המחלקות Pole ו-Ring.
מהי סיבוכיות זמן הריצה של הפעולה שמימשת בסעיף א? נמק את תשובתך.