m0_60797370 2022-04-29 17:11 采纳率: 0%
浏览 43
已结题

AVL tree和splay tree 无返回值的insert,remove等代码应该怎么写?

接口和返回类型都无法更改
AVL tree的初始代码如下:

package dsa.impl;

import dsa.iface.IPosition;

public class AVLTree<T extends Comparable<T>> extends BinarySearchTree<T> {

   @Override
   public void insert( T element ) {
      // TODO: Implement the insert(...) method.
   }

   @Override
   public boolean contains( T element ) {
      // TODO: Implement the contains(...) method.
      return false; // this line is here just so that the class will compile. You should replace it.
   }

   @Override
   public void remove( T element ) {
      // TODO: Implement the remove(...) method.
   }

   private void restructure( IPosition<T> x ) {
      // Implement the restructure(...) method.
   }

   @Override
   protected BTPosition newPosition( T element, BTPosition parent ) {
      return new AVLPosition( element, parent );
   }

   public class AVLPosition extends BTPosition {
      int height = 0;

      public AVLPosition( T element, BTPosition parent ) {
         super( element, parent );
      }
   }
}


求在二叉树中插入、移除和平衡节点的无返回值代码,可有偿!

  • 写回答

0条回答 默认 最新

    报告相同问题?

    问题事件

    • 系统已结题 5月7日
    • 创建了问题 4月29日