Could anyone tell me anything about S-Expressions in C++ and how I would go about using it with a binary search tree?
I appreciate any comments, thanks!
Could anyone tell me anything about S-Expressions in C++ and how I would go about using it with a binary search tree?
I appreciate any comments, thanks!
"Our greatest glory consists not in never failing,
but in rising every time we fall."
Oliver Goldsmith (1730-1774).
Anglo-Irish writer, poet and playwright.
an s-expression is like this:
((wut woah huh) wut wut)
nested lists
so, you take your basic binary tree definition:
tree {
item item
tree right, left
}
and instead of treating right as `right', treat it as 'nest'
so for every ( you encounter, open a new level of your `tree' and store everything you encounter up until ) in something pointed to by right
use left to point to the next node in your list of items
ex:
( wut ( woah ) )
to:
node 1
item - wut
left - null
right - node 2
node 2
item - woah
left - null
right - null
i hope i am coherent
.sect signature