Parse string to tree structure (solved)

General FreeBASIC programming questions.
D.J.Peters
Posts: 8586
Joined: May 28, 2005 3:28
Contact:

Re: Parse string to tree structure

Post by D.J.Peters »

@badidea yours does produce an runtime error here (compile with -exx)

why is the file: "/path3/itemC" two times in your virtual filesystem ?

Check out how short=elegant SortFS () is :-)

Joshy

Code: Select all

#include "crt.bi"

function getDepth(path as string) as integer
  var c=0,n = instr(path,"/")
  while n : c+=1 : n = instr(n+1,path,"/") : wend
  return c
end function

function SplitPath(path as string, splitted() as string) as integer
  var nSize = ubound(splitted)+1
  var s = path & "/"
  var c=0,p = strtok(strptr(s),strptr("/"))
  while (p<>NULL) andalso c<nSize
    splitted(c) = *p : c+=1 
    p = strtok(NULL,strptr("/"))
  wend
  return c
end function  

' return "true" if strings (l) and (r) must be swapped otherwise "false"
function SortString(l as string, r as string) as boolean
  var n1 = len(l), n2 = len(r), n = iif(n1<n2, n1, n2)
  if n<1 then return false
  for i as integer = 0 to n-1
    if l[i]=asc("/") then continue for
    if r[i]=asc("/") then continue for
    if l[i]>r[i] then return true
  next
  return false
end function

sub SortFS(FS() as string)
  var last = ubound(FS)-1
  var flag = true
  while flag=true : flag=false
    for i as integer = 0 to last
      var d1=len(FS(i )), d2=len(FS(i+1)),n = iif(d1<=d2,d1,d2)
      var index=0, l="", r=""
      while l=r andalso index<n
        l &= chr(FS(  i)[index])
        r &= chr(FS(i+1)[index])
        index+=1
      wend
      if SortString(l,r) then swap FS(i),FS(i+1) : flag=true :  exit for
    next
  wend
end sub

dim as string VirtualFS(...) = { _
   "/itemE",_
   "/path1/path2/itemC", _
   "/path1/path2/itemB", _
   "/path1/path2/itemA", _
   "/path2/path2/itemX", _
   "/path4/path5/path6/path7/itemQ", _
   "/path4/path5/path8/path7/itemR", _
   "/path4/path5/path6/path7/itemP", _
   "/path3/itemC", _
   "/path3/itemB", _
   "/itemD"}
print "virtual file system"
for i as integer = 0 to ubound(VirtualFS)
  print VirtualFS(i)
next
print
' sort the FS.
SortFS(VirtualFS())
print "sorted:"
for i as integer = 0 to ubound(VirtualFS)
  print VirtualFS(i)
next
print

print "root"
for i as integer = 0 to ubound(VirtualFS)
  var depth = getDepth(VirtualFS(i))
  dim as string splitted(depth-1)
  var path = VirtualFS(i) & "/"
  var c = SplitPath(path,splitted())
  for j as integer = 0 to c-1
    print space(j*2) & "+ " & splitted(j)
  next  
next  
sleep
badidea
Posts: 2586
Joined: May 24, 2007 22:10
Location: The Netherlands

Re: Parse string to tree structure

Post by badidea »

I'll check tomorrow and make the code less ugly.
D.J.Peters
Posts: 8586
Joined: May 28, 2005 3:28
Contact:

Re: Parse string to tree structure

Post by D.J.Peters »

D.J.Peters wrote:@badidea yours does produce an runtime error here (compile with -exx)
d:\done>d:\FreeBASIC\fbc32 -exx user_FS.bas
d:\done>user_FS.exe
Aborting due to runtime error 4 (out of memory) at line 45 of user_FS.bas::ADDITEM()
Lost Zergling
Posts: 534
Joined: Dec 02, 2011 22:51
Location: France

Re: Parse string to tree structure

Post by Lost Zergling »

@Badidea. While writing the code, I found a bug in lzle: the HashTag property is not always neutral on the parameter passed in reference, in general it is not visible. To work around this problem and not patch the version just for that, I had to use an intermediate variable (Str_tmp2).This will be corrected.

Code: Select all

#Include once "F:\Basic\LZLE.bi"
Declare Function SetMyVirtualTree(Str_tmp As String, L_tmp As List) As Byte
Function SetMyVirtualTree(Str_tmp As String, L_tmp As List) As Byte
    Dim As Integer  t : Dim As String  Str_tmp2
    If Left(Str_tmp,1)="/" Then : Str_tmp=Right(Str_tmp, Len(Str_tmp)-1) : End If
    Str_tmp2=Str_tmp : L_tmp.HashTag(Str_tmp2)
    t=Instr(Str_tmp, "/")
    While t<>0        
        Str_tmp=Left(Str_tmp, Len(Str_tmp)-t)
        Str_tmp2=Str_tmp : L_tmp.HashTag(Str_tmp2)
        t=Instr(Str_tmp, "/")
    Wend
    Return 1
End Function

Dim MyList As List
Dim Str_Path() As String : Redim Str_Path(14)
Dim i As Integer

Str_Path(1)="/path1/path2/itemA"
Str_Path(2)="/path1/path2/itemB"
Str_Path(3)="/path3/itemC"
Str_Path(4)="/itemD"
Str_Path(5)="/path8/path7/path3/itemA"
Str_Path(6)="/path7/path3/itemB"
Str_Path(7)="/path4/path9/path7/itemC"
Str_Path(8)="/path6/itemD"
Str_Path(9)="/itemE"
Str_Path(10)="/path3/path5/path7/itemF"
Str_Path(11)="/path6/path3/itemG"
Str_Path(12)="/path3/itemH"
Str_Path(13)="/itemI"
Str_Path(14)="/path3/path3/itemJ"

For i=1 To 14
    SetMyVirtualTree(Str_Path(i), MyList)
Next i

MyList.Root
While MyList.KeyStep
    Print MyList.HashTag    
Wend
MyList.Destroy
gCollector.Destroy
Sleep
I think this code remains relatively simple and easy to use compared to less accessible technical solutions. Concretely, it saves time.
Remarks, return, and/or suggestions are welcome.
badidea
Posts: 2586
Joined: May 24, 2007 22:10
Location: The Netherlands

Re: Parse string to tree structure

Post by badidea »

D.J.Peters wrote:
D.J.Peters wrote:@badidea yours does produce an runtime error here (compile with -exx)
d:\done>d:\FreeBASIC\fbc32 -exx user_FS.bas
d:\done>user_FS.exe
Aborting due to runtime error 4 (out of memory) at line 45 of user_FS.bas::ADDITEM()
Strangely, I don't get runtime errors here on linux (both 32 and 64 bit fbc 1.07.1)
But I will rewrite it anyway.

The two items "/path3/itemC" are intentionally. The database filesystem cannot have that. What I am trying to write is an import-tool for new data paths. By presenting it in a tree, I can more easily see if I made an error such as doubles.

Here I get:

Code: Select all

+ itemD
+ itemE
+ path1
  + path2
    + itemA
    + itemB
    + itemC
+ path2
  + path2
    + itemX
+ path3
  + itemC
  + itemC
+ path4
  + path5
    + path6
      + path7
        + itemP
        + itemQ
    + path8
      + path7
        + itemR
So almost there
Lost Zergling
Posts: 534
Joined: Dec 02, 2011 22:51
Location: France

Re: Parse string to tree structure

Post by Lost Zergling »

Replace the following "L_tmp.HashTag(Str_tmp2)" (the first one outside the while wend, the second one represents tree parse double) with
"If L_tmp.HashTag(Str_tmp2)=1 Then : Print "Double on : " & L_tmp.HashTag : End If"
Erratum :
Just insert this line :
Str_tmp2=Str_tmp
If L_tmp.HasKey(Str_tmp2)=1Then : Print "Double on : " & L_tmp.HashTag : End If
L_tmp.HashTag(Str_tmp2)
dodicat
Posts: 7976
Joined: Jan 10, 2006 20:30
Location: Scotland

Re: Parse string to tree structure

Post by dodicat »

Hi lost Zerling
I got hold of your three parts, and tested.
Maybe you should just edit the changes required so we can try it without too much fluffing around.
Anyway thanks for your input.
Here is my effort, although I am not sure of what is a path or not a path in Badidea's database.
I have used D.J.Peters's, Lost Zerling's and Badidea's arrays.

Code: Select all

Function StringSplit(s_in As String,chars As String,result() As String) As Long
    Dim As Long ctr,ctr2,k,n,LC=Len(chars)
    Dim As boolean tally(Len(s_in))
    #macro check_instring()
    n=0
    While n<Lc
        If chars[n]=s_in[k] Then
            tally(k)=true
            If (ctr2-1) Then ctr+=1
            ctr2=0
            Exit While
        End If
        n+=1
    Wend
    #endmacro
    
    #macro split()
    If tally(k) Then
        If (ctr2-1) Then ctr+=1:result(ctr)=Mid(s_in,k+2-ctr2,ctr2-1)
        ctr2=0
    End If
    #endmacro
    '==================  LOOP TWICE =======================
    For k  =0 To Len(s_in)-1
        ctr2+=1:check_instring()
    Next k
    If ctr=0 Then
        If Len(s_in) Andalso Instr(chars,Chr(s_in[0])) Then ctr=1
    End If
    If ctr Then Redim result(1 To ctr): ctr=0:ctr2=0 Else  Return 0
    For k  =0 To Len(s_in)-1
        ctr2+=1:split()
    Next k
    '===================== Last one ========================
    If ctr2>0 Then
        Redim Preserve result(1 To ctr+1)
        result(ctr+1)=Mid(s_in,k+1-ctr2,ctr2)
    End If
    Return Ubound(result)
End Function

Sub removeDuplicates(a() As String, b() As String)'rosetta code (maybe mine, can't remember)
    Dim lb As Long = Lbound(a)
    Dim ub As Long = Ubound(a)
    If ub = -1 Then Return '' empty array
    Redim b(lb To ub)
    b(lb) = a(lb)
    Dim count As Integer = 1
    Dim unique As Boolean
    For i As Integer = lb + 1 To ub
        unique = True 
        For j As Integer = lb To i - 1
            If a(i) = a(j) Then
                unique = False
                Exit For
            End If
        Next j
        If unique Then
            b(lb + count) = a(i)
            count += 1
        End If
    Next i
    If count > 0 Then Redim Preserve b(lb To lb + count - 1)  
End Sub

Sub push(a() As String,index As Long,insert As String)'arrayinsert
    If (index)>=Lbound(a) And (index)<=Ubound(a)+1 Then
        Var index2=(index)-Lbound(a)
        Redim Preserve a(Lbound(a) To  Ubound(a)+1)
        For x As Integer= Ubound(a) To Lbound(a)+index2+1 Step -1
            Swap a(x),a(x-1)
        Next x
        a(Lbound(a)+index2)=(insert)
    End If
End Sub

Sub pop(a() As String,index As Long)
    If index>=Lbound(a) And (index)<=Ubound(a) Then
        For x As Integer=(index) To Ubound(a)-1
            a(x)=a(x+1)
        Next x
        Redim Preserve a(Lbound(a) To Ubound(a)-1)
    End If 
End Sub

Sub AddRoot(a() As String,n as long)
    Var pp=a(n)
    pop(a(),n)
    push(a(),1,pp)
End Sub

Function TALLY(SomeString As String,PartString As String) As Long
    Dim As Long LenP=Len(PartString),count
    Dim As Long position=Instr(SomeString,PartString)
    If position=0 Then Return 0
    While position>0
        count+=1
        position=Instr(position+LenP,SomeString,PartString)
    Wend
    Return count
End Function

Function GetTree(s() As String,msg as string) As String
    print msg
    Dim As String root
    Dim As Long rootflag=Iif(tally(s(Ubound(s)),"/")=1,1,0)
    for n as long=lbound(s) to ubound(s)
    if tally(s(n),"/")=1 then s(n)+="*":rootflag=1'add a marker
    next n
    if rootflag then root=!"root\n"
    Dim As String p
    For n As Long=Lbound(s) To Ubound(s)
        p+=s(n)+Chr(10)
    Next
    Print p
    Redim As String a()
    stringsplit(p,Chr(Asc("/"),10),a())
    Redim As String b()
    removeDuplicates(a(),b())
    dim as long start=lbound(b)
    lbl:
    for n as long=start to ubound(b)
        if instr(b(n),"*") then
            b(n)=rtrim(b(n),"*")
            AddRoot(b(),n)
           start+=1
            goto lbl
            end if
        next n
        'final string out
    Dim As String ret=root
    For n As Long=Lbound(b) To Ubound(b)
        ret+=" +  "+b(n)+Chr(10)
    Next n
    Return ret
End Function

Dim As String VirtualFS(...) = { _  'D.J.Peters
"/itemE",_
"/path1/path2/itemC", _
"/path1/path2/itemB", _
"/path1/path2/itemA", _
"/path2/path2/itemX", _
"/path4/path5/path6/path7/itemQ", _
"/path4/path5/path8/path7/itemR", _
"/path4/path5/path6/path7/itemP", _
"/path3/itemC", _
"/path3/itemB", _
"/itemD"}


Dim As String p(1 To 4)  'badideas

p(1)="/path1/path2/itemA"
p(2)="/path1/path2/itemB"
p(3)="/path3/itemC"
p(4)="/itemD"

Dim Str_Path() As String : Redim Str_Path(14) 'Lost zerling's
Str_Path(1)="/path1/path2/itemA"
Str_Path(2)="/path1/path2/itemB"
Str_Path(3)="/path3/itemC"
Str_Path(4)="/itemD"
Str_Path(5)="/path8/path7/path3/itemA"
Str_Path(6)="/path7/path3/itemB"
Str_Path(7)="/path4/path9/path7/itemC"
Str_Path(8)="/path6/itemD"
Str_Path(9)="/itemE"
Str_Path(10)="/path3/path5/path7/itemF"
Str_Path(11)="/path6/path3/itemG"
Str_Path(12)="/path3/itemH"
Str_Path(13)="/itemI"
Str_Path(14)="/path3/path3/itemJ"



Print gettree(VirtualFS(),"D.J.Ptetr's array,* marks root")
Print
Print gettree(p(),"Badideas's array,* marks root")
print
print GetTree(Str_Path(),"Lost Zerling's array,* marks root")
Sleep

 
Probably completely wrong anyway.
Lost Zergling
Posts: 534
Joined: Dec 02, 2011 22:51
Location: France

Re: Parse string to tree structure

Post by Lost Zergling »

Hi everybody. Thanks being here ! I got this output using lists

Code: Select all

itemD
itemE
itemI
path1
path1/path2
path1/path2/itemA
path1/path2/itemB
path3
path3/itemC
path3/itemH
path3/path3
path3/path3/itemJ
path3/path5
path3/path5/path7
path3/path5/path7/itemF
path4
path4/path9
path4/path9/path7
path4/path9/path7/itemC
path6
path6/itemD
path6/path3
path6/path3/itemG
path7
path7/path3
path7/path3/itemB
path8
path8/path7
path8/path7/path3
path8/path7/path3/itemA
Replacing "/path3/itemH" by "/path3/itemC" detects double using HasKey instruction.
Adding

Code: Select all

?
? "MarkRoot ---------------------------"
MyList.Root
While MyList.nKeyStep
    Print MyList.HashTag
Wend
I get

Code: Select all

MarkRoot ---------------------------
itemD
itemE
itemI
path1
path3
path4
path6
path7
path8
path1/path2
path3/itemC
path3/itemH
path3/path3
path3/path5
path4/path9
path6/itemD
path6/path3
path7/path3
path8/path7
path1/path2/itemA
path1/path2/itemB
path3/path3/itemJ
path3/path5/path7
path4/path9/path7
path6/path3/itemG
path7/path3/itemB
path8/path7/path3
path3/path5/path7/itemF
path4/path9/path7/itemC
path8/path7/path3/itemA
D.J.Peters
Posts: 8586
Joined: May 28, 2005 3:28
Contact:

Re: Parse string to tree structure

Post by D.J.Peters »

I changed the output line to:
print space(iif(j<2,0,(j-1)*2)) & "+ " & splitted(j)

A single file j=0 or the first folder from path j=1 get the same priority in the output !

Joshy
Last edited by D.J.Peters on Mar 22, 2020 14:52, edited 1 time in total.
UEZ
Posts: 972
Joined: May 05, 2017 19:59
Location: Germany

Re: Parse string to tree structure

Post by UEZ »

Here my new version.

Code: Select all

#Define LF   Chr(10)
#Define CRLF Chr(13) & Chr(10)
#Define INDENT "  "
#Define PREFIX "+ "

Dim Shared As String * 255 u
For n As Long = 0 To 255
    u[n] = Iif(n < 91 Andalso n > 64, n + 32, n)  'lookup string
Next

Sub QuicksortUp(low As String Ptr,high As String Ptr) 'by dodicat
    If (high - low <= 1) Then Return
    Var J = low + 1, I = J, lenb = Cast(Integer Ptr, low)[1], lena=0
    While J <= high
        lena = Cast(Integer Ptr, J)[1] '=Len(*a)
        If lena > lenb Then lena = lenb
        For n As Long = 0 To lena - 1
            If u[(J)[0][n]] < u[(low)[0][n]] Then Swap *J, *I : I += 1 : Exit For
            If u[(J)[0][n]] > u[(low)[0][n]] Then Exit For
        Next
        J + =1
    Wend
    J = I - 1 : Swap *low, *J
    QuicksortUp(low, J)
    QuicksortUp(I, high)
End Sub

Sub StringSplit(sString As String, aResult() As String, sDelimiter As String = "/")
   Dim As Uinteger j = 0, i, ii = 1
   If Left(sString, 1) = sDelimiter Then sString = Ltrim(sString, "/")
   For i = 1 To Len(sString)
      If Mid(sString, i, 1) = sDelimiter Then
         Redim Preserve aResult(Ubound(aResult) + 1)
         aResult(j) = Mid(sString, ii, i - ii)
         j += 1
         i += 1
         ii = i
      End If
   Next
   If ii < i Then
      aResult(j) = Mid(sString, ii, i - ii)
   Else
      Redim Preserve aResult(j - 1)
   End If
End Sub

Sub PrintDirStructur(sPathes As String, sepChar As String)
   ReDim As String aPathes(1000)
   Dim As String char
   Dim As Uinteger i = 1, ii = 1, c = 0, d = 0, x, y, dimx = 0

   While i <= Len(sPathes) 'loop all characters
      char = Mid(sPathes, i, 1)
      If char = sepChar Then d+= 1 'current depth
      If Asc(char) = 10 Then 'LF
         aPathes(c) = Mid(sPathes, ii, i - ii) 'one complete line
         c += 1 'line count
         i += 1 'input iterator
         ii = i 'previous
         If dimx < d Then dimx = d 'increase max depth
         d = 0 'reset current depth
      Else
         i += 1 'No LF
      End If   
   Wend
   If ii < i Then 'add the last line
      aPathes(c) = Mid(sPathes, ii, i - ii)
   Else
      c -= 1 'correct line count
   End If
   Redim Preserve aPathes(c) 'shrink array size
   QuicksortUp(@aPathes(0), @aPathes(c))
   ? "Input pathes sorted:"
   For i = 0 To Ubound(aPathes)
      ? aPathes(i)
   Next
   ?
   ?
   ? "Formatted:" : ? 
   ?
   Dim As String aTree(dimx * c, dimx - 1) 'allocate for worst case
   Dim As String aLine()
   Dim As Integer px, py = 0, found, yy

   For i = 0 To Ubound(aPathes) 'loop all full paths
      Redim aLine(0)
      StringSplit(aPathes(i), aLine(), sepChar) 'split path into segments
      px = 0
      For x = 0 To Ubound(aLine) 'loop path segments
         y = 0
         found = 0
         While y < py
            If aLine(x) = aTree(y, x) Then
				If x > 0 Then
					yy = 0
					While yy > = 0 
						If aLine(x - 1) = aTree(y, x) Then
							found = 1
							Exit While, While
						End If
						yy -= 1
					Wend
				Else
					found = 1
				End If
            End If
            y += 1
         Wend
         If found = 1 Then
            px += 1
         Else
            aTree(py, px) = aLine(x)
            px += 1
            py += 1
         End if
      Next
   Next
   Dim As String sOutput, tc, tn
   
   For y = 0 To py
      For x = 0 To Ubound(aTree, 2)
         sOutput &= Iif(aTree(y, x) <> "", PREFIX + aTree(y, x), "") + INDENT
      Next
      sOutput &= CRLF
   Next
   ? sOutput
End Sub

Dim As String sPathes = _
   "/path1/xxxx/itemB" & LF & _
   "/path2/itemC" & LF & _
   "/path2/xxxx/itemA" & LF & _
   "/itemA" & LF & _
   "/path1/path2/path3/itemA" & LF & _
   "/path2/itemA" & LF & _
   "/itemD"

PrintDirStructur(sPathes, "/")

Sleep
I hope this works properly now.

EDIT: this solution doesn't work properly


@Joshy: I get several em when trying to compile your code:

Code: Select all

..(11) error 24: Invalid data types
..(12) error 24: Invalid data types, found ')'
..(12) warning 3(2): Passing different pointer types, at parameter 2 of STRTOK()
..(15) warning 3(2): Passing different pointer types, at parameter 2 of STRTOK()
..(38) error 24: Invalid data types, before ','
..(40) error 20: Type mismatch
..(41) error 20: Type mismatch
..(44) error 58: Type mismatch, at parameter 1 (l) of SORTSTRING()
..(78) error 24: Invalid data types
..(79) error 58: Type mismatch, at parameter 1 (path) of SPLITPATH()

Last edited by UEZ on Mar 23, 2020 10:17, edited 1 time in total.
D.J.Peters
Posts: 8586
Joined: May 28, 2005 3:28
Contact:

Re: Parse string to tree structure

Post by D.J.Peters »

UEZ wrote:@Joshy: I get several em when trying to compile your code ...
That means your fbc compiler or include files are not uptodate !

Often FreeBASIC for Linux setup isn't complete !

Joshy
badidea
Posts: 2586
Joined: May 24, 2007 22:10
Location: The Netherlands

Re: Parse string to tree structure

Post by badidea »

Lost Zergling wrote:Hi everybody. Thanks being here !
Where else can we go?
To reduce computer time, I have been building a bee hotel:
Image
UEZ
Posts: 972
Joined: May 05, 2017 19:59
Location: Germany

Re: Parse string to tree structure

Post by UEZ »

D.J.Peters wrote:
UEZ wrote:@Joshy: I get several em when trying to compile your code ...
That means your fbc compiler or include files are not uptodate !

Often FreeBASIC for Linux setup isn't complete !

Joshy
Well, I'm using the latest FB version 1.07.1 and I'm working only on Windows os.

How to check if I'm up2d8?
Lost Zergling
Posts: 534
Joined: Dec 02, 2011 22:51
Location: France

Re: Parse string to tree structure

Post by Lost Zergling »

Very nice.
grindstone
Posts: 862
Joined: May 05, 2015 5:35
Location: Germany

Re: Parse string to tree structure

Post by grindstone »

@badidea: Great work! That reminds me that I have to clean my nesting boxes (and my letter box, too, I get this little lodger since three years).

Image

And here are my two pennies to the tree parser:

Code: Select all

#Include "dirTree.bi"

Dim As tDirTreeNode Ptr tp, cp, root = New tDirTreeNode
Dim As Integer numberOfEntries, x, b, e
Dim As String fileSystemString, g

root->fname = "root"
root->attr And= fbDirectory 

'virtual file system string parser
Read fileSystemString
Do While Len(fileSystemString)
	b = 2
	tp = root 'begin at the root node
	Do 'parse fileSystemString and write the entries into the tree
		e = InStr(b, fileSystemString, Any "/\")
		g = Mid(fileSystemString, b, e - b) 'cut out one directory or item name
		tp = tp->newchild(g, IIf(InStr(g, "path"), fbDirectory , 0), 3)
		'|                                             |             |__sort alphabetical and avoid double names
		'|                                             |________________set directory attribute if not an item
		'|______________________________________________________________returns the pointer to the new child node
		'                                                               if one was created, or the original pointer
		'                                                               if a node with that name already exists
		b = e + 1
	Loop While e
	Read fileSystemString
Loop

Data "/path8/path7/path3/itemA"
Data "/path7/path3/itemB"
Data "/path4/path9/path7/itemC"
Data "/path6/itemD"
Data "/itemE"
Data "/path3/path5/path7/itemF"
Data "/path6/path3/itemG"
Data "/path3/itemH"
Data "/itemI"
Data "/path3/path3/itemJ"
Data ""

Print "*** TREE ***"

'print tree
Sub printTree(tp As tDirTreeNode Ptr)
	Print String(tp->depth, " "); "+ "; tp->fname 'print the name of the current node
	If tp->noChild Then
		Return
	Else 'call sub recursively
		For x As Integer = 0 To UBound(tp->child)
			printTree(tp->child(x))
		Next
	EndIf
End Sub

printTree(root)

Sleep

Delete root 'deletes the whole tree
root = 0
Post Reply