Term Project

advertisement
Name: Jariya Phongsai
Class: MAT230
Prof. Dr. Marina Dedlovskaya
Assignment: Term Project
Mat230 Introduction to Discrete Mathematics
Term Project
In this project I will design two algorithms for evaluating a given polynomial, and analyze their
effectiveness using an empirical approach. The two programs are designed to implement the algorithms
and perform an experiment to study the relationship between program running time and input size.
-
Devise two algorithms to compute f(x)=n(x^n)+1, where x is a positive real number, and n is a
power of 2. Use successive multiplication by x in the first algorithm and successive rising to the
second power in the second algorithm.
-
Write two codes to implement the algorithms from step I using a Java programming language.
Assume that X=125 and n=8, 16, 32, 64, 128, 256, 512, 1024, 2046,4096
Input (n)
8
16
32
64
128
256
512
1024
2048
4096
Running time Code I (nanosecond)
Running time Code II (nanosecond)
3344763
3578178
3775258
3784013
4172807
2482229
2600959
2584406
2523436
2541733
3154661
3229601
3366629
3400362
2471403
2504718
2694895
2556051
2844147
2584198
-
Devise two algorithms to compute f(x)=n(x^n)+1, where x is a positive real number, and n is a
power of 2. Use successive multiplication by x in the first algorithm and successive rising to the
second power in the second algorithm.
-
Write two codes to implement the algorithms from step I using a Java programming language.
Assume that n=125 and x=8, 16, 32, 64, 128, 256, 512, 1024, 2046,4096
Input (x)
8
16
32
64
128
256
512
1024
2048
4096
Running time Code I (nanosecond)
Running time Code I (nanosecond)
3249017
3358528
3334153
3374591
3374451
3481169
2652013
2529652
2968254
2511562
3396311
3417893
2584616
2744622
2485023
2917829
3311803
2512121
2508559
2850781
NANOSECOND
4000000
3500000
3000000
2500000
2000000
CODE I
1500000
CODE II
1000000
500000
THE VALUE OF X
0
8
16
32
64
128
256
512 1024 2048 4096
Download