⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 binnodeptr.java

📁 基于图形的二叉树工作演示程序
💻 JAVA
字号:
// Source code example for "A Practical Introduction
// to Data Structures and Algorithm Analysis"
// by Clifford A. Shaffer, Prentice Hall, 1998.
// Copyright 1998 by Clifford A. Shaffer

// Binary tree node with pointers to children
package myBag;
public class BinNodePtr implements BinNode {
  private Object element; // Object for this node
  private BinNode left;   // Pointer to left child
  private BinNode right;  // Pointer to right child

  public BinNodePtr() {left = right = null; } // Constructor 1
  public BinNodePtr(Object val) {             // Constructor 2
    left = right = null;
    element = val;
  }

  public BinNodePtr(Object val, BinNode l, BinNode r) // Construct 3
  { left = l; right = r; element = val; }

  // Return and set the element value
  public Object element() { return element; }
  public Object setElement(Object v) { return element = v; }

  // Return and set the left child
  public BinNode left() { return left; }
  public BinNode setLeft(BinNode p) { return left = p; }

  // Return and set the right child
  public BinNode right() { return right; }
  public BinNode setRight(BinNode p) { return right = p; }

  public boolean isLeaf()  // Return true if this is a leaf node
  { return (left == null) && (right == null); }
} // class BinNodePtr

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -