programming forums Java Java JSRs Mobile Certification Databases Caching Books Engineering OS Languages Paradigms IDEs Build Tools Frameworks Products This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
Sheriffs:
Saloon Keepers:
Bartenders:

# recursive data structure

mark smith
Ranch Hand
Posts: 258
hi

i try to feed a recursive structure from a map

an expresionn
(x>1) and (y>2 or z<4)

in the map i have this information

idInfo idMere nom
1 1 and
2 1 x>1
3 1 or
4 3 y>2
5 3 z<4

now i try to feed the data structure: info searchInfo from the map

data in the map are not necessarily in order, so that it's more complex to feed the structure

any idea to start?
[ May 22, 2008: Message edited by: mark smith ]

Bill Shirley
Ranch Hand
Posts: 457
Lots of issues here.

Data structures are not recursive. Algorithms are recursive (or not).

Some terms from graph theory that correspond to some data structures. Trees are a subset of graphs.

I would personally suggest against using an array, preferably use a List/ArrayList.

What are
idInfo
idMere
and
nom
intended to mean?

The items you list are definitely in a stack order.
The whole string has been parsed.

A x B pushes x, then A, then B onto the stack,
A, B = boolean tests,
x = boolean conjunction
subprocessing (prob'ly recursively) each A & B

thus
(x>1) and (y>2 or z<4)
A = (x>1)
x = and
B = (y>2 or z<4)

push x - "1 1 and"
process A = push A - "2 1 x>1"
process B...

this time
A = y>2
x = or
B = z<4

...

how to start?

pop the items (from the bottom, the way they're written),
and process them,

it should look like this when done...

Garrett Rowe
Ranch Hand
Posts: 1296
Bill Shirley : Data structures are not recursive. Algorithms are recursive (or not).

I disagree, a data structure can be recursive.

[ May 23, 2008: Message edited by: Garrett Rowe ]