Wednesday 5 December 2012

Conclusion about the Course:

This course is a great one to take, if you really want to test your mathematical abilities.
As you Progress, material builds on itself, so if you fail to understand something in the past, you will fact difficulties in the future part of this course, for sure.
Its like a Binary Tree Going Downwards.  Root of The tree is Induction, and From There It starts to grow down.
Danny is a Great Professor, explains things really well and out TA Lila is also very good, Explains Tutorial Questions in a very organized manner.
This course taught me the most than any other course ever has. Thums Up! for CSC 236.
A Great Experience.

Mathematical Problem:

Problem: Find a DFSA which accepts strings with multiple of 3 0s, and odd number of 1s.
and also Find an Equivalent Regular Expression for that?

Solution:
This is the solution I came up with.
State Elimination part was quite big, so I posted the Final Form in the end for State Elimination and the Regular Expression.



Monday 3 December 2012

DFSA, NFSA and Equivalence to Regular Expressions.

DFSA stands for Deterministic Finite State Automata:
After Regular Expressions ---> Danny moved to this topic.
DFSA is basically a machine with different states inside it, some of the states are accepting and some of them are non-accepting states. A DFSA represents the language defined by regex. So, basically all the strings belonging to the language are supposed to end up in accepting states when given to DFSA, all other strings will end up in dead or non-accepting States.  Deterministic part of DFSA is what makes it distinct, because transition from one state to the other is purely determined by the Input and the current state.

NFSA :- Non -Determinsitic Finite State Automata.
if a DFSA exist for a regular Expression then a NFSA also exsists.
In NFSA State Transitions are non-deterministic, from one state we can have path to two different states for the same input. It is completely dependent on the machine which state it chooses to go to.
Same Way we can have epsilon transitions in NFSA.
The Idea of NFSA is difficult to grasp in he begining, but then as I worked through examples from course notes and Tutorials... the idea becomes clear... Eventually making NFSA is eaiser then DFSA.



Now, the Third paart of This Post...
For Every DFSA or NFSA there is an Regular Expression.

Assume that you have Implemented a DFSA...
You have the State Transition Diagram Let's Say with 3 states...

To find the equivalent regex.
We need to eliminate all the states between Initial state to accepting state.
Eliminating states can be delicate as you have to preserve the state transitions of eliminated state.

After State Elimination we will be left with two states, Initial and accpeting state,
From the resulting Diagram we can figure out the Regex.

This requires practice... Nothing is abstract about it!
Practice from course notes and online refrences from google is also a good option.

Sunday 2 December 2012

Regular Expressions:

Last Segment of the course covered Regular Expressions
Regular Expressions are concise notations to describe languages.
From Regular Expressions we can form Infinite strings with finite characters, those finite characters belong to a generic set, and we say that Regular Expression is defined over that set.

Languages based on Regular Expressions are Defined using Structural Induction.

The Topic of Regular Expressions is the most Interesting and easiest part of the course I have experienced.

The whole idea of regular expressions is so simple and neat.
The Practical application which we did in java for CSC207,
Regular Expressions are used to match strings of text, such as particular characters, words, or patterns of characters.

Tuesday 27 November 2012

Partial Correctness And Iterative Algorithms

To prove Correctness of Iterative Algorithms.
The Procedure is :
Assume Preconditions:
Derive and Prove a loop invariant (Partial Correctness)
Prove Termination
In the End Show that: Precondition + Partial Correctness + Termination implies Post-condition.

Loop Invariant is something which is True Before and End of Every loop Iteration.
We normally use induction to Prove Loop Invariant.

Termination: Loop Invariant helps us prove termination also,
To prove termination we need to come up with a sequence  which is decreasing and in the end meets termination condition, Then Use of Principle of Well Ordering to show that This sequence hits the least element of the set and loop breaks.

Based on what Algorithm does, we show that output meets Post - condition.

Danny's Power algorithm example helps a lot to get the idea of proving correctness of iterative Algorithms.

Monday 26 November 2012

Recursive Algorithm Correctness!

Next Milestone After Recurrences arrived was Proving Correctness of Algorithm...

Danny worked Through the Correctness of Binary Search Algorithm in class...
The Pre conditions of Binary Search algorithm were Straight forward, But post conditions were not, Normally Post conditions are supposed to be the desired output from the algorithm But the post conditions of Binary Search made sense on the output but were not obvious to the mind.

By doing examples from course notes The Idea Stick to the mind.
And then we realize that Recursive Algorithm correctness is far more easier, 

Assume the pre conditions Use Induction to prove Correctness leading to post conditions Fairy Simple.

Tuesday 6 November 2012

Recurrences

Recurrences:

Next topic came in the course, which includes finding Time Complexity of recursive algorithms.
where we define the exact number of steps for base cases and a recurrence relation in terms of T(n) based on the algorithm for arbitrary values of  n > b, where b is a natural number.

This looked fairly simple until we got into proving upper and lower bounds of Recursive binary search
and merge sort algorithm,   To get the idea of bound for a certain Algorithm we basically unwind the recurrence based on its definition.  Normally Recursive algorithms involve Divide and conquer technique to define a recurrence, where we Split the input in two or more halves. So, then after unwinding the recurrence, we end up getting a closed form our recurrence relation.
That closed form tells us the exact bound for our algorithm.

Then we set out to prove Big O and Big Omega that bound for our recursive Algorithm.
The Proof Of Big Omega for recursive Binary search is straight forward, 
But Big O is difficult if your trying to prove it all by yourselves, it involves one trick which is not obvious and cannot be thought of easily,   Even Great researchers came to know it through trial and error.

So, I looked in to course notes, Theory of computation book, Google searches you tube videos
to understand the Big O notation for recursive binary search


and talk about Big O and Big Omega for merge sort algorithm, which both involve similar kind of trick in opposite direction.