1 / 6

Pseudocode Guidelines for Writing Algorithms

Pseudocode Guidelines for Writing Algorithms. High-level description: Begin with an English description of how the algorithm works. Include a general overview of the approach and goals.

Download Presentation

Pseudocode Guidelines for Writing Algorithms

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. Pseudocode Guidelines for Writing Algorithms • High-level description: • Begin with an English description of how the algorithm works. • Include a general overview of the approach and goals. • You may want to include examples and diagrams of the data structures that help make the operation of the algorithm more clear. • For recursive algorithms it is often useful to clearly describe the base and inductive cases that make the algorithm correct. • About one or two paragraphs of text is usually enough.

  2. Language and Syntax • Follow basic C and/or C++ syntax. • Dynamically created structures should be allocated using "new" and deallocated using "delete". • Avoid the use of advanced C++ features like iterators, templates, class inheritance, etc. • Do not rely on pre-defined classes from the Weiss book unless that is part of the assignment (as it was in the case of hw #1).

  3. Functions and Operators • You may assume that you have at your disposal the basic operations of the data type you are manipulating. • Introduce definitions for the relational operators applied to non-numeric types. • For example: Define (F < G) for nodes F and G to hold iff (F.data < G.data) This should be done only to clarify, never to obscure, the presentation.

  4. Additional Tips • Include meaningful comments in the body of the pseudocode. • Try to make the program as succinct and elegant as you can. This is not only good style but usually makes the algorithm easier for others to understand. • Pseudocode should be typed (preferred) or VERY neatly handwritten.

  5. Lists and writing pseudocode • Given 2 sorted lists, L1 and L2, write a procedure to compute L1 U L2 (the union of the two lists). The resulting list should be sorted as well.

  6. Recursive Algorithms • Provide a recursive algorithm that given a binary tree determines the number of leaves in the tree.

More Related