Reference Information. I created an application for creating online diagrams where div tags are containers containing smaller div containers, etc.
Question. For any particular div tag, I need to quickly determine if it contains other div tags (which, in turn, can contain other div tags).
I searched for jQuery and for this I do not see the built-in procedure. Does anyone know of an algorithm that is faster than O (n ^ 2)?
It looks like I need to go through the list of div tags in the outer loop (n) and have an inner loop (another n) to compare with all other div tags and perform a “leak test” (position, width, height), creating a list of the contained div tags. This is an n-square. Then I need to create a list of all nested div tags, combining the contained lists. Thus, the sum will be equal to O (n ^ 2) + n.
Should there be a better way?
source
share