Sunday, 30 March 2014

Week 11 – Sorting and Efficiency

              Sorting is a powerful tool to find an item very quickly at a low computation cost. There are plenty of algorithms to choose from, each one has their advantages and disadvantages. Sorting can be used for many data types. An example of a sorting algorithm is the quick sort where you choose a pivot point; decide where the pivot point goes with respect to the rest of the list, and quick sort the remaining partitions until you have none left. This sorts our list very quickly and we can now find and pull out data out of the list fairly quickly, better than when it was unsorted. Another sorting algorithm is known as the merge sort where you divide the list in half and merge sort the halves (think recursion), after you merge the sorted results back into one list. Once again, a very simple and quick sort to have lying around. Efficiency is also known as Big-Oh, an upper bound for the runtime of an algorithm. The algorithm will never run longer than the upper bound that it was after a point C. The quick sort algorithm is Big-Oh of n lg n which can be rewritten as O(n lg n). This means that quick sort will never take longer than n lg n and will always be below it, thus it has a great efficiency of getting its job done.


              Something new I learned in class this week was how to make a sorting algorithm using recursion. Big-Oh was already known to be from a class from the last semester (CSC165). Nothing this week frustrated me and it was all clearly understood by me. Overall I feel very confident with the material this week. This week’s tutorial was the last tutorial which was saddening because the TA was one of the best I’ve ever had yet.

Sunday, 23 March 2014

Week 10 – Sorting Big-Oh

                The first thing we did in this lecture this week was getting a better understanding of assignment two. Danny went over the four functions with us for half an hour giving us a complete understanding of what we have to exactly achieve and some ways to achieving the functions requirements. The functions that Danny went over with us were the following: is_regex, all_regex_permutations, regex_match, build_regex_tree. After his talk on each one I understood my task much easier and what it was that I was exactly trying to accomplish for assignment two. After the assignment two help, we moved onto sorting. The first type of sort we covered was quick sort. You have to choose a pivot by deciding with respect to the rest of the list and repeat on the left over slices of the list. We had a digression mid lecture to show what happens if you put a default value of an empty list in a function definition if no value is specified. After that we headed over to merge sort. The idea here is to divide the list in half and merge sort the halves until it is completely sorted. After that you merge the sorted results together.
               

                We got our assignment one marks back and I have to say that I’m really glad with my results. I couldn’t have asked for anything better. The lab this week was not as challenging as the previous labs. I found this one much easier. I was able to complete about three fourths of the lab before running out of time. Midterm test two is coming up and will probably be more challenging than the first one. It’s time for me to start studying. So I’ll have to cut this blog short to stick my head back into my notes and start reviewing.

Sunday, 16 March 2014

Week 9 – Binary Search Trees, big-Oh

                Something new that I learned in class this week was binary search trees. I learned about big-Oh in CSC165 and it wasn’t new to me. Big-Oh during lecture was a good refresher since I did it last semester. Big-Oh is basically the performance of a programming being executed. The best programs run at constant time and the worst run at a time of factorial. In a binary search tree the data in the left sub tree is less than the value of the root. While the data in the right sub tree is greater than the root. This makes searching much more efficient. We learned about deletion of data from a binary search tree. This task can be very difficult because of the massive amounts of conditions needed to satisfy. A binary search tree in comparison to a list, a binary search tree will finish to task much faster on a large set of data. In a binary search tree, each time we narrow down the data to search by fifty percent which is extremely good. In lecture we also revisited selection sort and insertion sort from CSC108 last semester. We also looked at some running time analysis for various examples of code. The most enjoyable thing in class was binary search trees since I already knew about big-Oh.

                The lab was the most frustrating thing. We found out near the very end of the lab that we have to use recursion to solve our problem. Overall, I’m confident with this week’s material except for the lab we had this week. I’ll try to do the lab on my own during the next week in preparation for the midterm. We had an exercise due on trees. It was relatively easy and took about two hours to complete. 

Sunday, 9 March 2014

Week 8 – Linked Structures

                This week in class we continued our discussion about linked structures. Especially linked lists and how they can be represented using the tree class. Linked structures are more efficient than regular python lists. If you have a data structure of millions of items, a linked structure is your best bet for efficiency and speed. If you were to remove the first item from a list of millions of elements, it would take very long for the process to complete. Whereas with a linked list, you just change the head and tail of the element you are wanting to remove. We were taught two different concepts in linked lists this week. They are both useful but different. The first method is as a list made up of an item (value) and the remaining list (rest). The second method was to represent it as objects (nodes) with a value and a reference to other similar objects. This week we used the second method. We learned about a wrapper class for linked list, insertion into the list, deletion, reversing and string representation. We almost created a binary search tree that represents data as a tree. You can search the tree very efficiently for an element.
               

                In class I enjoyed the binary search tree the most. Learning about new data structures always sparks an interest in me. The most challenging and frustrating part was in tutorials when we had to use a recursive algorithm to create the functions of the class. It took us a long time to figure out we had to use recursion. I feel confident with the lecture material but not the lab material. We got our test marks back. I was satisfied with mine even after a huge mistake on the final question.