Pseudocode and Algorithms Flashcards
queue
FIFO data structure: ordered collection of items added at the rear and removed from the front. sequence depends on order inserted, size depends on number inserted
array
a finite, ordered set of elements of the same type. grouped under one identifier, each element addressed using index
index
used to reference EACH element of an array
elementary data type
data type built into a programming language e.g. VB, pascal, python
tuple
dynamic data structure: ordered set of elements not necessarily of the same type able to inc/dec in size
structural data type
collection of data (made up of a number of elements) of a specified type e.g. array, string, record
primitive data type
data type PROVIDED by a programming language
n-dimensional array
a finite, ordered set of elements of a specified type indexed by n integers
abstract data type
a data type created by the programmer rather than defined by the programming language.
logical description of how data is viewed and operations that can be performed on it
programmer decides how to build and implement it and uses data types from programming language, user just needs to know state and behaviour
uses data abstraction: encapsulation, hiding details and implementation from user
encapsulation
ensuring a subroutine is completely self contained and independent of any global variables
dynamic data structure
data structure (a COLLECTION of data of a specified type in memory) with the ABILITY to grow and shrink in size in run time, with the aid of a heap
heap
portion of memory which is AUTOMATICALLY allocated and deallocated space as required (dynamic data structures)
adv of dynamic data structures and built in dynamic data structure
- good for implementing data structures when you don’t know max size in advance (can have arbitrary max to prevent overflow but not necessary to allocate memory beforehand)
- if built in dynamic data structure- many methods and functions e.g. pop already written and can be used in other data structures
- good use of memory: only takes up storage required
disadv of dynamic data structures
- can cause OVERFLOW if exceeds max memory limit
- needs memory to store pointers
- harder to program
- often time consuming to search
static data structure
data structure (collection of data of a specified type in memory) which is fixed in size at compile time so can’t inc in size or free up memory whilst the PROGRAM IS RUNNING
adv static data structure
- suitable for storing a fixed number of items e.g. months of year
- size is known so easier to program
- no need for memory wasted on pointers
disadv static data structure
- size decided in advance and no more items can be added if full, irrespective if free space in memory
- wastes storage if items stored is small relative to size of data structure
algorithm
a sequence of steps / set of rules SPECIFYING how to solve a problem, including inputs outputs and processing, written in a way it can easily be translated into high level code and then machine code for execution by the computer if in context of programming.
execute in finite time and produce an expected output for given inputs
a good algorithm
- DESIGNED in such a way that others can UNDERSTAND and MODIFY if necessary
- CLEAR, PRECISELY stated steps with correct OUTPUT for any valid input
- should allow for invalid inputs
- should execute efficiently with as few steps as possible
- should TERMINATE at some point
pseudocode
- halfway between a program, with its structural functions and english, with a solution expressed in a way that can be easily translated, and easily readable WITH NO CONCRETE SYNTAX
- helps develop and outline algorithms and understand the functioning
input and output pseudocode
print(“what is your name”)
myname= input()
OR
myname= input(“what is your name”)
integer
whole number
float/real
number with a fractional part
boolean
only takes values of true or false