Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fixed issue #4 and implemented matrix transpose function #20

Open
wants to merge 13 commits into
base: master
Choose a base branch
from
Prev Previous commit
Next Next commit
implement InOrder traversal
  • Loading branch information
Mohammadjafari80 committed Feb 4, 2021
commit ae82e6265cfc32dd544e37458f3870a2d2584f75
13 changes: 13 additions & 0 deletions data-structures/binary-tree/bst.go
Original file line number Diff line number Diff line change
Expand Up @@ -171,6 +171,19 @@ func PreOrder(n *Node) []*Node {
return nodes
}

func InOrder(n *Node) []*Node {
var nodes []*Node

if n == nil {
return nodes
}

nodes = append(nodes, PostOrder(n.Left)...)
nodes = append(nodes, n)
nodes = append(nodes, PostOrder(n.Right)...)
return nodes
}

func PostOrder(n *Node) []*Node {
var nodes []*Node

Expand Down