Graph and Tree Traversal methods Flashcards
what are the two ways of traversing a graph
depth first approach, breadth first approach
what is the method of conducting a depth first approach on a graph
travel down each branch then nachtrack
what is the method of conducting a breadth first approach on a graph
look at all the connection on a node then travel to the next node
does the order of nodes when traversing a graph matter
no, they will acheive the same purpose
what are the three methods of traversing a tree
preorder traversal, inorder traversal, postorder traversal
what is the method of conducting a preorder approach on a tree
it is a top down traversal method, where the roots is met first
what is the method of conducting a inorder approach on a tree
left to right traversal method, where the root is met in the middle step
what is the method of conducting a postorder approach on a tree
bottom up traversal method, where the root is met last
how can the order be worked out by using dots
after placing the dots a line is drawn anticlockwise and any dot that connects is recorded, for preorder dots are on the left, inorder has them below and for post order they are to the right