Consider a sorted binary tree data structure for storing integers. Write invariants in OCL denoting that

a. All nodes in the left subtree of any node contain integers that are less than or equal to the current node, or
the subtree is empty.
b. All nodes in the right subtree of any node contain integers that are greater than the current tree, or the
subtree is empty.
c. The tree is balanced.


a. ```
context BinaryTree inv:
left.getSubElements()->size = 0 or
left.getSubElements()->forAll(e:Integer| e <= getElement())
```
b. ```
context BinaryTree inv:
right.getSubElements()->size = 0 or
right.getSubElements()->forAll(e:Integer|e > getElement())
```
c. ```
context BinaryTree inv:
left.getSubElements()->size <= right.getSubElements()->size + 1 and
right.getSubElements()->size <= left.getSubElements()->size + 1```

Computer Science & Information Technology

You might also like to view...

All of the following are methods of the Iterator interface except:

(a) clear() (b) hasNext() (c) next() (d) remove()

Computer Science & Information Technology

Another term for various software programs that are sold together and designed to complement each other is ________

A) suite B) package C) collection D) group

Computer Science & Information Technology

When using Trace Precedents and Trace Dependents, tracer arrows display showing the relationship between cells and formulas

Indicate whether the statement is true or false

Computer Science & Information Technology

The word ________ has come to be known as a company that creates a private network as a service that interconnects to multiple cloud providers and allows customers to easily switch between them

A) Crosscloud B) Intercloud C) Intracloud D) Muxcloud

Computer Science & Information Technology