The project is a series of liveProjects that teaches you how to use specific algorithms to solve important programming problems. It covers topics such as recursion, linked data structures, trees, network algorithms, and more. You'll gain practical experience with various algorithmic topics, data structures, and programming techniques in this series of projects. Overall, this project aims to provide a comprehensive understanding of algorithms and their practical applications in programming.
This series of project steps involve using Python and various algorithms to manipulate binary and N-ary trees. Binary trees have at most two child nodes, while n-ary trees can have any number of child nodes. Throughout the portfolio, agile programming technique of frequent builds and thorough debugging are applied, with each unit covering incremental changes to the code. By adding version numbers to each program, different iterations can be tracked referencing previous milestones. The focus will be on sorting data, as well as storing, finding, and removing data in sorted trees. Additionally, it explores different layout approaches for organizing charts. By the end of the project, a base for a production-ready project on manipulating trees in Python and creating effective organizational charts will be scripted.
The classes BinaryNode and NaryNode have variables that refer to other objects of the same class. For instance, a BinaryNode can have a maximum of two BinaryNode "children". The recursive structure of a tree is made possible by the fact that nodes can have children that are also node objects.
See: binary_node1, See: nary_node1
This milestone showcases recursion, which is a crucial concept in trees. Additionally, it highlights the advantage of working with n-ary trees over binary ones, as an n-ary tree enables looping through a node's children, rather than dealing with each child individually. In fact, in certain scenarios, it might be more convenient to use an n-ary node class to represent a binary tree. However, some adjustments may be necessary to ensure that no node has more than two children in its children collection.
See: binary_node2, See: nary_node2
If you compare the str method (from the previous milestone) and the find_node method (from this milestone), you will notice that both methods use recursive traversal to perform some action throughout the tree. While the str method prints information about each visited node, the find_node method compares the value of the current node with a target value.
One notable difference between the two methods is that the find_node method can terminate the search as soon as it finds the target value, whereas str method always visits every node in the tree. Thus, while the find_node method is considered an exhaustive search since it may potentially visit every node in the tree, the str method is even more exhaustive as it always visits every node.
See: binary_node3, See: nary_node3
This project phase explores the traversal methods in a tree data structure, which involve recursively traversing the tree in different orders to visit its nodes. The methods covered in this context are preorder, inorder, postorder, and breadth-first traversals. The difference between these methods lies in the order in which they visit a node's children. While preorder, inorder, and postorder traverse to the bottom of the tree and work their way back up, breadth-first traversal uses a queue to visit nodes in a different order. All these methods build a list of visited nodes that can be iterated over to perform some action or execute a given method for each node.
See: binary_node4, See: nary_node4
This milestone is challengine in which separate recursive traversals of a tree are used to perform layout, draw links, and draw nodes. While each individual task is relatively simple, performing them in separate methods makes them easier to implement. However, it is possible to perform all the tasks in one recursive traversal, though it requires determination. The key is to perform each task after a recursive call returns, as each node's position depends on the positions of its children. The recommended approach follows the basic pattern of the "arrange_subtree" method: after arranging child subtrees and positioning the current node, links between the node and its children can be drawn followed by drawing the child nodes.
See: binary_node5, See: nary_node5