• Post Reply Bookmark Topic Watch Topic
  • New Topic

recursive data structure  RSS feed

 
mark smith
Ranch Hand
Posts: 258
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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 ]
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!