This is the last week of class. Then we are going to review at home and be ready for the final exam!
CSC236 exam is on Dec.12nd.
To do list before final:
1. Review every lecture notes.
2. Do all the tutorial questions again.
3. Review each quiz and assignment.
4. Do the past exams.
5. Read textbook if there are questions.
6. Go to office hour if needed.
BE READY AND CHEER UP!
2012年12月4日星期二
2012年12月3日星期一
Tutorial 8
One question on the tutorial I found very interesting -- the second question on tutorial 8.
It asked to devise a DFSA that accepts the language of strings over {0,1}, with an odd number of 1s and and even number of 0s. From the DFSA, devise the regular expression that denotes the same language.
So first of all, devise a DFSA that has four states. i.e. keep every states and find the relationship between.
Then remove one state at a time and modify all the states that have a relationship with this removed state.
Remove states until there are only two states left: the beginning state and the accepting state.
Finally, use a singe letter to represent a string and write out the regular expression.
This is how I did this problem.
A binary can have an even number of 1s and even number of 0s (EE), or an even number of 1s and an odd number of 0s (EO), or an odd number of 1s and an even number of 0s (OE), or an odd number of 1s and an odd number of 0s (OO). So there are four states : q1, q2, q3,q4 repectively.
The beginning state should an empty string. In this case, there should be no 0s or 1s in this string, so the number of 1s and 0s are both even (there is zero 0 and zero 1). This is in the first state.
The accepting state should by a string that has an odd number of 1s and an even number of 0s. i.e. the third state.
There are two choices to add to the first state: 1 or 0.
If add a 0 to the beginning state, there will be one 0 and zero 1, so there will be an even number of 1s and an odd number of 0s. This is in the second state.
If add a 1 to the beginning state, there will be one 1s and zero 0s, so there will be an odd number of 1s and an even number of 0s. This is in the third state.
Similarly, there are two choices to add to the second state.
The second state has an even number of 1 and an odd number of 0, so if add a 0 to the second state, there will be an even number of 1s and an even number of 0s. This goes back to the first state.
If add a 1 to the second state, there will be an odd number of 1s and an odd number of 0s. This is in the fourth state.
Then let's talk about the third state.
The third state has an odd number of 1s and an even number of 0s. If add a 0 to the third state, there will be an odd number of 1s and an odd number of 0s. This goes to the fourth state.
If add a 1 to the third state, there will be an even number of 1s and even number of 0s. This will go back to the first state.
Same to the fourth state.
The fourth state has an odd number of 1s and an odd number of 0s. If add a 0 to the fourth state, there will be an odd number of 1s and even number of 0s. This goes to the third state.
If add a 1 to the fourth state, there will be an even number of 1s and an odd number of 0s. This goes to the second state.
Once the string goes back to the first state, whatever the next string is 1 or 0, it always going to loop in between these four states.
The graph is as below:
It asked to devise a DFSA that accepts the language of strings over {0,1}, with an odd number of 1s and and even number of 0s. From the DFSA, devise the regular expression that denotes the same language.
So first of all, devise a DFSA that has four states. i.e. keep every states and find the relationship between.
Then remove one state at a time and modify all the states that have a relationship with this removed state.
Remove states until there are only two states left: the beginning state and the accepting state.
Finally, use a singe letter to represent a string and write out the regular expression.
This is how I did this problem.
A binary can have an even number of 1s and even number of 0s (EE), or an even number of 1s and an odd number of 0s (EO), or an odd number of 1s and an even number of 0s (OE), or an odd number of 1s and an odd number of 0s (OO). So there are four states : q1, q2, q3,q4 repectively.
The beginning state should an empty string. In this case, there should be no 0s or 1s in this string, so the number of 1s and 0s are both even (there is zero 0 and zero 1). This is in the first state.
The accepting state should by a string that has an odd number of 1s and an even number of 0s. i.e. the third state.
There are two choices to add to the first state: 1 or 0.
If add a 0 to the beginning state, there will be one 0 and zero 1, so there will be an even number of 1s and an odd number of 0s. This is in the second state.
If add a 1 to the beginning state, there will be one 1s and zero 0s, so there will be an odd number of 1s and an even number of 0s. This is in the third state.
Similarly, there are two choices to add to the second state.
The second state has an even number of 1 and an odd number of 0, so if add a 0 to the second state, there will be an even number of 1s and an even number of 0s. This goes back to the first state.
If add a 1 to the second state, there will be an odd number of 1s and an odd number of 0s. This is in the fourth state.
Then let's talk about the third state.
The third state has an odd number of 1s and an even number of 0s. If add a 0 to the third state, there will be an odd number of 1s and an odd number of 0s. This goes to the fourth state.
If add a 1 to the third state, there will be an even number of 1s and even number of 0s. This will go back to the first state.
Same to the fourth state.
The fourth state has an odd number of 1s and an odd number of 0s. If add a 0 to the fourth state, there will be an odd number of 1s and even number of 0s. This goes to the third state.
If add a 1 to the fourth state, there will be an even number of 1s and an odd number of 0s. This goes to the second state.
Once the string goes back to the first state, whatever the next string is 1 or 0, it always going to loop in between these four states.
The graph is as below:

First remove the fourth state of the device. i.e. remove OO state.
So we can get from EO to OE by adding a 10 and get from OE to EO by adding a 01.
Adding 11 to EO, we are still in state EO and adding 00, we are still in state OE.
Similarly, we can remove one more state, EO.
Then we represent each string by a unique letter: R represents 0(11)*0, P represents 1 + 0(11)*10, Q represents 00 + 01(11)*10 and T represents 1 + 01(11)*10.
There are two ways to get from state EE to state OE : go from EE to OE or first go from EE to OE, then from OE to EE and then back to OE. So the regular expression for this device is
R*P(Q + TR*P)*.
2012年11月24日星期六
Regex
It is in week 11 now! Almost finish this course!
Now we are learning Regex and NFSA and DFSA. The last assignment is coming and it is about time comlexity and FSAs.
Most of the lecture material was not difficult to understand, but I was kind of confused by the difference between DFSA and NFSA. What I did this time was to look up definitions on the textbook. On the textbook, it said:
A deterministic finite state automaton (DFSA) is a mathematical model of a machine which, given any string input x, accepts or rejects x. The automaton has a finite set of states. including a designated initial state and a designated set of accepting states. While the definition of NFSA was that: In a DFSA, a given state and current input symbol uniquely determine the next state of the automaton.
To my understanding, the difference is that: in DFSA, the state only depends on the input, but in NFSA, the state depends on both the current input and also the given state.
BTW, I like drawing NFSA or DFSA, it was much more interesting than just to prove something using Induction or prove the correctness of a funciton.
Now we are learning Regex and NFSA and DFSA. The last assignment is coming and it is about time comlexity and FSAs.
Most of the lecture material was not difficult to understand, but I was kind of confused by the difference between DFSA and NFSA. What I did this time was to look up definitions on the textbook. On the textbook, it said:
A deterministic finite state automaton (DFSA) is a mathematical model of a machine which, given any string input x, accepts or rejects x. The automaton has a finite set of states. including a designated initial state and a designated set of accepting states. While the definition of NFSA was that: In a DFSA, a given state and current input symbol uniquely determine the next state of the automaton.
To my understanding, the difference is that: in DFSA, the state only depends on the input, but in NFSA, the state depends on both the current input and also the given state.
BTW, I like drawing NFSA or DFSA, it was much more interesting than just to prove something using Induction or prove the correctness of a funciton.
2012年11月10日星期六
Midterm 2
Just finished my midterm two!
It was Ok~ I was so busy this week so I did not have lots of time prepare for it. But I think it will be fine since I did not have questions remained from the lectures before.
I got 100% on my assignment one! I am sooooooooo happy!!!!
Hope my assignment two will be still good!
It was Ok~ I was so busy this week so I did not have lots of time prepare for it. But I think it will be fine since I did not have questions remained from the lectures before.
I got 100% on my assignment one! I am sooooooooo happy!!!!
Hope my assignment two will be still good!
2012年11月3日星期六
Assignment 2
I just submitted the second assignment. In general, I found the second assignment was harder than the first one.
There were two questions in this assignment. Sounds not much, but each question was very long. The first question asked us to unwind first and then prove the closed form. It was very much like a question that was in one of the tutorial. So what I did was to review the tutorial question first and then try to do the question myself. The unwinding was not very complicated for me and since I was pretty clear with Simple Induction and Complete Induction, I solved the first question without too much difficulties.
The second question was about what we learnt in the last week -- time conplexity. I was so glad that I solved all questions that I didn't understand last week so now I was very clear about what steps should I do. If I did not fix my problem last week, I would be confused about how to do this question and it was going to take me a lot of time if I googled online or read through all the pages on the textbook. So, Never Put Off Until Tomorrow What You Can Do Today. ^_^
This week we mainly learnt about proving the correctness of a function.
To prove the correctness of a function. We need to prove that under the assumption that precondition holds, the function terminates and the post condition holds. To prove the function terminates, we have to construct a decreasing sequence in N and then use well-ordering principle to prove that there is a smallest value in N so that the loop will finally terminate.
The second midterm is in next week. I need to read through the text book as much as I can and clear all my questions before the test. Oh~ and do not make the same mistakes again as in Midterm test one. Cheer up and be ready! ^_^
2012年11月1日星期四
Midterm Paper Back
Got my midterm back! But I was not so happy with my grade.
The questions were not so hard. I lost marks mostly for the structure and the induction hypotheses. I think I am going to professor's office hour and ask for suggestions. Hope I won't make the same kind of mistake in the second midterm test.
Looking forward to get my assignment one back!
2012年10月27日星期六
Master Theorem
In week 7 we learnt about Master Theorem.
I found Master Theorem was very interesting and it was an easier way to find the upper and lower bound. But one problem (at least it was a problem for me) was that I had to remember the three different cases. I liked to use method in week 6 better than this because I did not like to cram something without knowing how to get the conclusion.
Have a nice week!
2012年10月20日星期六
Time Complexity
Now it is in week 6, half of the fall semester! Wow, time is so fast!
Course topic now is about Time Complexity. This is very similar to what I learnt in CSC165. But since I did not understand time complexity well in CSC165, I listened to the lecture carefully and will go to office hour to ask any questions that pops up in my mind.
We are learning complexity of recursive functions. Unwinding is a mostly used way to find the lower and upper bounds of a function. This is a different approach from how find the lower bound in CSC165. First, develop a special case and then apply for more general case, for example, first suppose n to be the power of 2 and then apply n to arbitrary numbers.
But there was one thing that I did not understand in class this week. Professor drew a picture to prove that a function was non-decreasing. I did not understand how this picture related to the decreasing of a function. So I went to the section on Thursday night. After the lecture, I asked professor Heap what did this graph mean. The professor explained patiently that since at first we supposed n to a power of 2 and this was not a general case, we wanted a more general case to apply to the unwinding. To apply the unwinding to a general case, we used the upper and lower bound of log(n) to get an arbitrary number. First prove T was not decreasing and then used the relationship between n and n nod and the unwinding to develop an inequality that contained T(n) on one side of the unequal sign and n on the other side. In this way, we could find out both the upper bound and lower bound of a function.
After professor's Heap's explanation, I found I got a better understanding of how to develop the upper and lower bound for a function. Asking questions to professor helps a lot. He can always explain things well and he is very patient. ^_^
Course topic now is about Time Complexity. This is very similar to what I learnt in CSC165. But since I did not understand time complexity well in CSC165, I listened to the lecture carefully and will go to office hour to ask any questions that pops up in my mind.
We are learning complexity of recursive functions. Unwinding is a mostly used way to find the lower and upper bounds of a function. This is a different approach from how find the lower bound in CSC165. First, develop a special case and then apply for more general case, for example, first suppose n to be the power of 2 and then apply n to arbitrary numbers.
But there was one thing that I did not understand in class this week. Professor drew a picture to prove that a function was non-decreasing. I did not understand how this picture related to the decreasing of a function. So I went to the section on Thursday night. After the lecture, I asked professor Heap what did this graph mean. The professor explained patiently that since at first we supposed n to a power of 2 and this was not a general case, we wanted a more general case to apply to the unwinding. To apply the unwinding to a general case, we used the upper and lower bound of log(n) to get an arbitrary number. First prove T was not decreasing and then used the relationship between n and n nod and the unwinding to develop an inequality that contained T(n) on one side of the unequal sign and n on the other side. In this way, we could find out both the upper bound and lower bound of a function.
After professor's Heap's explanation, I found I got a better understanding of how to develop the upper and lower bound for a function. Asking questions to professor helps a lot. He can always explain things well and he is very patient. ^_^
2012年10月14日星期日
Feel much better for Structual and Well-ordering Induction
The midterm test made me feel I need more understanding in Structural and Well-ordering Induction.
I googled on line but could not find much useful explanation. But luckily I remembered we have a discussion board. I went to the discussion board and found with no surprise that I was not the only one who did not understand Structural and Well-ordering Induction well. In the specific tag, somebody provided a pdf that explain Structural and Well-ordering Induction. I opened the file and as I read through, I found this file very helpful. It solved my problems that when should I use Well-ordering Induction and also explain the difference between Structual induction and Simple Induction. To my undertstanding, Structural Induction could use Simple Induction as an approach to prove things. If we want to prove something that has a specific structure, we could use Structural Induction.
Well-ordering Induction is more likely to use during a provement. It does not like Simple Induction or Complete Induction that have a certain format, it is used as a part of the provement. I remembered professor Heap said it is more often used in the material we are going to learn in a few weeks.
I googled on line but could not find much useful explanation. But luckily I remembered we have a discussion board. I went to the discussion board and found with no surprise that I was not the only one who did not understand Structural and Well-ordering Induction well. In the specific tag, somebody provided a pdf that explain Structural and Well-ordering Induction. I opened the file and as I read through, I found this file very helpful. It solved my problems that when should I use Well-ordering Induction and also explain the difference between Structual induction and Simple Induction. To my undertstanding, Structural Induction could use Simple Induction as an approach to prove things. If we want to prove something that has a specific structure, we could use Structural Induction.
Well-ordering Induction is more likely to use during a provement. It does not like Simple Induction or Complete Induction that have a certain format, it is used as a part of the provement. I remembered professor Heap said it is more often used in the material we are going to learn in a few weeks.
2012年10月10日星期三
First English Bolg
Let's talk about something else apart from study ^_^
First English blog! Wow~ very interesting!
I am very happy to share my CSC236 learning experience
with everyone here. I wrote blogs before but it was not in English ( it was in
my native language haha~), so actually this is my first English blog and it
sounds like a challenge to me! I will keep wrting up things so that we can exchange
our learning experience here~
I finally finished my first CSC236 term test
this Wednesday. How does everybody feel? I think it was not very hard but I
think I need to go over more about structual induction, since it is very like
simple induction and I was a little bit mixed. I think I am ok with simple and
complete induction but I need to work more on well-ordering. I can understand
the principle but I don't know how to use it to solve problems. What I plan to
do is to read the course textbook and google is always there to help~
Hope I
can get a better understanding soon~
Hope everyone has a nice sleep.
2012年10月6日星期六
Midterm 1 is coming!
Up to now, we have learnt Simple Induction, Complete Induction, Structural Induction and Well-ordering Induction.
Simple Induction and Complete Induction was not so hard for me, actually I found they were easy to understand. But Structual Induction and Well-ordering were not so clear to me. I could understand the class material but I was confused about the application. When and where should I use Structural or Well-ordering Induction?
The first midterm test is coming and I was a little bit nervous since it is the first test in this course. I didn't do well in CSC165 so I was alway careful and tried to understand all the course notes in CSC236 and hope to get a better grade. I think I am going to read through the textbook and try to make every point clearer.
Simple Induction and Complete Induction was not so hard for me, actually I found they were easy to understand. But Structual Induction and Well-ordering were not so clear to me. I could understand the class material but I was confused about the application. When and where should I use Structural or Well-ordering Induction?
The first midterm test is coming and I was a little bit nervous since it is the first test in this course. I didn't do well in CSC165 so I was alway careful and tried to understand all the course notes in CSC236 and hope to get a better grade. I think I am going to read through the textbook and try to make every point clearer.
2012年9月29日星期六
Assigment 1 Office Hour
So as I said, I went to professor Heap's office hour for the assignment.
There were five or six people waiting in the line. I was hoping they were all coming for this assignment because this way I could hear more about the assignment. ^_^
So when it was my turn, I talked to professor Heap about my question. He thought for a few second and told me my problem was that if I did it in my way then I was not proving what supposed to be proved in the question. I was proving the other way around. I was confused at first, because I thought my logic was correct, but after professor Heap explained to me once and once again, I suddenly realized where did I go wrong. It was to prove "any binary string that begins and ends with the same bit has an even number of occurrences of substrings from {01; 10}" but what I did was to make a provement for "any binary string that has an even number of occurrences of substrings from {01; 10} begins and ends with the same bit." My induction hypothesis made my conclusion go to the other way around and this was why I felt my induction step was wierd but could not tell how.
After I solved my question, I stayed in professor Heap's office and listened to other students' comments or questions. I liked this atmosphere. It made me feel like I had a wide range of knowledge, like our professor, ^_^ and I felt confident to talk in a group. I also liked to learn with people and listen to their questions becasue everyone may have different idea and thoughts and we can always make a supplement to each other. It helps everyone to progress on study.
There were five or six people waiting in the line. I was hoping they were all coming for this assignment because this way I could hear more about the assignment. ^_^
So when it was my turn, I talked to professor Heap about my question. He thought for a few second and told me my problem was that if I did it in my way then I was not proving what supposed to be proved in the question. I was proving the other way around. I was confused at first, because I thought my logic was correct, but after professor Heap explained to me once and once again, I suddenly realized where did I go wrong. It was to prove "any binary string that begins and ends with the same bit has an even number of occurrences of substrings from {01; 10}" but what I did was to make a provement for "any binary string that has an even number of occurrences of substrings from {01; 10} begins and ends with the same bit." My induction hypothesis made my conclusion go to the other way around and this was why I felt my induction step was wierd but could not tell how.
After I solved my question, I stayed in professor Heap's office and listened to other students' comments or questions. I liked this atmosphere. It made me feel like I had a wide range of knowledge, like our professor, ^_^ and I felt confident to talk in a group. I also liked to learn with people and listen to their questions becasue everyone may have different idea and thoughts and we can always make a supplement to each other. It helps everyone to progress on study.
2012年9月22日星期六
Assignment 1
The first assignment is about Induction.
We learnt Simple Induction and Complete Induction in the first two weeks. I thought this assignment aimed to let us practise how to use induction to prove things.
I started to prepare for this assignment today, read relevant contents on the textbook and did a summary of the course notes. Then I thought I was ready enough for this assignment. I read the assignemnt sheet and found it was not so hard although there were lots of things needed to be considered, for example, Simple and Complete, which was better to use for each question? What was the base case if I used Simple Induction and what was the case that cannot be included in the general case if I used Complete Induction?
As what I always did, my plan was to first write up the answers and then discuss with professor Heap. When I was writing the assignment, I found my approach to do question four was a little bit wierd. I didn't know where did I do wrong but I had the feeling that I missed something important in my induction. So I was going to bring my questing to the office hour and hope I could get some feedback.
We learnt Simple Induction and Complete Induction in the first two weeks. I thought this assignment aimed to let us practise how to use induction to prove things.
I started to prepare for this assignment today, read relevant contents on the textbook and did a summary of the course notes. Then I thought I was ready enough for this assignment. I read the assignemnt sheet and found it was not so hard although there were lots of things needed to be considered, for example, Simple and Complete, which was better to use for each question? What was the base case if I used Simple Induction and what was the case that cannot be included in the general case if I used Complete Induction?
As what I always did, my plan was to first write up the answers and then discuss with professor Heap. When I was writing the assignment, I found my approach to do question four was a little bit wierd. I didn't know where did I do wrong but I had the feeling that I missed something important in my induction. So I was going to bring my questing to the office hour and hope I could get some feedback.
订阅:
博文 (Atom)

