creating a binary trees

classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|

creating a binary trees

Faizal
Is there any octave program sample that I can use to start up in creating a binary trees for data structure. Thank you.
Reply | Threaded
Open this post in threaded view
|

Re: creating a binary trees

martin_helm
Am 19.11.2011 02:22, schrieb Faizal:
> Is there any octave program sample that I can use to start up in creating a
> binary trees for data structure. Thank you.
I am not absolutely sure what you are looking for exactly, you can build
tree structures in octave with cell arrays, like that
tree =
{{{{1},{2}},{{3},{4}}},{{{5},{6}},{{7},{8}}}}                                  

tree
=                                                                                            

{                                                                                                

  [1,1] =
 
{                                                                                              

    [1,1]
=                                                                                      

   
{                                                                                            

      [1,1]
=                                                                                    

      {
        [1,1] =  1
      }
      [1,2] =
      {
        [1,1] =  2
      }
    }
    [1,2] =
    {
      [1,1] =
      {
        [1,1] =  3
      }
      [1,2] =
      {
        [1,1] =  4
      }
    }
  }
  [1,2] =
  {
    [1,1] =
    {
      [1,1] =
      {
        [1,1] =  5
      }
      [1,2] =
      {
        [1,1] =  6
      }
    }
    [1,2] =
    {
      [1,1] =
      {
        [1,1] =  7
      }
      [1,2] =
      {
        [1,1] =  8
      }
    }
  }
}

_______________________________________________
Help-octave mailing list
[hidden email]
https://mailman.cae.wisc.edu/listinfo/help-octave
Reply | Threaded
Open this post in threaded view
|

Re: creating a binary trees

Jordi Gutiérrez Hermoso-2
In reply to this post by Faizal
On 18 November 2011 20:22, Faizal <[hidden email]> wrote:
> Is there any octave program sample that I can use to start up in creating a
> binary trees for data structure. Thank you.

Octave's data structures are somewhat intentionally quite limited.
What sort of task do you need a binary tree for?

- Jordi G. H.
_______________________________________________
Help-octave mailing list
[hidden email]
https://mailman.cae.wisc.edu/listinfo/help-octave
Reply | Threaded
Open this post in threaded view
|

Re: creating a binary trees

Sergei Steshenko




----- Original Message -----

> From: Jordi Gutiérrez Hermoso <[hidden email]>
> To: Faizal <[hidden email]>
> Cc: [hidden email]
> Sent: Saturday, November 19, 2011 8:15 PM
> Subject: Re: creating a binary trees
>
> On 18 November 2011 20:22, Faizal <[hidden email]> wrote:
>>  Is there any octave program sample that I can use to start up in creating a
>>  binary trees for data structure. Thank you.
>
> Octave's data structures are somewhat intentionally quite limited.
> What sort of task do you need a binary tree for?
>
> - Jordi G. H.
> _______________________________________________

For example, cell array can be array of arrays - as many levels as desired, though in an old Email of mine I showed that list indexes gets truncated.

So cell array can be used to represent a binary tree. Or a struct - something like

tree.left.left.right.left.right = whatever;
.

So, what's the problem ?

Regards,
  Sergei.

_______________________________________________
Help-octave mailing list
[hidden email]
https://mailman.cae.wisc.edu/listinfo/help-octave