The readings for Monday, September 05 are:
Data Structures and Other Objects Using C++:
The focus of the reading is on binary trees and some of the modern features of C++11 such as smart pointers.
If you do not have the primary textbook, you can use the following free alternative texts instead:
Data Structures & Algorithm Analysis
Once you have completed the readings, answer the following questions in the
reading02/README.md
file in your assignments repository:
Given a binary tree with N nodes.
What is the minimum height of the tree?
What is the maximum height of the tree?
Answer in terms of Big-O.
Given the following binary tree:
How would you represent the binary tree using an array? Sketch the result using ASCII Art such as:
0 1 2 [ ... | ... | ... ]
When would it be better to use an array representation of a binary tree over the traditional node based representation?
Given the following binary tree:
Record the nodes you would visit if you performed a breadth-first traversal of the binary tree (assume you go left-to-right when crossing a layer).
Record the nodes you would visit if you performed a depth-first traversal of the binary tree (assume you are using a pre-order approach).
Answering with a generic container such as a linked list or array is not specific enough. Instead, you need to think about which sort of adaptor you would use.
Suppose we had the following struct Node
:
struct Node { int value; struct Node *left; struct Node *right; };
Modify the struct Node
above to use smart pointers.
What are the benefits of using smart pointers in this struct Node
?
To submit your solution, you must initiate a Merge Request in your private assignments repository and assign it to the appropriate TA from the Reading 02 - TA assignment list.
To facility the Merge Request workflow, you must do your development in its own branch:
$ cd path/to/repo # Go to your repository $ git checkout master # Make sure we are on master branch first $ git pull # Make sure we have changes from GitLab $ git checkout -b reading02 # Create reading02 branch ... # Do your work $ git commit # Commit your work (can do this multiple times) $ git push -u origin reading02 # Push branch to GitLab