Opened 7 years ago

Last modified 3 years ago

#4699 new enhancement

BaseAvlSet/Tree use O(n*log n) memory

Reported by: Henning Kiel Owned by: somebody
Priority: high Milestone:
Component: *unknown* Version: v1.13.0-dev-nightly
Keywords: Cc: Martin Sjölund

Description

A rebalance causes nodes to be recreated though only the pointers need to be adapted, same holds for height value.
I propose to use arrays (or Mutable) to hold and update these values to have O(n) memory usage.

BaseAvlTree inherits from BaseAvlSet. Special care needs to be taken for its map and mapFold function.

record NODE
  Key key "The key of the node.";
  array<Integer> height "Height of tree, used for balancing";
  array<Tree> subtrees "Left+right subtrees.";
end NODE;

function left
  input Tree tree;
  output Tree = tree.subtrees[1];
end left;

function right
  input Tree tree;
  output Tree = tree.subtrees[2];
end right;

Change History (6)

comment:1 by Martin Sjölund, 7 years ago

That would make the AvlSet mutable like the HashTable and introduce all the problems we have with those (you cannot share sets or fail in a matchcontinue after you modified the set). The garbage is collected anyway. What could possibly be done is reduce the number of rebalancing needed by tweaking the allowed height differences.

comment:2 by Francesco Casella, 6 years ago

Milestone: 1.13.01.14.0

Rescheduled to 1.14.0 after 1.13.0 releasee

comment:3 by Francesco Casella, 5 years ago

Milestone: 1.14.01.16.0

Releasing 1.14.0 which is stable and has many improvements w.r.t. 1.13.2. This issue is rescheduled to 1.16.0

comment:4 by Francesco Casella, 4 years ago

Milestone: 1.16.01.17.0

Retargeted to 1.17.0 after 1.16.0 release

comment:5 by Francesco Casella, 4 years ago

Milestone: 1.17.01.18.0

Retargeted to 1.18.0 because of 1.17.0 timed release.

comment:6 by Francesco Casella, 3 years ago

Milestone: 1.18.0

Ticket retargeted after milestone closed

Note: See TracTickets for help on using tickets.