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.




Sunday, 28 February 2016

Recursion - Week 6






This week was all about recursion and its usage. Though, the time taken by recursion might be more than the usual loops, it is easier to apply for complex problems.

The function factorial above is made through recursion. Recursion and loops both can be controlled by the programmer(interface).

Here are some rules about factorials, If n = 0 then n! = 1 If n > 0 then n! = 1 x 2 x 3 x ... x n
For example, let's look at the factorial of the number 7:
7! = 7*6*5*4*3*2*1


Let's look at a program which calculates the factorial of any number entered by the user, by method of recursion.

Thursday, 11 February 2016

Midterm Week 5

The first midterm of the course CSC148 was this week. Though midterm keeping the mind in time was really lengthy.

The test was of medium difficulty umm, was not exactly difficult but the build-up of multiple classes took a lot of thinking time.

I couldn't complete the exam in 50 minute and I don't know if I will be able to get 80+ in this exam.

Friday, 5 February 2016

Stacks and Queues - Week 4

This week was about Stacks, Queues and linked lists.
The lab was comparatively easier as I have practised the implementation of Stacks, queues and linked lists in high school in C++.

The implementation was easier than that in C++. The quiz of the lab was about the stack status and how things go inside and out of the queue.

Things go inside and out of the stacks by LIFO(Last in First out) method and in queues by FIFO(First in first out). There are four methods which have been assigned with both of these: Insertion, Deletion, __eq__, __str__.

The system by which one node is connected to another in a linked list really makes it the most interesting part.

Wednesday, 27 January 2016

Initial Impression - Week 3

The course CSC148 promises to focus on how to deal with the real-world problems, how to deal with unexpected situations, and learning about abstract data types aka, ADT's.  The first three weeks have given me quite a learning experience about the new data types and how to go about with the manipulation of information provided.

There were many problems that I faced during these weeks as to how to go about understanding classes, understanding the new python compiler, 'PyCharm', and the introduction of inheritance.
I tackled most of my problems by asking the professor about the same after every lecture and even going to the office hours.

The course topics offered in the first few weeks really enhanced my knowledge base about programming in Python. Inheritance, especially was something I have already learned in C++ but its a totally different world in Python. There are different methods and different ways of inheriting classes, which is probably better than copying and pasting things. Also, creating and implementing the new data type introduced, Classes, was a thing which really made me more interested in carrying on with Computer Science as a subject.