S
Somebody
This is going to be difficult to explain without real pics, but here goes.
It may sound like a GUI question at the beginning, but bear with me . I'm
trying to come up with an algorithm for this:
I have "cells"... a cell can be split horizontally or vertically as many
times as a user wants (but can not exit the original cell which remains
rectangular). Ie... take a piece of paper, you can keep cutting it in half
indefinitely, but it will always remain rectangular and never be larger then
the original paper...
I represent this internally with a binary tree.
Take for example:
****************************
* A * B * C *
* * *************
* * * D *
****************************
This scenario occured for example because the user started with A, split it
horizontally to form B, split B horizontally to form C and split C
vertically to form D.
Ok, with that being said... I'm trying to determine if 2 cells can be
"merged" from my binary tree data, but I'm not exactly sure how to do that.
For example, in the above.. A can be merged with B to the right, B can be
merged with A to the left and C can be merged with D down and D can be
merged with C up.
The tree construct can be in several ways depending on what order the user
split things.
Any ideas on how to determine if a merge can happen?
I was thinking... I know the *exact* cell that the user would want to split,
and which direction they want to split in (for arguments sake lets say they
want to split B to the left horizontally)... I have *no idea* that A is
there at that point and that it is mergeable... I haven't even been able to
come up with a suitable definition of what qualifies 2 cells as mergable...
The only thing I've come up with is... start with B and find its right most
sibling thats to the left... if I encounter any vertical splits along the
way, no merge is possible. Does that sound like something that will work? or
does it need to be "fleshed out more".
Thanks!
It may sound like a GUI question at the beginning, but bear with me . I'm
trying to come up with an algorithm for this:
I have "cells"... a cell can be split horizontally or vertically as many
times as a user wants (but can not exit the original cell which remains
rectangular). Ie... take a piece of paper, you can keep cutting it in half
indefinitely, but it will always remain rectangular and never be larger then
the original paper...
I represent this internally with a binary tree.
Take for example:
****************************
* A * B * C *
* * *************
* * * D *
****************************
This scenario occured for example because the user started with A, split it
horizontally to form B, split B horizontally to form C and split C
vertically to form D.
Ok, with that being said... I'm trying to determine if 2 cells can be
"merged" from my binary tree data, but I'm not exactly sure how to do that.
For example, in the above.. A can be merged with B to the right, B can be
merged with A to the left and C can be merged with D down and D can be
merged with C up.
The tree construct can be in several ways depending on what order the user
split things.
Any ideas on how to determine if a merge can happen?
I was thinking... I know the *exact* cell that the user would want to split,
and which direction they want to split in (for arguments sake lets say they
want to split B to the left horizontally)... I have *no idea* that A is
there at that point and that it is mergeable... I haven't even been able to
come up with a suitable definition of what qualifies 2 cells as mergable...
The only thing I've come up with is... start with B and find its right most
sibling thats to the left... if I encounter any vertical splits along the
way, no merge is possible. Does that sound like something that will work? or
does it need to be "fleshed out more".
Thanks!