FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
algorithm-examples/cpp-algorithm/src/tree/leaf_node_list.cpp at main · codejsha/algorithm-examples · GitHub
codejsha
/
algorithm-examples
Public
Notifications
You must be signed in to change notification settings
Fork
0
Star
2
Code
Issues
0
Pull requests
0
Discussions
Actions
Projects
Security and quality
0
Insights
Additional navigation options
Code
Issues
Pull requests
Discussions
Actions
Projects
Security and quality
Insights
Expand file tree
Breadcrumbs
algorithm-examples
/
cpp-algorithm
/
src
/
tree
/
leaf_node_list.cpp
Copy path
More file actions
More file actions
Latest commit
History
History
History
28 lines (26 loc) · 789 Bytes
Breadcrumbs
algorithm-examples
/
cpp-algorithm
/
src
/
tree
/
leaf_node_list.cpp
Copy path
File metadata and controls
28 lines (26 loc) · 789 Bytes
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
#
include
"
leaf_node_list.h
"
/*
*
* \brief Add leaf nodes to the list.
* \param root the root of the tree
* \param leaf_node_list leaf node list
*/
void
AddLeafNodeToList
(BinaryTree::Node<
int
>* root, std::vector<BinaryTree::Node<
int
>*>& leaf_node_list)
{
if
(root ==
nullptr
)
{
return
;
}
if
(root->
left
==
nullptr
&& root->
right
==
nullptr
)
{
leaf_node_list.
push_back
(root);
return
;
}
AddLeafNodeToList
(root->
left
, leaf_node_list);
AddLeafNodeToList
(root->
right
, leaf_node_list);
}
auto
LeafNodeList::CreateLeafNodeList
(BinaryTree::Node<
int
>* root) -> std::vector<BinaryTree::Node<int>*>
{
auto
leaf_node_list = std::vector<BinaryTree::Node<
int
>*>{};
AddLeafNodeToList
(root, leaf_node_list);
return
leaf_node_list;
}
Back
|
FazBrowse Home
|
New Git URL