Thursday, 31 March 2016

Final Slog - Week 11

This is the final slog entry for CSC148. The course started off with the implementation of classes which were just introduced to us during the last few lectures of CSC108.

In this slog, I would like to revisit Trees and Recursion which were introduced in the Week 6. At first, the concept of moving from loops to using recursive function to make the code efficient, less complicated really scared me. I found the concept really hard and the codes were a nightmare but then discussing the problem with the professor totally changed my view about the concept. He just told me to retrace back the code and think again. This enhanced my working and understanding about the concept. Labs were not hard to understand anymore and the assignment 2 was not stressful at all.

The working of trees with recursion was the best part. The traversal techniques like, Preorder, Postorder, In-order and Lever-order and their different codes was really the most fascinating thing which I came across this course. The first one, In-order - (Left, root, right), Preorder - (root, left, right), Postorder - (left, right, root). The base case in all of these tree was, if n is None: return None. However, solving more and more questions in the labs, I realized that the base case was different a lot of times.

The concept of trees and Binary trees really made me think out of the box and the assignment really helped in the process of learning. The search functions in the Assignment made me fall in love with the tree ADT.
           
                                      

The search functions did not use the normal tree, this was a special type of tree. The assignment made me realize that the programmers can use trees and modify it according to their needs, whatever they want to use it like.

All in all, I had a great time in this course, learned a lot about the different concepts the course offered and would really like to take more Computer Science courses in the distant future.

Saturday, 26 March 2016

Crossover of CSC165 and CSC148 - Week 10

This week covered recursion efficiency, searching, sorting and big-Oh(O). Basically, the faster the code runs, the better it is but faster is not always the most practical thing. Also, Big Oh was not completed but will be started off with the next week. 

This week was really time consuming as we had to finish the assignment which was due this week. Efficiency, which was the main focus this week was also noted in our Assignment 2 in the class Puzzle_Tools where the faster the code runs, the lesser time it takes to solve the puzzles.

Plus, the first week in which there was a relation between CSC148 and CSC165, I really liked it :p

Friday, 18 March 2016

TermTest2 - Week 9

This week was a really hard week for me. I studied really hard for the test in order to get marks to push my average up. All effort was gone into understanding recursion and getting deeper and deeper into the concept of Binary Search Trees.

All in all, I found the test of medium difficulty, though I think I really did well (according to me). The test had 4 questions, three 8 markers and one 6 marker question. According to me, I found the question in which you had to return the nodes lower than the depth(n) provided,  really hard but I think I did okay in that as well.

Also, this week Binary trees and Binary Search trees was taught in the lectures. This week was a really good week for me.

Sunday, 13 March 2016

Tree - Week 8

This week, the lectures were about the binary trees which are connected through nodes(linked lists).
                                       
Here the root is node 8, which has 2 children, node 3 and node 10, which have 2 and 1 children respectively and so on.

The lectures also covered the height, Arity(maximum branching factor), depth of the tree and other functions such as the different ways of traversing the tree, like LevelOrder, PreOrder, PostOrder, InOrder.

The labs weren't that hard as it was basically counting the leaves of the tree(nodes with no children) which was to be done through recursion.

Thursday, 3 March 2016

Recursion : Week 7

Recursion is a new topic which has been covered this week. In the starting it was hard to understand as it is a bit complicated. From what I understand, Recursion is a way of coding, in which a function calls itself one or more times in its body. Basically, it returns the return value of this function call. 
If a function definition fulfils the condition of recursion, we call this function a Recursive function. 

Termination : The termination of these functions occur if with every recursive call the return value of the problem is downsized and moves towards its base case. A base case is a case where no further recursion is required or occurs. 

Note : If there is no base case, recursion can lead to an infinite loop. 

Example, the way in which the factorial recursive function works : 
4! = 4 * 3!
3! = 3 * 2!
2! = 2 * 1! (the recursive function breaks here as n becomes 1)

Replacing the calculated values gives us the following expression : 
4! = 4 * 3 * 2 * 1 

def fact(n):
   """This is a recursive function to find the factorial of an integer, n
   ””"
   if n == 1:
       return 1
   else:
       return (n * fact(n-1))

The above is the code of a sample recursive function(factorial), here the base case is at n = 1 where the function returns the value 1.

Advantages of recursion : 
  1. Usage of recursive functions make the code look clean and elegant.
  2. Using recursion, a complex task can be broken down into simpler sub-problems.

Disadvantages of recursion : 
  1. Sometimes the logic behind recursion is hard to follow.
  2. Recursive calls take up a lot of memory and time.