Data Structures and Algorithms
implementation
-provides the internal representation of a data structure -also provides the definition of the algorithms used in the operations of the data structure
interface
-represents the set of operations that a data structure supports -only provides the list of supported operations, type of parameters they can accept and return type of these operations
characteristics of data structures
1) correctness 2) time complexity 3) space complexity
need for data structure
1) data search 2) processor speed 3) multiple requests
foundations of data structures
1) interface AND 2) implementation
kinds of algorithm analysis
1) priori analysis 2) posterior analysis
categories of algorithms
1) search 2) sort 3) insert 4) update 5) delete
Characteristics of an Algorithm
1) unambiguous 2) input 3) output 4) finiteness 5) feasibility 6) independent
execution time cases
1) worst case 2) average case 3) best case
umabigious
Algorithm should be clear and ________. Each of its steps (or phases), and their input/outputs should be clear and must lead to only one meaning.
finitieness
Algorithms must terminate after a ______ number of steps
input
An algorithm should have 0 or more well defined _____
output
An algorithm should have 1 or more well defined ______, and should match the desired _________
independent
An algorithm should have step-by-step directions which should be _________ of any programming code
data search
Consider an inventory of 1 million(106) items of a store. If application is to search an item. It has to search item in 1 million(106) items every time slowing down the search. As data grows, search will become slower
entity set
Entities of similar attributes form an ___
posterior analysis
This is empirical analysis of an algorithm. The selected algorithm is implemented using programming language. This is then executed on target computer machine. In this analysis, actual statistics like running time and space required, are collected.
average case
This is the scenario depicting the average execution time of an operation of a data structure. If a operation takes ƒ(n) time in execution then m operations will take mƒ(n) time.
best case
This is the scenario depicting the least possible execution time of an operation of a data structure. If a operation takes ƒ(n) time in execution then actual operation may take time as random number which would be maximum as ƒ(n).
worst case
This is the scenario where a particular data structure operation takes maximum time it can take. If a operation's worst case time is ƒ(n) then this operation will not take time more than ƒ(n) time where ƒ(n) represents function of n.
record
a collection of field values of a given entity
file
a collection of records of the entities in a given entity set
interface
a group of related methods with empty bodies
expression
a literal, a variable, or a sequence of operations on literals and/or variables that produces a value
identifier
a sequence of letters, digits, __, and $, the first of which is not a digit
primitive data type
a set of values and a set of operations on those values
field
a single elementary unit of information representing an attribute of an entity
processor speed
although being very high, falls limited if data grows to billion records
integers (int)
arithmetic operations
real numbers (double)
arithmetic operations
multiple requests
as thousands of users can search data simultaneously on a web server,even very fast server fails while searching the data
assignments
associate a data-type value (defined by an expression) with a variable
initializing declarations
combine a declaration with an assignment to initialize a variable at the same time it is declared
algorithm complexity
considers TIME and SPACE
declarations
create variables of a specified type and name them with identifiers
correctness
data structure implementation should implement its interface correctly
statements
define the computation by creating and manipulating variables, assigning data-type values to them, and controlling the flow of execution of such operations
priori analysis
his is theoretical analysis of an algorithm. Efficiency of algorithm is measured by assuming that all other factors e.g. processor speed, are constant and have no effect on implementation.
attribute and entity
is that which contains certain attributes or properties which may be assigned values
group items
item that are divided into sub items
elementary items
items that cannot be divided
space factor
measured by counting the maximum memory space required by the algorithm
time factor
measured by counting the number of key operations such as comparisons in sorting algorithm
space complexity
memory usage of a data structure operation should be as little as possible
operator
names a data-type operation
variable
names a data-type value
loops
provide for a more profound change in the flow of execution—execute the statements in a block as long as a given condition is true
conditionals
provide for a simple change in the flow of execution—execute the statements in one of two blocks
data item
refers to single unit of values
time complexity
running time or execution time of operations of data structure must be as small as possible
literal
source-code representation of a value
characters (char)
the alphanumeric characters and symbols that you type
booleans
the set of values { true, false } with logical operations
delete algorithm
to delete item in a datastructure
insert algorithm
to insert item in a datastructure
search algorithm
to search an item in a datastructure
sort algorithm
to sort items in certain order
data
values or set of values
continue statement
which immediately begins the next iteration of the loop
break statement
which immediately exits the loop
feasibility
Should be _________ with the available resources