The strike has been going on for three weeks. Thus, we have not had labs or quizzes for the past three weeks. They are worth 10% of everyone's final CSC148 grade. My TA was quite helpful with the lab exercises because I could not do the labs on my own. I still can't do them on my own. While the strike has been going on, I started turning to Piazza or office hours to ask questions. Nevertheless, Professors Heap and Horton have been doing a great job with managing the course, office hours, and Piazza discussions while the TAs are gone, so hats off to them!
All of the following conditions must be present for a tree to be classified as a binary search tree:
- All data are comparable.
- Data in the left subtree are less than root.data.
- Data in the right subtree are greater than root.data.
Here is a visual representation of a binary search tree.
I found the lecture on mutating BSTs straightforward to follow. In the additional exercises for Lab 6, the insert function can be found, and the code implementation is based off the general formula for recursion: base case, then general case.
To implement insert, we need an accumulator variable as our return value. Next, we start with the base case: if the node is a root, we create a leaf using a variable. Then we look at conditions 2 and 3 from above. If the data in the left subtree are less than root.data, recursively insert new data in the left subtree. On the contrary, if the data in the right subtree are greater than root.data, recursively insert new data in the right subtree. Finally, return the accumulator variable.
As for the delete function, we looked at an algorithm to help us implement it together in lecture. It is very similar to the algorithm for insert, except we recursively remove data in either the left or right subtrees in this case. However, there are a few extra steps.
"I'm overwhelmed already," I think to myself as I attempt to understand how it works. |
I'm definitely going to practice with these two functions in Lab #8 while balancing work from my other courses.
This is the code that Prof. Heap showed us and had us work with.
This is the code that Prof. Heap showed us and had us work with.
I wish everyone the best of luck in A3 and the rest of the course! It's not easy, but it's not impossible! I'll leave you all with some motivation because positivity is key.
Definitely hats off to our professors for taking time in lecture to review the assignment and labs so that we have some feedback to work with! I agree that these labs are getting harder but I think getting help - even on previous topics - is helpful going forward towards this last assignment and exam.
ReplyDeleteAll the best!
All the best to you too in the last stretch of CSC148! :) Also, getting help is definitely the way to go.
Deleteığdır
ReplyDeletemaraş
afyon
bandırma
hakkari
VF8ZB