Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public void Add(int el, BSTIt pl = _head)
- {
- if (N == 0) {
- // делаем так же, как раньше
- _head = new BSTIt(el, null, null);
- N++;
- return;
- }
- if (if pl.Val == el) {
- // мы же не будем вторую вершину с таким же значением создавать?
- return;
- }
- if (if pl.Val > el) {
- if (pl.left != null) {
- Add(el, pl.left);
- } else {
- N++;
- new_vertex = BSTIt(el, null, null);
- pl.left = new_vertex;
- return;
- }
- }
- // пишем иф просто для красоты
- if (if pl.Val < el) {
- if (pl.right != null) {
- Add(el, pl.right);
- } else {
- N++;
- new_vertex = BSTIt(el, null, null);
- pl.right = new_vertex;
- return;
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement