 All right, so we are looking at which problem The second one thing midterm CSE 340 fall 2015 midterm exam one This is problem one. So this is an actual problem from an actual midterm Assuming I don't die by trimming over these wires. We can go over this So we have a series of regular expressions We have letter is the letters lowercase m through p We have capital letters capital m through p digit five six seven or eight We have alpha which is either a letter or a digit followed by Zero or more digits followed by zero or more letters Row is a digit or a letter followed by a letter or digit zero or more letters or digits, right? This is going to start with either a lowercase letter or a digit and be followed by any number of uppercase letters or digits V I guess the name yes, okay I Write these things and I completely forget V is any number zero or more capital letters followed by a digit Omega is a digit followed by either a capital letter or a digit followed by any number zero or more lowercase letters Cool. So the first part about problem one is filling in the blanks of matching up What is exists inside one regular expression if? This string is in the language defined by each of these regular expressions alpha row, so you can Go do that. That should be a good self-check, but the question today is on Not where is my mic? Where is my? Marker, but that is a good side question Everybody see a marker We'll give it up for net So that's a highlighter that would be bad on here Go to red, okay Okay, so the question is if we call it get token repeatedly on this input, so he's specifically given this input Okay, so it says if we call get token repeatedly on this input until the end of input is reached The sequence of token returned is the following and tells us specifically assume longest prefix matching is used and ties are broken in favor of tokens that appear first in first first in the list Okay, so we have one thing we want to do before we start if we ever copy the input into somewhere else We want to make sure and verify. It's actually the same input It would suck to solve this problem on a different string and put the wrong values in here If you wonder why I tell you this it's because I've seen it It's really sad because they do it correct like I see the steps are all correct. It's on the wrong input So you have to knock off some points for that 58 mmp Okay, so how do we start? Well, you first use the first one and see which one matches and which one's possible candidate But how are we gonna figure this out? Yeah, so I first gonna start here right but I want to make my columns of my table, right? I want to think of okay. What's so what are my columns? What am I keeping track of? Match match Let me that takes long and that does test. I'm sure So let me rephrase your question But let me tell you what happens. There's four things that appear here the answer I think in this case is four of these alpha row Whatever So it's worth 12 points in this case. I think it was 20 points in the other exam So if you put down four wrong symbols Zero out of 20 or zero out of 12 I know one correct out of four you'll get a fourth of the points right But if you do this I can see where you made a mistake Because when you try to parse this if you make a mistake here and mess up on your first token That affects your next get token because it's going to change where you start from I Guess I'm actually I say I make a mistake on the first part But then all the rest I'm asked properly even though they technically weren't symbols Would you not look at the proper matching and I get points if you don't show me your work? No, I'm not looking at that. I'm not gonna redo your work to see how you messed up and actually ended up getting the Right answer because I can't see where you messed up Do it at the end if you have time if you write it down the answer right down the answer if you can't Show more work. We'll write down the answer first and go back and show your work later Cool. Okay, so we're going here. So we analyze this very first character five So which of these right your expressions matches do we have anything that matches so before we start right? So we have nothing that matches We have all as the potential match and we have nothing as the longest match Right so far Now you're one step and look just at this five So which what matches five? digit digit Alpha Alpha a match. Yeah matches like season zero or more zero or more. Yeah, so alpha Just row match Yes, digit right and that's a row What about No, yeah Does it match? Yeah, I can see you can make a letter to that's why I'm just here Yep, so that matches so what constitutes a match and a potential The matches is this string five just this Okay, so again so far is it in the language defined by this regular expression Okay, so if it matches the matches if it matches up exactly then that's what yes And Omega is Omega does this match Right the string five is not in the language defined by Omega, but strings that start with five Are in the language by Omega? Right, and so that's potential so then the potential does digit have the potential to match But yeah, this was a match to match it wasn't a potential Right, I'm saying now we're going to potential so we're going through all these does letter have the potential to match No capital letter just digit I guess Could it if you added another if you looked at the next character could digit match No, no, it's not because what's the length of the strings it is one one, so what you can always add it It's not gonna hurt it right because later you'll check digit You'll say clearly doesn't matter we know it can't possibly match if we look at another character because this is only strings of like one Okay, alpha Can alpha potentially match? Yeah Yeah, so we have this digit and depending on the next things are it could still match, right? So we have alpha What about row? Yeah Yeah, so we match this digit and we have any number of digits or letters Okay fee can fee have the potential to match No, no because we can't add if we add anything to this. This is saying the last thing is a digit Right, so there's no strings that start with five and are of length two or more Right, so not fee. What about camera? Yeah? Yeah Omega, right? Okay, and then what's the longest match we've seen so far Digit one. Why did you have all these first one to go exactly? It's the first one on the list So now we look at eight so then we say of the ones that last time potentially matched Alpha row omega which ones are those So it does alpha match five eight not much Oh, yeah, it does does match because I'm worth a little digit and digit, right? So alpha matches What about row? Yeah, yeah, digit also matches And what about omega? No, yeah, well, no, so it could be digit in the math And that's one digit Okay, I see I thought there was digit in the parentheses. Okay, now it's digit down. Yeah, then that is a match. Okay And then we go to potential so it does alpha have the potential patch Yeah, yeah, right. We can keep doing more digits and more letters, right? So alpha could have about row Yeah Yeah, more digits or more capital letters What about Omega? No, because after that after that yeah, I can't Well, hmm. Well actually yeah, because it could be a letter afterwards. Yeah digit digit and then any number of letters Omega, so now what's the longest match we've seen so far? To what alpha two So now back to your question, what do you write? What specifically is the question asking you to write for the answer of this problem? Look, it said we called the token respectfully and said that anything is reached because it was a token returned as a following Yeah, it doesn't actually say to the number. Is the fault, exactly. It says the sequence of tokens returned is the following Yeah, so I have to remember. No, but to the record, I still wasn't sure that I read it because I was like, okay The sequence of token returned is the following, right? Parentheses means you can eliminate that and just do that. This is the sequence of tokens returned Well, 5am Does it match in alpha? No Yeah, it should List in the language defined by alpha. Oh 5am. Yeah, these three right here. Yeah Well digit Digit than any number of letters though. That's capitalized letters. Oh, that's capital, okay. That's yeah, no in my case, no No, it does not match. What about row? Digit digit No, because this is lowercase letter. What about omega? Yeah Digit. You got the letter? It's my letter. Oh, that's okay. Yeah, okay. I'm thinking the second one's Omega. I feel confused Digit digit letter So Omega so Omega matches doesn't Omega have the potential to match Yeah, you got more marginal letters. Yeah, actually, we can also go through we should go through all these. Does this have the potential match alpha? No, no, no, what about row? No, can't do that. Omega? Yeah. Yeah. Yeah, we can keep doing Why can't you skip the five? Why am I skipping one? Yeah, so we've already only go through the potential so before that's why we calculate the potential So we don't have to go through all you can do it by just look at the potential and yeah, that's true Yep, so now my longest match is Omega with like three So do I stop is it Omega three? No, I still have potential right so this is where you can mess up you mess up and do Omega your first one's right, but now You can actually cheat ahead and see letter star. You're gonna go all the way here. Yeah, right? So if you mess up here now when you call get token again, you're gonna get different things Yeah, so it would just be MMP so I'm gonna keep going and it'll be MMP and I'll get to this capital P And I'll say does 5 8 mm lowercase be capital P does that exist in the language described by Omega Doesn't have the potential to match that no no So we would finally get to the point all the way here And then we'd say the longest match is Omega of like one two three four five Five Now I'll get token. I'm gonna start here. So right I'm starting here. I have no matches all potential longest match So I'd say P is a lowercase letter No, it's a number case. Yes. Is it a digit? Is it doesn't match alpha? Yeah, yeah Does it match row? No, does it match fee? Yes No, well, it's a couple letter Okay, that's what some so it's a potential Omega Okay, then we go through potential so Letter now capital letter Does that have the potential? No, no digit now alpha. Yeah. Yeah, we have digits and letters What about row under note fee? Yeah. Yes, this has the potential to match And Omega no So the longest so far we've seen is a letter of like one Right, and then I'm gonna go here to M and I'm gonna say does an M match alpha PM match alpha PM Wait, yeah And no, it won't be speak this alpha is his letter. Do you know you have one? Excellent and so the first character is what a letter? Yeah, he followed by what? But what is the digit? Oh, oh, that's right. Yeah, so he could match But this could go to this match M So we already match the P to this letter can this M match this digit? No, so this goes to epsilon, right? So then we say can this match that letter? Yeah. Yeah, yes so alpha alpha matches and Also has the potential to match and feed is fee match this PM. No No, but does that have a potential? Yeah, then we look at PM 5 and say does an alpha match that PM 5? No, no because we did letter This went to zero This now goes to letter and there's no digit afterwards, right? So PM 5 is not in there and it has no potential to match Fee is letter letter followed by a digit So We get here we get to fee and then we'd say fees the only one that could potentially match And then we'd say it doesn't have the potential to match Well, no, we've reached the end. Yeah, it has no potential So we know that this is fee of five and now we do it an MP 5 and So we look at M We say M is lighter lowercase letter of length one We look at P and we would see that can this be lowercase letter? No No count start with lowercase letter. Can this start with the lowercase letter? Yeah Yes, so MP though. Can the next one be? No lowercase P. No, what about fee? No, and what about omega? No No, so we went through all of them done match MP's and what should be returned? The M should be letter one. Can we get to P5? Is that lowercase or capital P? Lowercase P. Got you What was that? Lowercase P So we look at the first one. We know it's a letter out of all of these and we look at P5 P5 is P5 and alpha No, it can't be Is it a row? Yeah P and then a digit. Yes, it's a row. Is it gamma? No Or sorry a fee. No, is it omega? No, no So it's a row Good question on this