Algorithms Flashcards
Is there a difference between a Problem and an Algorithm?
Yes
Problem
description which associates inputs to output states
Problems include 2 things
precondition + postcondition
Does a problem statement itself indicate how to solve the problem?
No; just pre and post
Algorithm
describes a possible sequence of steps which when carried out solves a problem by meeting post conditions upon completion.
Do algorithms have to meet a problems’ post conditions upon completion?
yes
Function details can be hidden T or F?
True
Pseudocode
english-like representation of algorithm logic
and is independent of implementation language
in pseudocode, do we explicitly declare primitive data items? (eg. int number)
no.
Conventions for variable names:
- meaningful names
- no single-char names except for loops
- Do not use generic names : count sum row
- use descriptive names
- use abbreviations
Is this a valid Psuedocode variable name?
count
NO
Is this a valid Psuedocode variable name?
add
NO
Is this a valid Psuedocode variable name?
thisPointer
Yes
Is this a valid Psuedocode variable name?
a :: character
NO
Is this a valid Psuedocode variable name?
pow
NO