BinarySearchTree

public enum BinarySearchTree<Value> where Value : Comparable
extension BinarySearchTree: ExpressibleByArrayLiteral

Undocumented

Cases

  • Undocumented

    Declaration

    Swift

    case empty
  • Undocumented

    Declaration

    Swift

    case leaf(Value)
  • Undocumented

    Declaration

    Swift

    indirect case node(BinarySearchTree, Value, BinarySearchTree)
  • Undocumented

    Declaration

    Swift

    public init<S>(_ sequence: S) where Value == S.Element, S : Sequence

Computed Properties

  • Declaration

    Swift

    public var count: Int { get }

    Return Value

    The amount of nodes contained herein.

  • Declaration

    Swift

    public var height: Int { get }

    Return Value

    The height of this BinarySearchTree.

  • Complexity

    O(n)

    Declaration

    Swift

    public var inOrder: [Value] { get }

    Return Value

    The values of the nodes contained herein in inOrder (sorted) order.

  • Declaration

    Swift

    public var minDescendent: BinarySearchTree { get }

    Return Value

    The left-most descendent.

  • Declaration

    Swift

    public var maxDescendent: BinarySearchTree { get }

    Return Value

    The right-most descendent.

Instance Methods

  • Declaration

    Swift

    public func inserting(_ newValue: Value) -> BinarySearchTree

    Return Value

    A BinarySearchTree with the given newValue inserted in the appropriate place.

  • Declaration

    Swift

    public func contains(_ value: Value) -> Bool

    Return Value

    true if this BinarySearchTree contains the given value. Otherwise, false.

  • Declaration

    Swift

    public func search(for target: Value) -> BinarySearchTree?

    Return Value

    The BinarySearchTree which contains the given target, if it exists. Otherwise, nil.

  • Declaration

    Swift

    public init(arrayLiteral elements: Value...)