[Boards: 3 / a / aco / adv / an / asp / b / bant / biz / c / can / cgl / ck / cm / co / cock / d / diy / e / fa / fap / fit / fitlit / g / gd / gif / h / hc / his / hm / hr / i / ic / int / jp / k / lgbt / lit / m / mlp / mlpol / mo / mtv / mu / n / news / o / out / outsoc / p / po / pol / qa / qst / r / r9k / s / s4s / sci / soc / sp / spa / t / tg / toy / trash / trv / tv / u / v / vg / vint / vip / vp / vr / w / wg / wsg / wsr / x / y ] [Search | Free Show | Home]

Is it possible to build a Binary tree in an interpreted language

This is a blue board which means that it's for everybody (Safe For Work content only). If you see any adult content, please report it.

Thread replies: 11
Thread images: 1

File: 2000px-Binary_search_tree.svg.png (99KB, 2000x1667px) Image search: [Google]
2000px-Binary_search_tree.svg.png
99KB, 2000x1667px
Is it possible to build a Binary tree in an interpreted language without pointers?

All you're really doing is building a large struct
>>
Of course it is. A big list is the memory space and an integer index in that list the memory pointer.
>>
Yes.
>>
>>58629000
>without pointers
Most possibly you won't be able to place pointers in array in an interpreted language directly, so you kinda won't have pointers in the array, but it's just you won't be able to use pointers as pointers.
>>
yes it is. You can simulate pointers using any array.
>>
You don't need pointers to make binary tree.
>>
data Tree a = Empty | a (Tree a) (Tree a)

There, recursively defined binary tree in Haskell.
>>
>>58629685
Fail
>>
>>58629697
How about providing some constructive criticism instead of a 9gag-tier reply?
>>
>>58629000
1
2 3
4 5 6 7
8 9 10 11 12 13 14 15
16... and so on

just use these indices in a large array.

The father of a node x is x/2 rounded down (or simply a right shift), the two children of node x are 2x and 2x+1 (left shift filling 0 or 1).

You just need a node structure that records if a node is in the tree or not.
>>
>>58629000
>interpreted language without pointers?
What interpreted language doesn't have pointers? (protip: references are pointers)

Also, this: >>58629657

You can represent a binary tree in an array, for example.
Thread posts: 11
Thread images: 1


[Boards: 3 / a / aco / adv / an / asp / b / bant / biz / c / can / cgl / ck / cm / co / cock / d / diy / e / fa / fap / fit / fitlit / g / gd / gif / h / hc / his / hm / hr / i / ic / int / jp / k / lgbt / lit / m / mlp / mlpol / mo / mtv / mu / n / news / o / out / outsoc / p / po / pol / qa / qst / r / r9k / s / s4s / sci / soc / sp / spa / t / tg / toy / trash / trv / tv / u / v / vg / vint / vip / vp / vr / w / wg / wsg / wsr / x / y] [Search | Top | Home]

I'm aware that Imgur.com will stop allowing adult images since 15th of May. I'm taking actions to backup as much data as possible.
Read more on this topic here - https://archived.moe/talk/thread/1694/


If you need a post removed click on it's [Report] button and follow the instruction.
DMCA Content Takedown via dmca.com
All images are hosted on imgur.com.
If you like this website please support us by donating with Bitcoins at 16mKtbZiwW52BLkibtCr8jUg2KVUMTxVQ5
All trademarks and copyrights on this page are owned by their respective parties.
Images uploaded are the responsibility of the Poster. Comments are owned by the Poster.
This is a 4chan archive - all of the content originated from that site.
This means that RandomArchive shows their content, archived.
If you need information for a Poster - contact them.