Sunday, 16 March 2014

Overcoming difficulties with code

Something that I found really challenged me this week was actually exercise 3. Up until now, the exercises had seemed a lot simpler and easier to complete, but I found myself having some trouble dealing with the third. While part A was was fairly easy, and only required a little tweaking by moving certain lines around and renaming some things, I found that part B was much harder to tackle. The reason for this is that I could not for the life of me find a way to both find the deepest path, and to add up the values of each node along that path. I was able to make it so that it could find the deepest path fairly easily, but all that it would do was return the depth in a number form, and not the actual values added up. I was also able to make a separate piece of code that would take the values of each node, but not add them up, and not take account of the path depth. Finally however, I was able to come to the realization that I could fix all of my problems by slightly altering my code that found the longest path. I merely changed the first part of the code, where I added the root at the beginning, so that it would recursively seek that in smaller and smaller levels down the path, while also finding the longest path with the greatest sum of values.

Last week, I also did something that I had not done before, and that was take part in the after lecture discussions with the prof and other students who had questions. This was back when A2 part 1 was being discussed (I missed a week of the blog, so I was unable to talk about this up until now), and we were discussing the different ways that the parts of the code could be implemented. The memories as to what exactly was being discussed during the time I was there are lost to me now, but I still remember how the discussion process made many concepts a lot easier to grasp. With each student and the professor bringing different viewpoints to the field, the different aspects of the code were broken down into much simpler pieces, allowing for an easier understanding of what they were meant to do, and how they could best be implemented. I did not stay for the entirety of the time, as I left after maybe five or ten minutes, but I feel that I took a lot away from the experience, and if I find that I am having trouble with any work in the future, I think I know a new place to turn to.

No comments:

Post a Comment