Day 54: Time for Examples on Pretty Print

I realized my recursive function was actually calculating the height of a tree rather than the depth. It’s not a big deal right now but based on the definitions that I spent time writing I got it wrong and it might cause issues later if I do it again. Anyways… I tried to finish up on the “Pretty Print” function but failed. I don’t know… I couldn’t execute on the rest of the function or something. I think I was sort of distracted today. Regardless, I have run through my allotted time for self discovery. I got some example functions to go through now and I will be copying and then trying to modify those once I feel comfortable. Maybe next time I’ll be able to build the function from scratch.

TLDR;

Okay, so here are the highlights of what I did:

  • Continued work on the “Technical Questions” section of the book “Cracking the Coding Interview” by Gayle Laakmann McDowell. Within that, I continued my work on Tree data structures. I have started to build some tooling by adding an unnecessary but cool function that will use a Preorder Traversal and then pretty print the tree to the terminal/console (whatever it’s called LOL). I started reading through some examples for pretty-printing a tree data structure. I could not figure it out on my own in the time I allowed myself to have. I would like to spend more time on this but this function is a fun exercise and it’s my first time building something like this. I can learn from examples a lot faster than trial and error on my own.

Reference Article

I am reading through this article’s example “Pretty Print” for a tree. Thankfully they have multiple forms that I can learn from.

Vertical Output Example

                              15

                    7

                              14

          3

                              13

                    6

                              12

1

                              11

                    5

                              10

          2

                              9

                    4

                              8

Horizontal Output Example


                                1

                2                                3

        4                5                6                7

    8        9        10        11        12        13        14        15

Conclusion

That’s all for today. This is my sixth round of the “#100daysofcode” challenge. I will be continuing my work from round five into round six. I am currently working through the book “Cracking the Coding Interview” by Gayle Laakmann McDowell. My goal is to become more familiar with algorithms and data structures. This goal was derived from my goal to better understand operating systems and key programs that I use in the terminal regularly e.`g. Git. This goal was in term derived from my desire to better understand the fundamental tools used for coding outside of popular GUIs. This in turn was derived from my desire to be a better back-end developer.

I have no idea if my path is correct but I am walking down this road anyways. Worst case scenario I learn a whole bunch of stuff that will help me out on my own personal projects.