




Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
This page cannot be seen from the preview
Don't miss anything!





behavior thecomplexity and
Find largest Max value in
Algorith with run time +(a)=nlogh requires A =
1024
x
= 10, time spent
Worst case
Linear search Time Complexity
of operation
are
Total time complexity =
of
1024
to
for a
given array. Problem size quadratic
Algorithm running time time = < Input S12e if n = 1024 Then max of
= Max
operations When n = 1020 Is 1024 x 102d= 1048, -> number of the algorithm A
I
a
of operations of the problem silent Algorithm
109 function second best
Big-OH Notation Big-OH
bound) is Big- if: TIN = OfIN) ***U rules if there are
constants rule
c and no such that TIN) =CfIN) if
= 0 HIN)and
(n)),then N When Ino
T,
(N) + T2IN) =
max f (N), 9 (n7) oldis owes ologn) Big -oh: State a claim
the
greatest amount of resources (TiMe) (b) T,INT2IN)=0DfI 9(47) I
(max
is required by
⑧
a polunomial of degree
TIN
= 106N =
OINO if TheN TIN = 0/NY
VUIe # TIN)=
10925 N
If
3(logr)" + IN+3N +6N In ever case:
=
i9vaDeOrted.
Arom rule
if
↓
running time never more than
A
= [2,5, 7, 9, 11,
running time of the test
Insert
worst case all
need to be shifted one
right
case) &M run time
size by
(which is usually 1/
is pre-read (sorted
Binary search is
the Index 1Such that Alex or input
liz0;injitt)
solution binary search: a [i] = 0 go left
it x A [mid Erepent for (p=0;)
case: OID Found
run time: Olcoqu).
operation in sorted array: &liogn) worstcase all other operations ON) time. **
List interface in
Util
data minerations it again obtain is interinarianiserimridities rantar initivar &es Sinsertion
It disadvantage of linked list
ADT · removing of existing
not easily indexable, get expensive. List: Linear sequence of
#'s is expensive.
size of
-> quere
operations. not
-Pandap "*8@Eron T Deavere ~St
t quare ADT:Ol F1r5+-1H-FIUS-OUt · make empty · find-returns position -> O(N) Worst case
· Insert and remove
↓ endaveve: Insert at lend ⑭ · Find Kth
ertionand deletions occur overt event dedueve:
most recent inserted element Important
**
Better.
I
->
↑ WarevatgesAndotrran I
FindKth -> No longer as efficient as an array
⑧ 17 time and works
traversing
the list
ere
Special
AList, stacks, averes ↑ Add to Front remove First:
a link to #Out is kept Add to end: O(l) it link to last node kept
of arere
#on ICTs in back removing last item:
An
position
represent end
queue ↑ ↑Beagining number of elements in
currentsize.
ADT
-> ISTO:
& time complexity operations: push-insert (on+op)
recently deleted. access:
0 (n)
(n) 2 NATION
I InSerTIOn: 0(
implantation of
Delete:
0( push:
at the Fort &
element
at the Font A
< Peek (TOp):
at the Front, retuns It value.
2 h of stack Array list implementation
stalk:
Notes post Fix expression:
of stack -- for empty stacks · the time to evaluate Is
processing
push some element into
onto stack: we increment topstalls and set
in the input
of stalk operations The Array Stop
= x pop-we return the
stop
the
topstack and
time
push are preformed In very
constant time. · If expression is given in
Fix
them
no need to know any precedence rule;
is an Disadvantage
PriOrHU Implementation
&
complexity
that
allows
The ·
dreve
In
list (unsorted)
following
two
operations: ·Sert
IS 01)
· Insert (add
0D)
·
deletMin,
which Finds,
I
· priority
linked
removes
element
in
is
GrnhaveOAFLFonda
restructure
that
I
·
priority
Binary
sear on tree
case)
Ollogn)
(average
case)
·
a
"profity"
ex. Min
greatest
priority ↓
norityare
rededth
percolate
down
Theorem: A heap
storing
&
mentat
IOn
~
queves
neight
ollogn)
Implementation
priority
deve
try
heap
mi
hedp:
T
run
time
of
deletemin is
Oliogn)
Structure property:
ree
that
possible
priority operations
D
level,
which
right Implementations
(min
heap
property:
The
of
non-root
percolate
important
priority
of Its parents
keep
comparing
phority
of stem
t
· If
priority
is less than, swap
with
the most important
go
&
a
keys
of
child
↑
·
are
important
than
or
were
reached a
Insert/ddd:
strategy
torso
inept
Noir
re
a
to
the
tree
treate
a
in
the
since
the tree
will
· Focus
on restoring
the heap
properity.
Not
search tree
on
Formiasareas
is a
te
Basically
a
priority
is a grere
priorities
things
in orderbased on data
given
if
ex
eX.
④
key
of
key
oDierIs e [11output
·Go
swap
OOGOOLOOOOO
therefore y
< & On problem
TaDle
supports only a subset of operation
by binary search
tree. nash
not operations like max and min are
AED Ewen two key map to the same location in the Hashing: Insertions,
and search. In constant time.
resolution: seprate chaining · assume that all
are the first 10
2
and the hash function:
hash(x)=xmod
The Ideal hash
data structure is merely an array
of some
size, coulding
⑭ main a ndeasseparate chang the
tape
table: LE advantage/disavantage Index=
(ke
problem: "The collision problem Disadvantage: parts of the table array might never be used. key Med tables -> nonemannermania is immediationar
erationS Increases to 0) worst case
key
are integers, Hash Function:
good Idea to make table she prime* 2 dressing
empty space in
Important
Points: All Items are stored in
&Chaining. The load
·each sell keeps
one of these three states: EMptY, · While (MS**, If
alternative
cells are tred Until empty is found.
I internationanometripinnainai ·
(Lazn): Key
-> S10+ Marked
Deleted ↑
sequence: sequence
of
maxes that probing
in search for an
cell during insertion, · IS a COlIISION
or seaching for
during
operations. Method that
primary age/advantage ↓
by changing the prode unsuccessful search:
hodes to exam is
on are open adress function:
tablesize successful search:
to exam is 712 0 rg.
Advantage: All items
probe sequence: has its self. No other structure
(n (13ey)
%. Tables12e nashing Find a position:
= Ke . tablesize
Disadvantage: The
of the
(n) ken)
Table ske probe sequence: (olkey)
must
be distint · Dependent on choosing a
table size Inciien)+i=).
1v(key)
(2*U)
table size requires the use of three stage (OEMpt,
Important
good news 10
+i* U lkey)
occupied, pefeted ( . earate Probing better enter it how thatthIS (are dress ↓ primary Clustering
= KCUYP. eVIIseU) -9-lsey. He Linear probing
·
Ographs · A graph (hE
CONSIStOf
a Set Of *gical sort ·topological sorting is not vertices, and a set of edges A topological sort of a
possible if the
has a · each edge is a pair (v,w), wherev,wEV.If graph
is a linear ordering of its vertices
since
vertices the pair
graph
is directed. such that for
directed edge
in E,
hand won the cucie, v precede
graph
are sometime refered to as diagraph ↓ come before in topological
wand w
v · edges in the diagraphs have a direction and in general ·ordering is not necessary is for every (v,v)
The Vertex vis the source and the vertex
the destination · in-degree of a vertex: edges where the vertex is the destination QBNOCF ·OUR OF INTERN out-degree of a vertex: edge where
vertex is the source
cucle is a path that begins
at the
same
Vis) itnlucle whou cc causes *al sort First AlgOUIM
cal sort Algorthm
A IgoUHM #1: -mark each vertex with Its
#he artifice is to
reftexidegree for a zero degree vertex ever the a 0
OtOtOf t time spending
degree vertex NadPUpotRAVENOS Athat Itaddandremove it 9
Total: 0 (IVI
In a
stack ect... Error rates and PCR te
OnEriom'olaointadawetvonma rations
one part before going back to the other parts not
explored ·(BFS) explores area close to start node First mong
Of
DESRB' Olvit O WeWelgHtedPAt oth ⑰S
Grenagraph with non-negative edge weight,
= (,E), way to a leaf before backtraking nearest to the root before and a distinguished source vertex in v
a path
Determine the distance and
path from source vertex to every and exploring
exploring further
· After searching
then
then D,
vertex in the grostra Algorithm The search
tracks and tries
as either known or unknown. A tentative distance another path from B
each vertex is ·Node are explored in order: OD'E ON TOO Or -drll kept for each verterrepath length from to using only known vertise
ABDEHLMNIODCFG
recor, which is the last vertex to cause achangetod or
a veterans Algorithm v, which has the smallest do amoung all
vertices, and
that ·
on expanding
of know vertices path from stor is knowseason)
I
strategy
Idea:
msp on
seleting edges GOOD OELOA oFloOORooTodor originatio Its starts
tree,
of the roSKal AlgOrIHMthis
is based
on expanding cloud are from graphone-by-one as follows atree formed from
edge starting
vertex, v, vis any
·The basic idea of the Kruskal's
connects all the vertices of Gat. Then It adds the shortest edge) = edge
minimum cost emanating from that connects to
to select the edge in
of
weight
loWe total COSt.
an edge if it
not caves a
The nest of the graph. = ol then moves to
vertex and
the process. OOO M Bonamed O CiaraMithortneaps or case research
application
of
with min lost.
d
set
terms
Makeset(x)
a
·Find(x)
Vetons