Thursday, 5 March 2015
Impressions of recursive data types (Week 8 SLOG)
Last week, we looked at a different type of tree called a binary tree, where each node only has two children. In some ways, the binary tree is simpler than a standard tree, as we can assign variables to the left child and right child, rather than finding a desired node through indexing. Not only does this make writing recursive code slightly easier (in my opinion), but it is also less mind-twisting to think about (again, in my opinion). Additionally, we looked at a type of binary tree called a binary search tree, where the left child node is always less than the current node, and the right child node is always greater than the current node. This makes searching for a particular node much more efficient, as you can effectively reduce your search time in half with the first iteration. In lab 6, we looked at implementing functions using a binary tree. Some of these functions proved to be more challenging as the conditions for desired results were usually more numerous than past exercises. Careful implementation and meticulous testing seem to be vital in order to write functions for these trees, binary search trees in particular.
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment