Home » Developer & Programmer » Forms » Re: Binary tree or Trie
Re: Binary tree or Trie [message #78618] Wed, 06 March 2002 02:05 Go to next message
Messages: 14
Registered: March 2002
Junior Member
*****************Original Post*************************
I have created a new algorithm for "the duplicate
records problem", and I have implemented the algorithm
in c++ and java language.

the "data-structure" used it is the "Trie" + "Tree";
now, to improve, I would like to implement the algorithm using the PL-SQL, but I don't succeed in finding examples of as to manage "the search" in a Binary-Tree in PL-SQL language.


populating or selecting the tree ?
if u r talking about selecting then

select *
from table
connect by prior id=parent_id

u can also change structure like this

id number;
---other details----
left_child_id number;
right_child_id number;


please, what is connect by prior id=parent_id ?


Re: Binary tree or Trie [message #78622 is a reply to message #78618] Wed, 06 March 2002 03:40 Go to previous message
pratap kumar tripathy
Messages: 660
Registered: January 2002
Senior Member
"connect by prior" is used to select Hierarchical Queries.

Hierarchical Queries
If a table contains hierarchical data, you can select rows in a hierarchical order using
the hierarchical query clause:
* START WITH specifies the root row(s) of the hierarchy.
* CONNECT BY specifies the relationship between parent rows and child rows of
the hierarchy. Some part of conditionmust use the PRIOR operator to refer to
the parent row. See the PRIOR operator on page 3-16.
* WHERE restricts the rows returned by the query without affecting other rows of
the hierarchy.
Oracle uses the information from the hierarchical query clause clause to form the
hierarchy using the following steps:
1. Oracle selects the root row(s) of the hierarchy—those rows that satisfy the
START WITH condition.
2. Oracle selects the child rows of each root row. Each child row must satisfy the
condition of the CONNECT BY condition with respect to one of the root rows.
3. Oracle selects successive generations of child rows. Oracle first selects the
children of the rows returned in step 2, and then the children of those children,
and so on. Oracle always selects children by evaluating the CONNECT BY
condition with respect to a current parent row.
4. If the query contains a WHERE clause, Oracle eliminates all rows from the
hierarchy that do not satisfy the condition of the WHERE clause. Oracle evaluates
this condition for each row individually, rather than removing all the children
of a row that does not satisfy the condition.
5. Oracle returns the rows in the order shown in Figure 5–1. In the diagram
children appear below their parents.
START WITH condition
CONNECT BY condition
Previous Topic: works in sql+ but not in reports
Next Topic: how transfer data from excel to form with tabular block???? PLS HELP
Goto Forum:

Current Time: Sun Jan 29 02:35:18 CST 2023