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

TCSS 343 HW5

This document contains solutions to homework problems involving: 1) Evaluating a polynomial expression at a point using Horner's method. 2) Converting a decimal number to binary and calculating its value using exponents of two. 3) Performing a linear search to find a match between two strings by shifting characters when they do not match.

Uploaded by

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

TCSS 343 HW5

This document contains solutions to homework problems involving: 1) Evaluating a polynomial expression at a point using Horner's method. 2) Converting a decimal number to binary and calculating its value using exponents of two. 3) Performing a linear search to find a match between two strings by shifting characters when they do not match.

Uploaded by

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

"

Daniel Bergman HW5 TCSS 343

1a. p(x) = x5 + 3x3 4x2 + 1 at x = 2.

Coefficient 1 0 3 -4 1
Value with 1 -2 + 0 = -2 -6 + 3=-3 -3*-2 - 4 = 2 2*-2 + 1 = -3
Horner's
algorithm

1b. n = 19 = 10011 in binary.

Binary Value 1 0 0 1 1

Product exponent 6 62 62*2 = 4 64*2+1 = 9 69*2+1 =19

2a.

Value G C T A
Shift 2 1 5 7

2b.

i.

String 1: CTGCGCT

String 2: CTGCGCGGACCAGACTGCGCCCTGGGCTGCGCTAGTGCT

^Compare G to T. Not a match. Shift 2.

ii.

String 1: CTGCGCT

String 2: CTGCGCGGACCAGACTGCGCCCTGGGCTGCGCTAGTGCT

^Compare T to A. Not a match. Shift 7.

iii.

String 1: CTGCGCT

String 2: CTGCGCGGACCAGACTGCGCCCTGGGCTGCGCTAGTGCT

^^^ Compare T to T. Match. Compare C to C. Match. Compare G to A. Not a


match, shift 5 spaces forward.

iv.

String 1: CTGCGCT

String 2: CTGCGCGGACCAGACTGCGCCCTGGGCTGCGCTAGTGCT

^ Compare T to C. Not a match, shift 1 space forward.


"
Daniel Bergman HW5 TCSS 343

v.

String 1: CTGCGCT

String 2: CTGCGCGGACCAGACTGCGCCCTGGGCTGCGCTAGTGCT

^ Compare T to C. Not a match, shift 1 space forward.

vi.

String 1: CTGCGCT

String 2: CTGCGCGGACCAGACTGCGCCCTGGGCTGCGCTAGTGCT

^^^ Compare T to T. Match. Compare C to C. Match. Compare G to


C. Not a match, shift 5 spaces forward.

vii.

String 1: CTGCGCT

String 2: CTGCGCGGACCAGACTGCGCCCTGGGCTGCGCTAGTGCT

^^^^ Compare T to T. Match. Compare C to C. Match.


Compare G to G. Match. Compare C to G. Not a match, shift 5 spaces forward.

viii.

String 1: CTGCGCT

String 2: CTGCGCGGACCAGACTGCGCCCTGGGCTGCGCTAGTGCT

^^^^^^^ Compare T to T. Match. Compare C to C. Match.


Compare G to G. Match. Compare C to C. Match. Compare G to G. Match. Compare T to T. Match.
Compare C to C. Match. Return current index.

You might also like