Recent

Author Topic: Binary Tree implementation  (Read 3838 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: 1114
  • 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 3.99(main) FPC 3.3.1(main) Ubuntu 23.10 64b Dark Theme
Lazarus 3.0.0(stable) FPC 3.2.2(stable) Ubuntu 23.10 64b Dark Theme
http://github.com/gcarreno

Thaddy

  • Hero Member
  • *****
  • Posts: 14205
  • Probably until I exterminate Putin.
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
Specialize a type, not a var.

BrunoK

  • Sr. Member
  • ****
  • Posts: 452
  • 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