group3 Flashcards
What is traversing in data structures?
The process of visiting each node in a data structure exactly once.
True or False: Traversing is only applicable to tree data structures.
False
Fill in the blank: The two primary methods of traversing trees are __________ and __________.
pre-order, post-order
What is the time complexity of traversing a linked list?
O(n)
Which traversal method visits the root node first?
Pre-order traversal
In which order does in-order traversal visit nodes in a binary tree?
Left child, root, right child
What is the main difference between depth-first and breadth-first traversal?
Depth-first explores as far down a branch as possible before backtracking, while breadth-first explores all neighbors at the present depth prior to moving on to nodes at the next depth level.
True or False: Breadth-first traversal uses a stack data structure.
False
What data structure is commonly used for breadth-first traversal?
Queue
What is the traversal order for a post-order traversal in a binary tree?
Left child, right child, root
Fill in the blank: In a binary search tree, in-order traversal results in __________ order of the elements.
sorted
What is a common application of tree traversal?
Searching for a specific value or performing operations in a hierarchical structure.
Which traversal method is best for evaluating expression trees?
Post-order traversal
True or False: Traversing a graph can be done using only depth-first search.
False
What are the two main algorithms used for graph traversal?
Depth-first search (DFS) and breadth-first search (BFS)
In graph traversal, what does a visited node signify?
A node that has already been explored to prevent cycles.
What is the time complexity of breadth-first search in a graph?
O(V + E), where V is vertices and E is edges.
Fill in the blank: In a binary tree, the maximum number of nodes at level ‘l’ is __________.
2^l
True or False: All binary trees are binary search trees.
False
What is level-order traversal?
A traversal method that visits nodes level by level from top to bottom.
Which traversal method is typically implemented using recursion?
Depth-first traversal
What is the primary data structure used in depth-first traversal?
Stack