請益一下,二元搜尋找到最大值,可以使用以下範例去證明之嗎。說明根的特性。
int left_child(int index) {return index * 2;}
int right_child(int index) {return index * 2 + 1;}
void binary_tree()
{
int tree[5 + 1];
cout << "根為" << tree[1];
cout << "根的左邊小孩是" << tree[left_child(1)];
cout << "根的右邊小孩是" << tree[right_child(1)];
}
--
All Comments