Week 11-12. Pretty close to the end of the semester. This week was actually a throwback for me. I took CSC165 the previous semester, and the last week of this course was a topic covered in that course as well, which has to do with the efficiency of code, and run times. This deals with upper and lower bounds depending on the side of any given argument of size N.
Essentially The run time of any function written in python can be deduced to be constant, linear, or exponential (to varying degrees) depending on the body of the function itself, and how many loops it contains. The material was familiar to me and pretty easy to listen to and understand completely due to the material being covered in 165.
CSC 148 S
Thursday, 2 April 2015
Saturday, 21 March 2015
week 10 impressions
Week 10 we talked a lot about the previous assignment due
the other week, and ways to solve it. A very frustrating aspect was how Heap
decided to go over deep copies. Normally I would have been grateful, but the
timing of teaching us about deep copies was too late for us to use it. During
assignment 2 I had to ask a friend who had already taken CSC148 for help since
I couldn’t seem to tackle the Minimax function. He explained to me then what a
deep copy is, and that it would help significantly with the assignment. At this
point in time, Heap had not mentioned it at all. The assignments have been
relatively vague in directions, and the help that he gives either comes a week
before the assignment is due, or a week after it is due and it can be extremely
frustrating.
Other than that, this week we also learned about assertions
and how they can be used in maintaining code after being updated, which is
usually added by code in the format:
Assert <condition> , <error_string>
Which is essentially saying if not condition, then raise the
error string to avoid bugs that arise from updates.
Wednesday, 11 March 2015
week 9 impressions (week 10)
Week 9 consisted of a slightly new data type that was a
tree, but that is able to insert and delete nodes inside of the already
existing tree called a BST. The only feature that came off as especially unique
was that when inserting another bit of data (numbers) it would add itself into
the appropriate tree so that it would be in increasing order from left to right
from the root of the base.
We also had our midterm II this week which was much harder
than the first test which only dealt with classes. I had a lot of trouble
dealing with linked lists since I wasn’t nearly as familiar as I thought it was
with being able to navigate each through elements in a linked list so that may
turn out pretty badly.
Monday, 9 March 2015
week 9
On top of the assignment, last week we started looking at our newest topic/ADT: Linked Lists. This is a type of list that has any number of topics inside of it, while also containing a reference to another list. This data type is sequential because of how to reach any point in the linked list, you have to go through each previous element. this can significantly increase the time it takes to find a single element within the ADT. That said, the layout for this data structure is very clear cut and is easy to change elements within the list.
While on the surface, the concept of a linked list is coming off as a lot easier than the code itself but its interesting. The concept of having a list reference another list resounds the use of having a Root or BTNode have another node as a child which creates a bit more complex structure than a linked list.
week 8
Last week Heap introduced a new, a slightly altered version of a tree, known as a BTNode with a specific design of having the children having to have conditions that would determine if it were to the right or left of the root node.
I'm still trying to get a feel for working with trees, but the coding in the BTNode is very similar in design so it shouldn't be too hard to navigate.
Assignment 2 is due in a week and with that being said there is a lot of stress looking at and taking a stab at the assignment itself. Designing the Tippy game itself took a bit of thinking to figure out but I decided to make the grid for the into a list of numbers so a grid 3x3 would just be a list of [1,2,3,4,5,6,7,8,9] and changing the value of the gives numbers to either an x or an o when a player applies a move to the gamestate. Figuring out the algorithm for a winning condition was just a bit of computation, and a general formula in terms of the grid size can be used to find win conditions.
I'm still trying to get a feel for working with trees, but the coding in the BTNode is very similar in design so it shouldn't be too hard to navigate.
Assignment 2 is due in a week and with that being said there is a lot of stress looking at and taking a stab at the assignment itself. Designing the Tippy game itself took a bit of thinking to figure out but I decided to make the grid for the into a list of numbers so a grid 3x3 would just be a list of [1,2,3,4,5,6,7,8,9] and changing the value of the gives numbers to either an x or an o when a player applies a move to the gamestate. Figuring out the algorithm for a winning condition was just a bit of computation, and a general formula in terms of the grid size can be used to find win conditions.
Thursday, 26 February 2015
week 7
Recently in class we've been focusing a lot of time on recursion. What it is, where it is found, and what uses it can serve. The first thing that stuck out to me with the concept of recursion was how it tackles a problem that is very unique, but also common in computer science.
Recursion is essentially a way of repeatedly accomplishing a task until the task at hand is solved or becomes the most simplified form that it can be. The term for this simplified form is the base case. The process which a recursive function works is that it looks at a given state of a task, runs itself to check to see whether or not the current state is the base case; if not, the process will perform a function to simplify the task by 1 step, and then calling on the function again to repeat the same process on the task in its new state. This will continue to loop infinitely until the task becomes it's base case, in which it is solved.
An example of this can be seen by this function in python that looks at every element of a list, and adds them together.
def listsum(numList):
if len(numList) == 1:
return numList[0]
else:
return numList[0] + listsum(numList[1:])
the important things to note to understand the process of recursion are the names of the function itself and it's input to run, the base case conditions, and the non-base case task.
This example takes an input of a list. This list can vary in complexity from being of length 1, to any other length. It's base case is when the list only contains 1 item in the list. If the list isn't 1 item in length, it will look at the first number in the list, and add to it the return value of the same function, on a list that has taken out the first value.
The function first examines the list and has an if statement to see if it is the basecase. if it isn't, the function takes the first number in the list and adds it with listsum(numList[1:]). So the function repeats itself until the basecase condition is met, and the sum of the entire list is returned.
. A nice part about recursion is that if designed correctly, it doesn't matter how complex the situation or problem is. It repeatedly examines the input and only compares it to see if it is equivalent to the base case, so it doesn't look at a problem a set amount of times.What makes this so useful is because it significantly reduces the amount of code that is needed to look at specific problems. It simplifies solutions while also making them more intricate and optimized
Recursion is essentially a way of repeatedly accomplishing a task until the task at hand is solved or becomes the most simplified form that it can be. The term for this simplified form is the base case. The process which a recursive function works is that it looks at a given state of a task, runs itself to check to see whether or not the current state is the base case; if not, the process will perform a function to simplify the task by 1 step, and then calling on the function again to repeat the same process on the task in its new state. This will continue to loop infinitely until the task becomes it's base case, in which it is solved.
An example of this can be seen by this function in python that looks at every element of a list, and adds them together.
def listsum(numList):
if len(numList) == 1:
return numList[0]
else:
return numList[0] + listsum(numList[1:])
the important things to note to understand the process of recursion are the names of the function itself and it's input to run, the base case conditions, and the non-base case task.
This example takes an input of a list. This list can vary in complexity from being of length 1, to any other length. It's base case is when the list only contains 1 item in the list. If the list isn't 1 item in length, it will look at the first number in the list, and add to it the return value of the same function, on a list that has taken out the first value.
The function first examines the list and has an if statement to see if it is the basecase. if it isn't, the function takes the first number in the list and adds it with listsum(numList[1:]). So the function repeats itself until the basecase condition is met, and the sum of the entire list is returned.
. A nice part about recursion is that if designed correctly, it doesn't matter how complex the situation or problem is. It repeatedly examines the input and only compares it to see if it is equivalent to the base case, so it doesn't look at a problem a set amount of times.What makes this so useful is because it significantly reduces the amount of code that is needed to look at specific problems. It simplifies solutions while also making them more intricate and optimized
Wednesday, 18 February 2015
CSC148 week 5
This week we had only one hour of class due to our first midterm being on Wednesday. Class consisted of material covering how Unit Tests should work and how to import and execute them. The Unit test works by testing functions you've written in python and makes sure they have the desired outcome
The Midterm consisted of material mainly from the first few weeks related to Classes and Subclasses to create a student profile that could account for grades, and eligibility to graduate. Overall the test was not bad, and quite enjoyable.
The next days lab we learned and made another ADT, looking at how to make and use queues in the form of a list in which you can only modify the bottom and top of the stack with pop() and append(). Learning and making this class was relatively simple but also useful because of how often queues are used in everyday life.
The Midterm consisted of material mainly from the first few weeks related to Classes and Subclasses to create a student profile that could account for grades, and eligibility to graduate. Overall the test was not bad, and quite enjoyable.
The next days lab we learned and made another ADT, looking at how to make and use queues in the form of a list in which you can only modify the bottom and top of the stack with pop() and append(). Learning and making this class was relatively simple but also useful because of how often queues are used in everyday life.
Subscribe to:
Posts (Atom)