Skip to content

camilaherculano/algorithms

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

15 Commits
 
 
 
 

Repository files navigation

algorithms

Some useful algorithms to never forget

bfs.cpp

Input Format

The first line contains an integer n, the number of nodes in the tree. Next line contains n space separated integer where ith integer denotes node[i].data.

Remember that in a binary search tree, all nodes on the left branch of a node are less than the node value, and all values on the right branch are greater than the node value.

Output Format

The bfs function prints a single line with n integers denoting the node order in a bfs(breadth-first search) of the binary tree.

Sample Input

7

5 8 3 4 2 1 9

Sample Output

5 3 8 2 4 9 1

About

Some useful algorithms to never forget

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages