First prior prior priority and wide priority search
http://www.mydrs.org 2002-6-25
Large banyan
a team
1. Definition of the team:
The team is one of the special linear tables, which only allows one end of the team to be inserted, and the other end of the team is deleted. Insert one end called the tail (T), delete one end called the team (h), no one of the elements called the air. The queue follows the principle of "advanced first out", queue shopping, buy tickets, etc., is the most common team.
2. Basic operations of the team:
(1) Description of the team:
TYPE Queue = Array [1..100] of integer;
VAR A: Queue; {Definition array}
H, D: integer; {Team, tail pointer}
(2) Initialization (Figure 1):
Procedure start;
Begin
H: = 1; D: = 1;
END;
(3) Enter the team (Figure 2):
Procedure enter;
Begin
Read (s); {Read data}
INC; {tail plus one}
a [d]: = S;
END;
(4) Operation of the team (Figure 3):
PROCEDURE OUT;
Begin
INC (H); {team first plus one}
a [h]: = 0;
END;
Second, the Guangsheng Priority Search
Search for the process similar to the tree similar to the tree. It has a lot of similarities and teams, which use many ideas of the team, in fact, in-depth study of the team, its basic operations and queues almost the same.
Third, team and breadth priority search
Figure 4 shows traffic map from urban A to city H. As can be seen from the figure, from the city A to the city h to pass several cities. Now find out a country with a minimum city.
Figure 4
Analysis: Seeing this picture is easy to think of using the neighboring distance, 0 means you can go, 1 means can't go. Figure 5.
Figure 5