avatar
c*e
1
In the following graph, with starting point 0, what is the order of DFS
traversal?
0
/ \
1 2
/
3
We use a stack for DFS visit. The problem is, is the visit order the order each node is pushed into the stack, or the order each node is popped from the stack.
avatar
r*e
2
http://www.ncbi.nlm.nih.gov/pubmed/24341493
Bioanalysis. 2014 Jan;6(1):33-42. doi: 10.4155/bio.13.280.
An ultrasensitive method for the quantitation of active and inactive GLP-1
in human plasma via immunoaffinity LC-MS/MS.
请e-mail到[email protected]/* */
谢谢。
avatar
q*x
3
dfs is post-order.

each node is pushed into the stack, or the order each node is popped from
the stack.

【在 c**********e 的大作中提到】
: In the following graph, with starting point 0, what is the order of DFS
: traversal?
: 0
: / \
: 1 2
: /
: 3
: We use a stack for DFS visit. The problem is, is the visit order the order each node is pushed into the stack, or the order each node is popped from the stack.

avatar
c*e
5
Are you sure? A professor says the answer is 0213 or 0132.

【在 q****x 的大作中提到】
: dfs is post-order.
:
: each node is pushed into the stack, or the order each node is popped from
: the stack.

avatar
P*l
6
这个问题很奇怪呀
都用stack了,显然是pop的顺序啊
要是push就用queue了吧

each node is pushed into the stack, or the order each node is popped from
the stack.

【在 c**********e 的大作中提到】
: In the following graph, with starting point 0, what is the order of DFS
: traversal?
: 0
: / \
: 1 2
: /
: 3
: We use a stack for DFS visit. The problem is, is the visit order the order each node is pushed into the stack, or the order each node is popped from the stack.

avatar
r*t
7
Seriously? I thought only pre-order visits nodes in the same order as dfs,
although all three traversal can be implemented using dfs.

【在 q****x 的大作中提到】
: dfs is post-order.
:
: each node is pushed into the stack, or the order each node is popped from
: the stack.

avatar
q*x
8
look at clrs graph dfs algorithm. it's post-order. parent node is colored
after children nodes.

【在 r****t 的大作中提到】
: Seriously? I thought only pre-order visits nodes in the same order as dfs,
: although all three traversal can be implemented using dfs.

avatar
r*t
9
Fig 22.4?
grey = discovered
black = finished
If visiting is defined as finished, then yes it is post-order;
if visiting is defined as discovered, then it is pre-order.

【在 q****x 的大作中提到】
: look at clrs graph dfs algorithm. it's post-order. parent node is colored
: after children nodes.

avatar
c*e
10
Did you intend to post an attachment?

【在 r****t 的大作中提到】
: Fig 22.4?
: grey = discovered
: black = finished
: If visiting is defined as finished, then yes it is post-order;
: if visiting is defined as discovered, then it is pre-order.

avatar
q*x
11
every type of traversal needs to discover root b/4 children.

【在 r****t 的大作中提到】
: Fig 22.4?
: grey = discovered
: black = finished
: If visiting is defined as finished, then yes it is post-order;
: if visiting is defined as discovered, then it is pre-order.

相关阅读
logo
联系我们隐私协议©2024 redian.news
Redian新闻
Redian.news刊载任何文章,不代表同意其说法或描述,仅为提供更多信息,也不构成任何建议。文章信息的合法性及真实性由其作者负责,与Redian.news及其运营公司无关。欢迎投稿,如发现稿件侵权,或作者不愿在本网发表文章,请版权拥有者通知本网处理。