Three tools are available to analyze and solve complicated problems: figures, examples, and division.
There are a few methods to help candidates to formulate clear ideas. First, candidates can employ
some examples to help themselves to analyze problems. Simulating operations with one or two
examples may uncover the hidden rules. Second, figures are helpful to visualize abstract data structures
and algorithms. Many problems related to lists and binary trees might become easier if they are
visualized with figures. Another approach is to divide a complicated problem into multiple manageable
pieces and then solve them one at a time. Many recursive solutions, such as divide-and-conquer
algorithms, as well as dynamic programming algorithms, are all essentially utilization of division.
For example, it is quite a complex problem to convert a binary search tree into a sorted doubly linked list. When confronted with such a problem during interviews, candidates may draw some figures about one or two sample binary search trees and their corresponding sorted doubly linked lists in order to visualize the relationship between them. They can also try to divide a binary tree into three parts: the root node, the left subtree, and the right subtree. After the left and right subtrees are converted to linked lists, they are connected with the root node to form a sorted linked list, and the problem is solved. More details about this problem are available in the section Binary Search Trees and Double-Linked Lists.
For example, it is quite a complex problem to convert a binary search tree into a sorted doubly linked list. When confronted with such a problem during interviews, candidates may draw some figures about one or two sample binary search trees and their corresponding sorted doubly linked lists in order to visualize the relationship between them. They can also try to divide a binary tree into three parts: the root node, the left subtree, and the right subtree. After the left and right subtrees are converted to linked lists, they are connected with the root node to form a sorted linked list, and the problem is solved. More details about this problem are available in the section Binary Search Trees and Double-Linked Lists.
No comments:
Post a Comment