0% found this document useful (0 votes)
34 views

DiskMat à - Ving 3

The document describes the greedy algorithm for making change using quarters, dimes, nickels, and pennies. It provides examples of using the algorithm to make change for various amounts and discusses: 1) Using the greedy algorithm to make change for 57 cents, 99 cents, 76 cents, and 60 cents when nickels are included. 2) The greedy algorithm does not always yield the optimal solution when no nickels are used, as seen when making change for 99 cents. 3) Big-O estimates for various functions including nlog(n^2+1), n^2logn, and others.

Uploaded by

Aurora Sauar
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
34 views

DiskMat à - Ving 3

The document describes the greedy algorithm for making change using quarters, dimes, nickels, and pennies. It provides examples of using the algorithm to make change for various amounts and discusses: 1) Using the greedy algorithm to make change for 57 cents, 99 cents, 76 cents, and 60 cents when nickels are included. 2) The greedy algorithm does not always yield the optimal solution when no nickels are used, as seen when making change for 99 cents. 3) Big-O estimates for various functions including nlog(n^2+1), n^2logn, and others.

Uploaded by

Aurora Sauar
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 3

DISK MAT OUING 3

② se the cashier's algorithm to make

change using quarters ,


dimes ,
nuckles and

pennies for

a) 57 cents :
2-25+7.1 cent

b) 99 cents : 2.25+7 -101-2.5-+4-7 cent

'

e) 76 cents -

3-25+2.7 cent

d) GO cents -

. 2- 25 + 7 • 10 cent

5⑨ Same ,
but no nickels .

Then will for


the
greedy algorithm give optimal solution
a) 52 , C) 76 and d) GO cont as it makes the same decision as it

does with nickels - ( No nickels in these solutions]

For b) greedy algorithm will 12 is not optimal


the give pennies which

should 4 4 dimes and 4


be :
quarter ,
pennies .

④ Can see from is that the greedy


algorithm do not always yield the

least amount of
pennies

3.2J
27£

Give for of these functions


a big-0 estimate each .

d) n
log Cn2+ 1) 1- n2 log n

n ? 7 i
log Cnz
+
7) ←
log Cn2s-n2)

7) log C2n2)

eog.cn
-
+

login 7) ←
log 2+2109 n £3108M
-
+

logcn2+7 ) is Otogn )

By theorem 3 :
nlogcnz +17 is Ocnlogn)

2 nlogcnz + 7) tog 0(n2#yn]


-
and by theorem +n n is
b) Ltocyn 7)
2
Cnlogn +
7) + + Cna + 7)
2
nz2 :
@ login +
7) = n2( login)2 + 2 nlog.mil

Theorem 2 oCn2Clogn)2)

and a logcnt ? ) is Oclogn)

hat ? is OCNZ )

Hence , using theorem 3

(n 7) ocrihlogn)
-
(tog n +7) +
is

and :

(nlooyn + 7)
2
+
(locyn + 1) ( n 2+1) is
OCn gnD

30£ Show that each of these pairs


of functions
a re of the same orator

c) Lxt I ] ,

✗ >
I I ✗ a- 2×+21<-211
Hence ☒ +3s is ④ (X )

LX unique
constants a ✗ a- +
E) a- Czx is not -

all that functions have the


showing the

Sanne order -

e) log no ✗ , 10924

,↳§g!÷ =
'%✗_
we know that
eog -
✗ =
loegco

log ✗ =
(log 10 ) log ↳

logo ✗ is ☒ dog ✗ )
→ same order .

✗ >
7 = 3×2 £ 3×2 + ✗ +7

and 3×2 + ✗ +7<-3×2 + ✗2 + ✗2 =


5×2 a- 26×2=2-3×2

which shows that 3×2 + ✗ +2 is (3×2)

with ci=1 ,
cz=2 and K =
7 ,

42J No .

section4#

45J What time does a 12 -


hour clock read

a) 19:00 (
or 7:00 PM)

b) 04:00

c) 10:00

42J Show that if arbic and rn are integers


Srt MZZ ,
c > 0 and a _= b Cnoroelm) ,
then
ACE be cnaodmc) .

a =-D Cmodm )

b = at Kern

Cb = cat Kem

ca E Cb Cmodcm ) ☐

You might also like