This week, we revisited the topic of recursion. There was nothing new about understanding or even designing recursive functions, but one thing that stood out this week was how recursion could be used to implement certain ADTs such as binary trees, the topic for this week's lecture. Sadly, we only had time to go over the terminology of binary trees, so we never had the time to actually see its implementation. The implementation part piqued my interest so much that I decided to do a bit of research on this particular ADT.
It turns out that like a typical ADT, we can implement binary trees any way we want in our code. However, what surprised me the most was how we could use recursion to search our tree: depth-first search, breadth-first search, you name it. Even though I still haven't gotten my feet wet on recursion yet, I find the applications of it really interesting, like how binary trees are used by computers to evaluate math expressions. I do feel like I'm going to use this application of recursion in one of my assignments, which might be pretty difficult.
Luckily, I'm going to get a bit more practice with recursion from the labs, but it all depends on how much effort I put into the actual concept itself. I've heard that learning recursion only comes with practice, and I'm still struggling to implement recursive functions. Perhaps I'll try to come up with a couple of examples and pseudo-code and see if tracing the code actually helps me come up with some common strategies to carry out such functions. I would like to see more applications to recursion, such as some new ADTs or other real-world scenarios.
No comments:
Post a Comment