1 / 19

CS 498 (242)

CS 498 (242). Lecture 3. Last Lecture. Made too many assumptions Was too broad Did not cover timing in enough detail to be useful Did not cover important parts of optimization in enough detail. Important Points. Optimization priorities: Improve the algorithm if you can

Download Presentation

CS 498 (242)

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. CS 498 (242) Lecture 3

  2. Last Lecture • Made too many assumptions • Was too broad • Did not cover timing in enough detail to be useful • Did not cover important parts of optimization in enough detail

  3. Important Points • Optimization priorities: • Improve the algorithm if you can • Concentrate your effort on the code that is executed most (it was obvious in last assignment) • Eliminate unnecessary instructions (things that don’t change from one iteration to next) • Order conditionals so those most likely to fail come first

  4. FSM • Example - Vending machine • Accepts nickels only • $0.15 dispense product

  5. Pseudo-code While machine on inputTotal = 0 While (inputTotal < PRODUCT_PRICE) inputTotal += AcceptCoin(coin) DispenseProduct

  6. AcceptCoin(coin) • Is it a nickel? • Yes – return(5) • RejectCoin(coin) • Return(0)

  7. AcceptCoin(coin) • Is it a nickel? • Yes – return(5) • Is it a dime? • Yes – return(10) • Is it a quarter? • Yes – return(25) • RejectCoin(coin) • Return(0)

  8. Outline Introduction I have a couple of points to make Topic 1 key point 1 first detail of my first point second detail of my first point second key point Conclusion

  9. Tree Data Structure • Root node (outline) • Children: • Introduction • Topic(s) • Conclusion

  10. Tree Data Structure • Topic(s) • Key point(s) • Detail(s)

  11. Tree Data Structure • Key point(s) • Detail(s)

  12. Example <outline> <outlinename>My Outline</outlinename> <introduction>I have a couple of points to make</introduction> <topic> <topicname>Topic 1</topicname> <keypoint> <keypointtitle>key point 1(/keypointtitle> <detail>first detail of my first point</detail> <detail>second detail of my first point</detail> </keypoint> <keypoint><keypointtitle>second key point</keypointtitle> </keypoint> </topic> </outline>

  13. How is this a tree?

  14. What are the nodes?

  15. What signals you to start a state?

  16. What signals you to start a state? • A tag • Example - <topic>

  17. What signals you to exit a state?

  18. What signals you to exit a state? • Matching end tag • Example - </topic>

  19. <topic> • Get next tag • Is it: • Topicname • Keypoint • </topic> We don’t worry if it’s a “<conclusion>” or anything else. Those are not valid inputs to transition states.

More Related