Wednesday, 21 November 2012

The Importance of States (or, How I Screwed Up Quiz #6)

Blah, blah, blah, self-depricating introduction, woe is me, I don't understand, joke, etc. etc. etc. Now that the formal introduction is over, it's time for a confession:

Although I have a limited (although increasing) understanding, I'm doing alright. I'm not sure why. I feel like I'm not doing well, which leads to the tone of these slog posts, but I actually am. Somehow. I actually got over 100% on Test 2. Guess "let the answer be z" strategy worked out. Well, that and the mark adjustment. I'm not one of those people that keeps track of what their grades are, because I honestly don't too much care as long as I feel like I'm understanding content, so I can't really estimate what my final mark is going to be, but it's going to be alright. Much higher than I deserve as of right now.

That said, I'm consistently doing poorly on tutorial quizzes. Instead of blaming myself for not studying for them, I'm going to blame that they're on Monday. No but seriously, I always say I'll study later, and spend the weekend doing coursework for other courses. Then I don't get to studying CSC236. Then I go into the tutorial armed with only what I remember from lecture, and it rarely goes well. I think the last time I got full marks was in week 3 or something. If anything is bringing down my mark, it's this. But I felt good for quiz #6. Although I had most certainly still not studied for it, I was feeling good about the material, and seeing the tutorial problems taken up on the board, I followed along perfectly. I was delighted to see the quiz question be on drawing a machine. It seemed easy enough.

As I recall, the question was "Draw a machine that accepts binary strings with an even number of 1s and an odd length". I got ready to draw. And then I failed. Sure, I could draw a machine to accept binary strings with an even number of 1s. No problem. I could draw one to accept binary strings with an odd length. Both are pretty damn easy to do. But something about combining them... I just couldn't do it. I felt like what I felt like trying to do a STA247 program in R on the weekend (the reason I didn't study for this quiz) - wishing I had the ability to store data in some kind of static object. A bizarre thought for writing on paper, I agree. But I was trying to mash two machines together, and keeping track of information from a toggle between even and odd length, while also toggling even and odd 1s proved difficult.  As everyone else got up to leave, I kept working and working and ended up with a bizarre diagram that worked for any binary string starting with 1. Never did get it to work with the other half of all binary strings. I wish I could replicate it now, because try as I might, I can't re-create this horrifically wrong solution. I wanted to recreate it just for this slog entry, but I can't remember what nonsense I pulled. Now, having figured out the correct answer, I can't un-see the correct answer. I can't put myself back in the mindset of ridiculous, over-complicated solutions. I'll upload a photo of this embarrassment when I get my quiz back.

Today, I sat down to do it. Granted, I'd already seen the correct form in lecture, but I hadn't really grasped it entirely, and I didn't want to spoil it, so I didn't look at any lecture slides or anything. The answer just came to me. Maybe the lecture did trigger the answer from me. Maybe it had nothing to do with it. All I know is I came out of having solved the problem understanding both the tutorial problem, and today's lecture a lot more.

The key? It's all about the states. Where did I go wrong on Quiz #6? States. That's where. States are my static object storage I was looking for while writing the solution. It had been right in front of me the whole time, and I never saw it.



I didn't quite understand this in lecture either. I felt like the machine we settled on was more like a summary of the other two machines. But I now realize that it's actually it's own thing. The machine's states don't refer to the position in other machines like I had thought, but in fact, refer to what properties the string has. You know, like what a state should be. Here I've used notation XY for each state, where X and Y are either E or O, E indicating "even" and O indicating "odd". X refers to the number of 1s, and Y refers to the length of the string. And once that's defined, it's nothing to finish the machine. Reading a 1 takes you from EE to OO, adding a zero from there takes you to OE, and so on and so forth. It just makes sense, and all because I properly defined my states instead of leaving them with generic names "a1", "a2", .... , "an".

If only I had realized the importance of states. Or had realized that I should have been making a new machine that handled both pieces of information simultaneously instead of trying to literally mash two machines together, keeping track of both pieces of information separately, but still within the same machine. Hindsight huh?


1 comment:

  1. Yeah, states are the only memory you've got.

    That said, I think the quizzes took at least two unfair bounces for the morning section (there was also the mathematical induction/complete induction one), so I'll be looking how the two sections stack up.

    ReplyDelete