This is going to be my final SLOG entry for this course. We received our SLOG evaluations today in lecture, and I don't think I realized how easy it was to type up these things until today, when I realized that my thoughts on these topics have come so naturally this entire semester.
It's been a pretty long semester - I learned a new programming language - make it 2, or 3, or 4. I learned a lot about computers, a lot about programming, a lot about abstraction, even a lot about math. I learned the basics of a skill and mindset which I believe may be fundamental to my career later on, and I did enjoy doing it. Both assignments were incredibly engaging. The labs were very relaxing, and the lectures were quite informative. It's been a good semester, and I know that I'll be taking more classes next year, in order to further my skills, attain more knowledge, and set me up for the future.
Wednesday, April 6, 2016
Wednesday, March 30, 2016
Revisiting a Post - on Abstract Data Types, Linked Lists, and Memory
In my post on Thursday, February 11th, I said that I would learn more about hash tables, how linked-lists save memory, and data structures and sorts in general. After reading a lot more about data structures and efficiency (in Big O notation), I feel like I've learned enough to answer some questions.
From reading the WikiBook Data Structures, as well as perusing through many, many Harvard C50 videos, I know now that linked-lists generally simplify matters because data doesn't have to be stored contiguously. In addition, arrays have to have a preset size, so in order to grow arrays, they need to be completely copied to a larger array. which takes O(n) time, amortized to O(1) (since we do it 1/n of the time). However, linked lists can be dynamically resized. The main disadvantage to linked-lists is that searching elements takes O(n) time in the worst case, while it takes O(1) time in an array.
In addition, I learned about many other data structures, such as hash tables, red-black trees, and tries. Each has their own advantages and disadvantages, and often I've learned that there's a trade-off between time-complexity and space-complexity for data structures. In addition, in regards to sorting algorithms. I learned and became comfortable with all the standard algorithms taught in class such as bubble sort, insertion sort, selection sort, merge sort, and quick sort, but also learned about heap sort (another data structure I learned about was a heap), counting sort, and radix sort.
So in all, what's happened since the beginning of last February? I feel like every blog post I've made so far has shown a new subject that I learned about, or a new area that I'm interested in - and at the end of it all, I feel like I've done a pretty good job, on my own time, to learn some pretty interesting and useful material in this subject. I've taken the topics that we've learned in class and searched them up, so that I get more comfortable with them, but also because I have a desire to scratch more than the surface. In essence, I feel like this is the basis of learning - a desire to scratch beyond the surface. To find out what you're not being told. And I feel like I've embraced that, and learned immensely.
From reading the WikiBook Data Structures, as well as perusing through many, many Harvard C50 videos, I know now that linked-lists generally simplify matters because data doesn't have to be stored contiguously. In addition, arrays have to have a preset size, so in order to grow arrays, they need to be completely copied to a larger array. which takes O(n) time, amortized to O(1) (since we do it 1/n of the time). However, linked lists can be dynamically resized. The main disadvantage to linked-lists is that searching elements takes O(n) time in the worst case, while it takes O(1) time in an array.
In addition, I learned about many other data structures, such as hash tables, red-black trees, and tries. Each has their own advantages and disadvantages, and often I've learned that there's a trade-off between time-complexity and space-complexity for data structures. In addition, in regards to sorting algorithms. I learned and became comfortable with all the standard algorithms taught in class such as bubble sort, insertion sort, selection sort, merge sort, and quick sort, but also learned about heap sort (another data structure I learned about was a heap), counting sort, and radix sort.
So in all, what's happened since the beginning of last February? I feel like every blog post I've made so far has shown a new subject that I learned about, or a new area that I'm interested in - and at the end of it all, I feel like I've done a pretty good job, on my own time, to learn some pretty interesting and useful material in this subject. I've taken the topics that we've learned in class and searched them up, so that I get more comfortable with them, but also because I have a desire to scratch more than the surface. In essence, I feel like this is the basis of learning - a desire to scratch beyond the surface. To find out what you're not being told. And I feel like I've embraced that, and learned immensely.
Friday, March 25, 2016
Assignment 2
This past week, we finished assignment 2. Although we hadn't learned anything about algorithm efficiency yet for the assignment, I had already found myself trying to speed things up throughout the assignment, in any ways that I knew - often trying to implement the most clever strategy or failfast for a game. Overall, the assignment went quite smoothly, and though there was indeed some debugging to be done, I feel that the process of debugging taught me more about my program.
The sudoku game was quite simple to implement - most of the methods were already implemented, and there were very clear instructions on how to implement the last one.
The word ladder game was simple to implement - but we took quite a long time thinking of an effective failfast for the game - as we saw the the text file had almost 100k words, we were thinking of ways to optimize the game's searching so we wouldn't have to go through 100k words every time.
The grid peg solitaire game was actually quite difficult to implement - its implementation was mostly the same as the MN-puzzle's implementation, but we were caught off guard by the fact that our grids would be affected by each swap when creating extensions - so we would create far more extensions than desired. We fixed it with a deepcopy.
The MN puzzle's usage of tuples was quite annoying, as we wanted to change variables within the puzzle for the extensions, but had to go through a convoluted method of creating lists and then changing back into tuples - I feel like there should be a more clever way to solve the problem, but this was the implementation that we went with. Importantly, for the MN puzzle, I used some theory that I picked up on CSC240 and MAT495, proving that there's always an invariant for the puzzle, and thus we implemented an effective fail-fast which could tell immediately whether a puzzle was solvable or not.
Initially, we wanted to use recursion to implement the searches, but we couldn't figure out how to keep track of the visited configurations with recursion - so instead we used the deque and implemented both searches iteratively with a while loop.
Most of the puzzles run quite quickly - the longest would be the sudoku puzzle 2 - which can take up to 2 minutes if we're unlucky, but can take as little as 10 seconds. The other puzzles all take well under 1 minute, many in fractions of seconds.
The sudoku game was quite simple to implement - most of the methods were already implemented, and there were very clear instructions on how to implement the last one.
The word ladder game was simple to implement - but we took quite a long time thinking of an effective failfast for the game - as we saw the the text file had almost 100k words, we were thinking of ways to optimize the game's searching so we wouldn't have to go through 100k words every time.
The grid peg solitaire game was actually quite difficult to implement - its implementation was mostly the same as the MN-puzzle's implementation, but we were caught off guard by the fact that our grids would be affected by each swap when creating extensions - so we would create far more extensions than desired. We fixed it with a deepcopy.
The MN puzzle's usage of tuples was quite annoying, as we wanted to change variables within the puzzle for the extensions, but had to go through a convoluted method of creating lists and then changing back into tuples - I feel like there should be a more clever way to solve the problem, but this was the implementation that we went with. Importantly, for the MN puzzle, I used some theory that I picked up on CSC240 and MAT495, proving that there's always an invariant for the puzzle, and thus we implemented an effective fail-fast which could tell immediately whether a puzzle was solvable or not.
Initially, we wanted to use recursion to implement the searches, but we couldn't figure out how to keep track of the visited configurations with recursion - so instead we used the deque and implemented both searches iteratively with a while loop.
Most of the puzzles run quite quickly - the longest would be the sudoku puzzle 2 - which can take up to 2 minutes if we're unlucky, but can take as little as 10 seconds. The other puzzles all take well under 1 minute, many in fractions of seconds.
Thursday, March 17, 2016
Binary Trees, and then Assignment 2
This past week, we've been working on binary trees, had our second midterm, and will have assignment 2 due in about a week.
I feel like binary trees are a good specialization of the general Tree structure - they model real world yes/no decision making, as well as predicate/propositions (things that can evaluate to 2 things) quite well. In addition, they can represent binary operations such as the basic arithmetical operations, as we have shown in class. In all, I feel quite comfortable with the recursive processes applied onto binary trees, though I do feel that more practice would always help.
I am currently working on assignment 2 - so far, I think it's going to be an interesting assignment (I love solving puzzles regardless).
I feel like binary trees are a good specialization of the general Tree structure - they model real world yes/no decision making, as well as predicate/propositions (things that can evaluate to 2 things) quite well. In addition, they can represent binary operations such as the basic arithmetical operations, as we have shown in class. In all, I feel quite comfortable with the recursive processes applied onto binary trees, though I do feel that more practice would always help.
I am currently working on assignment 2 - so far, I think it's going to be an interesting assignment (I love solving puzzles regardless).
Thursday, March 10, 2016
Binary (n-ary) Trees
This past week, we worked on binary (and really, generally any arity) trees. In general, I felt that the tree structure is quite an important and intuitive way to think of data - and so I want to spend the next week thinking about and learning about different ways in which trees are used. I know that they're used in searches, in sorts, but I'd also like to find other methods in which to use trees.
In particular, I feel that the power of recursion displays itself quite well when applied to trees - since the set of trees is recursively defined, we can use recursion to characterize and employ functions on trees very easily.
In particular, I feel that the power of recursion displays itself quite well when applied to trees - since the set of trees is recursively defined, we can use recursion to characterize and employ functions on trees very easily.
Wednesday, March 2, 2016
Recursion
These past 2 weeks, we've been working on Recursion - what I view to be one of the fundamental concepts in computer science, and also a concept that can result in rather powerful functions being created in simple ways. In terms of class content, I felt that I was quite comfortable with the simpler examples and exercises in recursion presented in class - perhaps because it's a topic that I've dealt with in the past, and which requires some level of mathematical/analytical skill, which I feel is one of my stronger traits as a computer scientist.
I was quite interested in the concept of solving recurrences, as that links closely to topics that have been covered in other classes that I have taken or am taking (MAT495 and CSC240), and so I found it quite enjoyable to break down a recurrence to understand what it truly does - and in many cases, the function is actually quite complex for a very short segment of code - the power of recurrence, I suppose.
But in effect, I believe that I was more interested in employing recurrences, and thus I spent quite a deal of time thinking about areas in which recurrences could be used. I was quite intrigued to learn that the recursively defined Fibonacci number function was actually substantially slower than that using a loop (it proceeds in O(2^n), exponential time) and so there were areas where a recurrence might actually be detrimental to a program. However, I also learned over the week that it becomes a much simpler task to employ sorting methods using recurrences, as well as to define tree structures. In fact, I found the tree with directed edges defined under the recurrence method to be quite a clever construction.
In effect, I'm quite excited to continue learning about recurrences, as well as to employ them in my future ventures wherever necessary and viable.
I was quite interested in the concept of solving recurrences, as that links closely to topics that have been covered in other classes that I have taken or am taking (MAT495 and CSC240), and so I found it quite enjoyable to break down a recurrence to understand what it truly does - and in many cases, the function is actually quite complex for a very short segment of code - the power of recurrence, I suppose.
But in effect, I believe that I was more interested in employing recurrences, and thus I spent quite a deal of time thinking about areas in which recurrences could be used. I was quite intrigued to learn that the recursively defined Fibonacci number function was actually substantially slower than that using a loop (it proceeds in O(2^n), exponential time) and so there were areas where a recurrence might actually be detrimental to a program. However, I also learned over the week that it becomes a much simpler task to employ sorting methods using recurrences, as well as to define tree structures. In fact, I found the tree with directed edges defined under the recurrence method to be quite a clever construction.
In effect, I'm quite excited to continue learning about recurrences, as well as to employ them in my future ventures wherever necessary and viable.
Thursday, February 25, 2016
Completing Assignment 1
Over the reading break, we finished our first larger assignment in this class. As it was one of the larger projects that I've coded for a while, there were a few important take-aways from this project
1. Break down the problem.
It was much easier to simply focus on implementing every single small part of the ride-sharing simulation at a time. My partner and I focused on Location, then Container, then Driver, then Rider - doing the most basic classes before trying to implement higher level classes. In doing so, I realized that by simply breaking down the problem beforehand when planning the project, and then focusing on each class' function makes the problem much easier to solve.
2. Trace back the errors.
There were many errors in initial code while doing the assignment - checked during doctests, or during runtime, or otherwise. An important skill I worked on during the assignment was reading my error messages, tracing them back to the root of the problem, and hence fixing the errors.
3. Repeatedly test the code - any small misstep can ruin things.
One example of an error that I created, and took about 20 minutes to fix, was that instead of the request_driver method finding the driver who was closest to the rider's origin, I accidentally made the rider find the driver who was closest to the destination. I realized later that this could have been easily avoided if I tested that method more rigorously - and that I should thus try to rigorously test every portion of my code as I developed it.
1. Break down the problem.
It was much easier to simply focus on implementing every single small part of the ride-sharing simulation at a time. My partner and I focused on Location, then Container, then Driver, then Rider - doing the most basic classes before trying to implement higher level classes. In doing so, I realized that by simply breaking down the problem beforehand when planning the project, and then focusing on each class' function makes the problem much easier to solve.
2. Trace back the errors.
There were many errors in initial code while doing the assignment - checked during doctests, or during runtime, or otherwise. An important skill I worked on during the assignment was reading my error messages, tracing them back to the root of the problem, and hence fixing the errors.
3. Repeatedly test the code - any small misstep can ruin things.
One example of an error that I created, and took about 20 minutes to fix, was that instead of the request_driver method finding the driver who was closest to the rider's origin, I accidentally made the rider find the driver who was closest to the destination. I realized later that this could have been easily avoided if I tested that method more rigorously - and that I should thus try to rigorously test every portion of my code as I developed it.
Thursday, February 18, 2016
Assignment 1
This past week, I've been busy working on assignment 1 of our class. Though I initially felt that the project would be an overwhelming amount of work, with the provided APIs as well as a great deal of planning, I'm finding it much more straightforward than I previously imagined.
Dividing the task and focusing on coding the modules 1 by 1 simplifies the problem a great deal - however the only challenge is remembering how all the modules are interconnected to achieve any desired goal. I don't find the coding component to be particularly difficult, but rather the organization and coordination of the different parts is the main challenge.
I find that some of the instructions contained in some of the APIs are rather vague - however most of my questions have been cleared up by either the professor, TAs, or Piazza.
Dividing the task and focusing on coding the modules 1 by 1 simplifies the problem a great deal - however the only challenge is remembering how all the modules are interconnected to achieve any desired goal. I don't find the coding component to be particularly difficult, but rather the organization and coordination of the different parts is the main challenge.
I find that some of the instructions contained in some of the APIs are rather vague - however most of my questions have been cleared up by either the professor, TAs, or Piazza.
Thursday, February 11, 2016
Abstract Data Types, Linked Lists and Memory
The past week, we've been working on abstract data types, specifically learning about Linked Lists, after our foray into Stacks and Queues (data types which I discovered are very prominent in every programming language). I've been able to grasp the concept of a Linked List quite well - doing the lab quite rapidly and without much trouble (passed all the doctests and tried a bunch of fringe cases), but the most interesting thing about a Linked List is the idea that it saves memory.
In what way do Linked Lists actually save us memory? We were told in class that it's due to the simplicity of the data structure and how each separate Node keeps track of simply 2 things - a value and a pointer to the next Node. However, what is it about lists that make it a less efficient (from a memory standpoint) data structure. How about hash tables? I believe that I'll do a bit of extra reading to satisfy my curiosity on this subject.
Meanwhile, I've sated some curiosity on the topic of efficiency when it comes to sorting algorithms. I was curious as to the algorithm by which Python's list.sort() method works, so I searched it up. It's called Timsort, after a guy named Tim (!), and the algorithm seems quite complicated - so I haven't delved very deeply into trying to understand it. However, I have gotten used to the more basic algorithms with sorting - bubble sort, selection sort, insertion sort, merge sort, quicksort, and heap sort - so it'll just be a matter of time until I finally try to understand how Timsort works.
In what way do Linked Lists actually save us memory? We were told in class that it's due to the simplicity of the data structure and how each separate Node keeps track of simply 2 things - a value and a pointer to the next Node. However, what is it about lists that make it a less efficient (from a memory standpoint) data structure. How about hash tables? I believe that I'll do a bit of extra reading to satisfy my curiosity on this subject.
Meanwhile, I've sated some curiosity on the topic of efficiency when it comes to sorting algorithms. I was curious as to the algorithm by which Python's list.sort() method works, so I searched it up. It's called Timsort, after a guy named Tim (!), and the algorithm seems quite complicated - so I haven't delved very deeply into trying to understand it. However, I have gotten used to the more basic algorithms with sorting - bubble sort, selection sort, insertion sort, merge sort, quicksort, and heap sort - so it'll just be a matter of time until I finally try to understand how Timsort works.
Wednesday, February 3, 2016
Impressions on List Comprehensions, Unit tests, Doc Tests, Stacks, and Queues
Frank back. So that was quite a busy week for me. I currently have the PEP8 conventions guide open on my laptop, as well as an umpteen other resources and links to fill in any gaps of knowledge that I feel like I still have, with both Python and computer science in general.
I feel like I picked up the concept of list comprehensions quite quickly, as I liken the syntax to set notation in mathematics or logical notation - another class that I'm currently taking. As a result, I feel like I understand the intuition behind list comprehensions quite well, and therefore can read and create them quite comfortably.
I also understand the concept behind doctests and unittests, as I've been reading up on them recently - however I feel like the difficult part is definitely looking for the fringe cases that any program that we create would have to test. I feel like I'd need quite a bit of practice thinking of testable client code for my programs in order to write useful doctests and unittests.
I feel like ADTs are quite a wide-ranging and complicated subject, but given their importance, I will likely try to become comfortable with the concept. With regards to specifically the Stack and Queue ADTs, I was quite comfortable with the implementation and reasoning behind them - though I feel like I will face more challenges when creating a more complicated program that will have to incorporate these data types.
I feel like I picked up the concept of list comprehensions quite quickly, as I liken the syntax to set notation in mathematics or logical notation - another class that I'm currently taking. As a result, I feel like I understand the intuition behind list comprehensions quite well, and therefore can read and create them quite comfortably.
I also understand the concept behind doctests and unittests, as I've been reading up on them recently - however I feel like the difficult part is definitely looking for the fringe cases that any program that we create would have to test. I feel like I'd need quite a bit of practice thinking of testable client code for my programs in order to write useful doctests and unittests.
I feel like ADTs are quite a wide-ranging and complicated subject, but given their importance, I will likely try to become comfortable with the concept. With regards to specifically the Stack and Queue ADTs, I was quite comfortable with the implementation and reasoning behind them - though I feel like I will face more challenges when creating a more complicated program that will have to incorporate these data types.
Wednesday, January 27, 2016
Opening Impressions of Computer Science and Python
This is my first post on this blog, which will continue to detail my impressions and weekly objectives throughout my first semester of learning computer science. In doing so, I'll be able to reflect on whether I achieved my goals, and perhaps gleam out some overarching themes that tie my semester together.
Coming from a Java background, another object-oriented programming language, and without any Python experience, I've spent the opening few weeks of the semester catching up on knowledge about Python conventions - but also reviewing my previous computer science knowledge. Though some of the assignments appear at first to be quite challenging, the course material seems interesting so I'm currently confident that I'll stay motivated to keep up with the course. Python seems to be quite a forgiving language, and I'm relieved that a lack of semicolons will no longer immobilize my code.
For now, I'll simply continue reading up on and practicing many Python concepts with which I'm not yet comfortable, and I'll return next week with additional details about (hopefully) neat concepts!
Coming from a Java background, another object-oriented programming language, and without any Python experience, I've spent the opening few weeks of the semester catching up on knowledge about Python conventions - but also reviewing my previous computer science knowledge. Though some of the assignments appear at first to be quite challenging, the course material seems interesting so I'm currently confident that I'll stay motivated to keep up with the course. Python seems to be quite a forgiving language, and I'm relieved that a lack of semicolons will no longer immobilize my code.
For now, I'll simply continue reading up on and practicing many Python concepts with which I'm not yet comfortable, and I'll return next week with additional details about (hopefully) neat concepts!
Subscribe to:
Posts (Atom)