Introduction to Data Structures and Algorithms
Output
- at least one quantity is produced -are the data items presented to the outside world as the result of the execution of a program based on the algorithm.
STEPWISE REFINEMENT
-The process by which a programmer refines an initial idea to a problem's solution into more specific terms. -The last phase of refinement results in a program ready to be coded for execution.
Data Types
-data that a variable can hold in a programming language -all programming language has a set of built-in data types
Analysis of Algorithms
-determining the amount of resources necessary to execute it such as time and storage -usually in terms of CPU time and memory requirements
Procedure
-essential tool in programming that generalizes the notion of an operator -can be used to encapsulate parts of an algorithm by localizing in one section of a program all the statements relevant to a certain aspect of a program.
Algorithms
-finite set of instructions that specify a sequence of operations to be carried out -recipe for solving a problem -all the tasks that can be carried out by a computer
Best-case analysis
-is used in to describe an algorithm's behavior under optimal conditions. For example, the best case for a simple linear search on a list occurs when the desired element is the first element of the list. - Less widely found
Worst-case analysis
-it is typically impossible to determine the exact worst-case scenario. Instead, a scenario is considered such that it is at least as bad as the worst case. For example, when analyzing an algorithm, it may be possible to find the longest possible path through the algorithm
data structure
-specialized format to store and organize data in a computer's memory or disk -collection of variables, possibly of several different data types connected in various ways
Abstract Data Types
-specification of a set of data and set of operations performed in a data -storage for data defined in terms of set of operations to be performed on the data
PSEUDOCODE
-textual presentation of a flowchart -close to a natural language -the control structures impose the logic -may become part of the program documentation could be translated into a program
Input
-zero or more quantities are externally supplied -are the data items presented to the algorithm. An algorithm has either no input or a predetermined number of them.
Input, Output, Definiteness, Finiteness, Effectiveness
Every algorithm must satisfy the following 5 criteria. An algorithm ought to produce at least one output.
algorithm
This is an Example of a simple ______. -Apply to wet hair -Massage gently -Leave on for a few moments -Rinse Off
Array, Linked list, Stacks, Trees, Hast tables
What are the 5 Types of Data Structures?
Finiteness
all instructions of an algorithm will terminate after a finite number of steps
Average-case analysis
analysis where all possible inputs and calculate computing time for all of the inputs. Sum all the calculated values and divide the sum by total number of inputs. We must know (or predict) distribution of cases
Definiteness
each instruction must be clear and unambiguous
Effectiveness
each operation must be definite, but must also be feasible
Raw data
is an input to a computer and an algorithm is used to transform this into a refined data