Red black tree sort/Wren: Difference between revisions

Content deleted Content added
PureFox (talk | contribs)
m Removed an unused line.
PureFox (talk | contribs)
m Fixed some typos.
Line 4: Line 4:
<lang ecmascript>import "random" for Random
<lang ecmascript>import "random" for Random


/* Represents a node in the red black tree. */
/* Represents a node in the red-black tree. */
class Node {
class Node {
// constructs a new node
// constructs a new node
Line 31: Line 31:
}
}


/* Represents a red black tree data structure. */
/* Represents a red-black tree data structure. */
class RBTree {
class RBTree {
// constructs a new red black true specifying whether duplicate keys are allowed or not
// constructs a new red-black tree specifying whether duplicate keys are allowed or not
construct new(allowDups) {
construct new(allowDups) {
_tnull = Node.new()
_tnull = Node.new()
Line 278: Line 278:


// find the node with the maximum key
// find the node with the maximum key
maximun(node) {
maximum(node) {
while (node.right != _tnull) node = node.right
while (node.right != _tnull) node = node.right
return node
return node