using System.Collections; namespace tasks; /// /// Interface for an array-based binary tree. /// public interface IArrayBinaryTree : IEnumerable { /// /// Gets the number of nodes in the tree. /// int Count { get; } /// /// Gets the index of the root. /// int RootIndex { get; } /// /// Sets the value of the root node. /// void SetRoot(T value); /// /// Returns the indices of the left and right children for a given parent. /// (int leftIndex, int rightIndex) GetChildrenIndices(int parentIndex); /// /// Sets the value of the left child of a given parent. /// void SetLeftChild(int parentIndex, T value); /// /// Sets the value of the right child of a given parent. /// void SetRightChild(int parentIndex, T value); /// /// Gets the node at the specified index. /// T this[int index] { get; } /// /// Checks if a node at the specified index exists. /// bool Exists(int index); /// /// Clears all nodes from the tree. /// void Clear(); } /// /// An implementation of a binary tree based on an array. /// Indices are calculated as: /// - Left Child: 2 * i + 1 /// - Right Child: 2 * i + 2 /// - Parent: (i - 1) / 2 /// public class ArrayBinaryTree : IArrayBinaryTree { public T this[int index] { get { throw new NotImplementedException(); } } public int Count { get { throw new NotImplementedException(); } } public int RootIndex { get { throw new NotImplementedException(); } } public void Clear() { throw new NotImplementedException(); } public bool Exists(int index) { throw new NotImplementedException(); } public (int leftIndex, int rightIndex) GetChildrenIndices(int parentIndex) { throw new NotImplementedException(); } public IEnumerator GetEnumerator() { throw new NotImplementedException(); } public void SetLeftChild(int parentIndex, T value) { throw new NotImplementedException(); } public void SetRightChild(int parentIndex, T value) { throw new NotImplementedException(); } public void SetRoot(T value) { throw new NotImplementedException(); } IEnumerator IEnumerable.GetEnumerator() { return GetEnumerator(); } }