1 / 8

Speed Programming

Some intro stuff. Speed Programming. Some Programming Hints. Write the Comments first Document your variables Use Symbolic Constants Don’t use enumerated types unless you really need to. Use subroutines as much as you can. If you are using debugging statements, make them meaningful.

tterrence
Télécharger la présentation

Speed Programming

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. Some intro stuff Speed Programming

  2. Some Programming Hints • Write the Comments first • Document your variables • Use Symbolic Constants • Don’t use enumerated types unless you really need to. • Use subroutines as much as you can. • If you are using debugging statements, make them meaningful. • Use the STL (strings, stacks, queues, etc..)

  3. Some general testing hints • Test the given input. • Test incorrect input (if necessary) • Test boundary conditions. • Check for “off-by-one” errors. • Test cases where you can compute the answer. • Test large cases (even if you do not know the answer; just in case). • Get to know your debugger.

  4. Some more general testing hints • Display data structures • Test all invariants. • Inspect your code. • Make your debugging print statements meaningful • If you use arrays, make them larger than necessary • Make sure your bugs are really bugs

  5. Character stuff • Check non-printable characters. • Letters and digits are sequential, all kinds of tricks. • Iteration • Conversion-upper to lower or viceversa • Conversion: chracter to rank • Newline and carriage return are a pain when converting between systems. • Unicode is another story.

  6. String representations • End marker • Array plus length • Linked list • Others? • Big effect on operations.

  7. Sorting Applications: • Uniqueness testing • Deleting duplicates • Event prioritizing • Median selection • Frequency coounting • Set operations • Finding target pairs • Efficient searching

  8. Sorting algorithms • Insertion • Selection • Bubble or exchange sort • Shell-sort (insertion with diminishing increment) • Heapsort • Quicksort • mergesort

More Related