Recent

Author Topic: Binary Tree implementation  (Read 3419 times)

Arbee

  • Full Member
  • ***
  • Posts: 223
Binary Tree implementation
« on: September 17, 2012, 12:44:44 pm »
While clearing out some old coding I came across an old task I did years ago in Delphi, namely the creation an object oriented implementation of a Binary tree capable of storing any object in that tree.

There probably is not a great demand for this as Object Pascal already offers similar things like that, but I also did not want to throw it away just like that, so if there is somebody out there who is looking for this, here it is.

Changed it slightly to make it Object Pascal compatible.  It is still a bit rough around the edges I must admit, but improving it should be easy.

the attached project is a small Q&D test program that shows some of the options.  The actual tree implementation ins in bintree.pas, the only unit that one would need to imbed in a project that uses it.
1.0/2.6.0  XP SP3 & OS X 10.6.8

Gustavo 'Gus' Carreno

  • Hero Member
  • *****
  • Posts: 914
  • Professional amateur ;-P
Re: Binary Tree implementation
« Reply #1 on: August 13, 2022, 07:17:09 am »
Hey Arbee,

Many thanks for this code.

May I ask: Is your implementation of the binary tree self balancing?

Many, MANY thanks for this piece of code!!

Cheers,
Gus
Lazarus 2.3.0(trunk) FPC 3.3.1(trunk) Ubuntu 21.10 64b Dark Theme
Lazarus 2.0.12(stable) FPC 3.2.2(stable) Ubuntu 21.10 64b Dark Theme
http://github.com/gcarreno

Thaddy

  • Hero Member
  • *****
  • Posts: 11895
Re: Binary Tree implementation
« Reply #2 on: August 13, 2022, 12:07:08 pm »
Any comparisons to the other binary trees in the standard distribution?
- ease of use
- speed
- compact
Black themes should be banned.

BrunoK

  • Sr. Member
  • ****
  • Posts: 343
  • Retired programmer
Re: Binary Tree implementation
« Reply #3 on: August 13, 2022, 01:42:59 pm »
Test application lazBtree.zip leaks a lot.

 

TinyPortal © 2005-2018