Thursday

Efficiency and Time complexity of Functions

       
        The past few weeks of study has been a lot more interesting than just to get an function to work a certain way, analyzing the efficiency of an algorithm has allows me to look at writing functions and methods in a different perspective than just putting in blocks of code and making it work but rather lets me think about how each part of my code is going to effect the progress when an input produces an output.
        When we talk about the efficiency of functions and algorithms, we want to analyze the fundamental building blocks of how fast a program can run. Often times we would want to minimize the time it takes for an algorithm to compute a solution, but in doing so accuracy can be given up to give a faster solution. Which is why when we study the efficiency of an algorithm we are then able to determine whether it was worth giving up the accuracy of algorithm for a faster running time. The extension method in word ladder puzzle of assignment 2 is an perfect example to talk about this, when looking for the next possible extensions of the puzzle, there was different ways to go about it, the most generic way is for the function to provide all the possible next word and try look for a solution. In this case, when there are thousands and millions of words to look through, the running time will increase relatively fast when you increase the input yet it will always give an answer when an answer is reachable. However, there is a way faster way to approach the solution to really cut down on running time. By forcefully changing he first letter of the word into the first letter of the final solution and check if it is a possible extension from the original word, and doing so until there you've checked every letter or reached the solution. This method cuts down the running time by not checking the extensions that leads nowhere close toward the solution, but cuts down on accuracy as it is possible to lead into a dead end without returning the solution. However, when we a large text file containing millions and billions of words, we can assume that there will almost always exist enough words that is just 1 letter different from each other to reach our final solution. So the speed accuracy trade off can made up with other factors effecting the algorithm causing some to be more efficient than others, which is the reason why the study of efficiency is so important.
        After having going more in depth with why we code a certain way rather than how to put a bunch of code together and make the function work has really allowed me to think more about the field of Computer Science, from the beginning it was more just like 'oh I know how to put code together and make things work, therefore I'm good at computer science!', but in reality (or as I have just started to discover) there are so much more to it! So much better ways to structure out code so that we are able to come up with faster output timing.

No comments:

Post a Comment