i want help in the discrete assignment

User Generated

NFN97

Computer Science

Description

i will upload a file that has all the instructions

in the same file you will find all the problems

please solve the problem as the instructions need

Unformatted Attachment Preview

COT 3100 Intro. To Discrete Structures Homework #8 Problem 1 (55 points): Assume that 𝒏 is a positive integer. For each of the following algorithm segments, how many times will the innermost loop be iterated when the algorithm segment is implemented and run? 𝑛 1) for ( 𝑖 = 1; 𝑖 ≤ ⌊ 2⌋ ; 𝑖 ++) [Statements in the body of the inner loop, none containing branching statements that lead outside the loop] 2) for ( 𝑖 = ⌊𝑛/2⌋ ; 𝑖 ≤ 𝑛; i ++) [Statements in the body of the inner loop, none containing branching statements that lead outside the loop] 3) for ( 𝑖 = 1; 𝑖 ≤ 𝑛 ; 𝑖 ++) for ( 𝑗 = 1; 𝑗 ≤ 2𝑛 ; 𝑗 ++) [Statements in the body of the inner loop, none containing branching statements that lead outside the loop] 4) for ( 𝑖 = 2; 𝑖 ≤ 𝑛 ; 𝑖 ++) for ( 𝑗 = 1; 𝑗 ≤ 3𝑛 ; 𝑗 ++) [Statements in the body of the inner loop, none containing branching statements that lead outside the loop] 5) for ( 𝑖 = 1; 𝑖 < 𝑛 ; 𝑖 ++) for ( 𝑗 = 𝑖 + 1; 𝑗 ≤ 𝑛 ; 𝑗 ++) [Statements in the body of the inner loop, none containing branching statements that lead outside the loop] 6) for ( 𝑖 = 1; 𝑖 < 𝑛 ; 𝑖 ++) for ( 𝑗 = 𝑖; 𝑗 ≤ 𝑛 ; 𝑗 ++) [Statements in the body of the inner loop, none containing branching statements that lead outside the loop] 7) for ( 𝑖 = 1; 𝑖 ≤ 𝑛 ; 𝑖 ++) for ( 𝑗 = 1; 𝑗 ≤ 𝑖 ; 𝑗 ++) [Statements in the body of the inner loop, none containing branching statements that lead outside the loop] 8) for ( 𝑖 = 1; 𝑖 ≤ 𝑛 ; 𝑖 ++) for ( 𝑗 = 1; 𝑗 < 𝑖 ; 𝑗 ++) [Statements in the body of the inner loop, none containing branching statements that lead outside the loop] 9) for ( 𝑖 = 1; 𝑖 ≤ 𝑛 ; 𝑖 ++) for ( 𝑗 = 1; 𝑗 ≤ ⌊(𝑖 + 1)/2⌋ ; 𝑗 ++) [Statements in the body of the inner loop, none containing branching statements that lead outside the loop] 10) for ( 𝑖 = 1; 𝑖 ≤ 𝑛 ; 𝑖 ++) for ( 𝑗 = ⌊(𝑖 + 1)/2⌋; 𝑗 ≤ 𝑛 ; 𝑗 ++) [Statements in the body of the inner loop, none containing branching statements that lead outside the loop] 11) for ( 𝑚 = 1; 𝑚 ≤ 𝑛 ; 𝑚 ++) for ( 𝑘 = 1; 𝑘 ≤ 𝑚 ; 𝑘 ++) for ( 𝑗 = 1; 𝑗 ≤ 𝑘 ; 𝑗 ++) for ( 𝑖 = 1; 𝑖 ≤ 𝑗 ; 𝑖 ++) [Statements in the body of the inner loop, none containing branching statements that lead outside the loop] Problem 2 (25 points) Find how many solutions there are to the given equation that satisfy the given condition. 1) 𝑥1 + 𝑥2 + 𝑥3 = 20, each 𝑥𝑖 is a nonnegative integer. 2) 𝑥1 + 𝑥2 + 𝑥3 = 20, each 𝑥𝑖 is a positive integer. 3) 𝑦1 + 𝑦2 + 𝑦3 + 𝑦4 = 30, each 𝑦𝑖 is a nonnegative integer. 4) 𝑦1 + 𝑦2 + 𝑦3 + 𝑦4 = 30, each 𝑦𝑖 is an integer that is at least 2. 5) 𝑎 + 𝑏 + 𝑐 + 𝑑 + 𝑒 = 500, each of 𝑎, 𝑏, 𝑐, 𝑑, and 𝑒 is an integer that is at least 10. Problem 3 (10 points) For how many integers from 1 through 99,999 is the sum of their digits equal to 10? Problem 4 (10 points) Prove that if n is an integer and n ≥ 1, then 𝑛+2 1 · 2 + 2 · 3 +· · · +𝑛(𝑛 + 1) = 2 ( ) 3 Submission Requirements The following requirements are for electronic submission via Canvas. ⚫ Your solutions must be in a single file with a file name yourname-hw8. ⚫ Upload the file by following the link where you download the homework description on Canvas. ⚫ If scanned from hand-written copies, then the writing must be legible, or loss of credits may occur. ⚫ Only submissions via the link on Canvas where this description is downloaded are graded. Submissions to any other locations on Canvas will be ignored.
Purchase answer to see full attachment
User generated content is uploaded by users for the purposes of learning and should be used following Studypool's honor code & terms of service.

Explanation & Answer

The solutions are ready. Please read them and ask if something is unclear.I still have to polish some answers, those 3 hours you mentioned must be sufficient.docx and pdf files are identical

0. I hope we know that
𝑛

∑ 1 = 𝑛,
𝑖=1
𝑛

𝑛

∑𝑖 = ∑𝑖 =
𝑖=1
𝑛

𝑖=0
𝑛

(𝑛 + 1)𝑛
,
2

∑ 𝑖2 = ∑ 𝑖2 =
𝑖=1
𝑛

𝑖=0
𝑛

𝑛(𝑛 + 1)(2𝑛 + 1)
,
6
2

(𝑛 + 1)𝑛
∑𝑖 = ∑𝑖 = (
) .
2
3

𝑖=1

3

𝑖=0

1.
𝑛

1) ⌊ 2⌋ (obvious).
𝑛

2) 𝑛 − ⌊ 2⌋ + 1 (obvious).
3) 𝑛 ∙ 2𝑛 = 𝟐𝒏𝟐 because the loops are independent.
4) (𝑛 − 2 + 1)(3𝑛) = 𝟑𝒏𝟐 − 𝟑𝒏 (the loops are independent).
5) Here the loops are dependent. We have
𝑛−1

𝑛−1

𝑛−1

∑(𝑛 − (𝑖 + 1) + 1) = ∑(𝑛 − 𝑖) = |𝑐ℎ𝑎𝑛𝑔𝑒 𝑖 → 𝑛 − 𝑖| = ∑ 𝑖 =
𝑖=1

𝑖=1

𝑖=1

(𝒏 − 𝟏)𝒏
.
𝟐

6) Similar to 5:
𝑛−1

𝑛−1

𝑛−1

∑(𝑛 − (𝑖) + 1) = ∑(𝑛 − 𝑖 + 1) = ∑(𝑖 + 1) =
𝑖=1

𝑖=1

𝑖=1

7) Similar to 5 and even simpler: ∑𝑛𝑖=1 𝑖 =
8) Similar to 7: ∑𝑛𝑖=1(𝑖 − 1) =

(𝑛+1)𝑛
2

−𝑛=

(𝒏+𝟏)𝒏
𝟐

.

(𝒏−𝟏)𝒏
𝟐

.

(𝑛 − 1)𝑛
(𝒏 − 𝟏)(𝒏 + 𝟐)
+𝑛−1=
.
2
𝟐

9) It is ∑𝑛𝑖=1 (⌊
and ⌊

𝑖+1
2

𝑖+1
2

⌋). Divide it into two sums, with odd and even 𝑖s. For an odd 𝑖, 𝑖 = 2𝑘 + 1

⌋ = 𝑘 + 1, for an even 𝑖, 𝑖 = 2𝑘 and ⌊
𝑛

∑ (⌊
𝑖=1

𝑖+1

2
𝑛−1


2

⌋ = 𝑘. This way the sum is
𝑛
⌊ ⌋
2

𝑖+1
⌋) = ∑ (𝑘 + 1) + ∑(𝑘).
2
𝑘=0

𝑘=1

We know what it is. We can consider odd and even 𝑛s separately and get nicer formulas.
10) almost the same as 9) (change of variable j).
𝑘
𝑚
𝑛
11) It is ∑𝑛𝑚=1(∑𝑚
𝑘=1(∑𝑗=1 𝑗)) = ∑𝑚=1 (∑𝑘=1 (
𝑛

𝑘(𝑘+1)
2

1

2
)) = 2 ∑𝑛𝑚=1(∑𝑚
𝑘=1(𝑘 + 𝑘)) =
𝑛

1
1
1
1
= ∑ ( (𝑛(𝑛 + 1)(2𝑛 + 1) + 𝑛(𝑛 + 1))) =
∑ (2𝑛3 + 3𝑛2 + 𝑛 + 3𝑛2 + 3𝑛) =
2
6
2
12
𝑚=1
𝑛

=

𝑚=1

1
1 1 2
∑ (2𝑛3 + 6𝑛2 + 4𝑛) =
( 𝑛 (𝑛 + 1)2 + 𝑛(𝑛 + 1)(2𝑛 + 1) + 2𝑛(𝑛 + 1)) =
12
12 2
𝑚=1

1
1
=
𝑛(𝑛 + 1)(𝑛(𝑛 + 1) + 2(2𝑛 + 1) + 4) =
𝑛(𝑛 + 1)(𝑛2 + 5𝑛 + 6) =
24
24
𝟏
=
𝒏(𝒏 + 𝟏)(𝒏 + 𝟐)(𝒏 + 𝟑).
𝟐𝟒

2.
1) 𝑖 may be any from 0 to 20, for any 𝑖 𝑗 may be any from 0 to 20 − 𝑖 and after 𝑖, 𝑗 are
chosen, 𝑘 is determined. So, the quantity is
20

20−𝑖

20

20

20

∑ ( ∑ (1)) = ∑(21 − 𝑖) = ∑ 21 − ∑ 𝑖 = 212 −
𝑖=0

𝑗=0

𝑖=0

𝑖=0

𝑖=0

20 ∙ 21
= 441 − 210 = 𝟐𝟑𝟏.
2

2) 𝑖 may be any from 1 to 20, for any 𝑖 𝑗 may be any from 1 to 20 − 𝑖 and after 𝑖, 𝑗 are
chosen, 𝑘 is determined. So, the quantity is
20

20−𝑖

20

20

20

∑ ( ∑ (1)) = ∑(20 − 𝑖) = ∑ 20 − ∑ 𝑖 = 202 −
𝑖=1

𝑗=1

𝑖=1

𝑖=1

𝑖=1

20 ∙ 21
= 400 − 210 = 𝟏𝟗𝟎.
2

3) Here we have the same way
30

30−𝑖

30−𝑖−𝑗

30

30−𝑖

30

∑ ( ∑ ( ∑ (1))) = ∑ ( ∑ (31 − 𝑖 − 𝑗)) = ∑ ((31 − 𝑖)2 −
𝑖=0

𝑗=0

𝑘=0

𝑖=0

𝑗=0

30

30

= |𝑖 → 30 − 𝑖| = ∑ ((𝑖 + 1)2 −
𝑖=0

30

𝑖=0

(30 − 𝑖)(31 − 𝑖)
)=
2

𝑖(𝑖 + 1)
1
) = ∑(2𝑖 2 + 4𝑖 + 2 − 𝑖 2 − 𝑖) =
2
2
𝑖=0

1
1 30 ∙ 31 ∙ 61 90 ∙ 31
1
∑(𝑖 2 + 3𝑖 + 2) = (
+
+ 62) = (350 ∙ 31 + 62) = 𝟓𝟒𝟓𝟔.
2
2
6
2
2

=

𝑖=0

4) It is similar to 3) but variables start from 2, not from 0:
30

30−𝑖

30−𝑖−𝑗

30

30−𝑖

∑ ( ∑ ( ∑ (1))) = ∑ ( ∑ (29 − 𝑖 − 𝑗)) =
𝑖=2

𝑗=2

𝑘=2

𝑖=2

30

= ∑ ((29 − 𝑖)2 − (
𝑖=2

𝑗=2

(30 − 𝑖)(31 − 𝑖)
− 1)) =
2

29

29

1
1
= |𝑖 → 31 − 𝑖| = ∑ ((𝑖 − 2) − (𝑖(𝑖 − 1) − 2)) = ∑(2𝑖 2 − 8𝑖 + 8 − 𝑖 2 + 𝑖 + 2) =
2
2
2

29

𝑖=1

𝑖=1

1
1 29 ∙ 30 ∙ 59 7 ∙ 29 ∙ 30
1
= ∑(𝑖 2 − 7𝑖 + 10) = (

+ 290) = (190 ∙ 29 + 290) = 29 ∙ 100 =
2
2
6
2
2
𝑖=1

= 𝟐𝟗𝟎𝟎.

500−𝑖−𝑗

500−𝑖
5) It is ∑500
𝑖=10(∑𝑗=10 (∑𝑘=10
490

480−𝑖

470−𝑖−𝑗

𝑗=0

490

480−𝑖

𝑖=0

𝑗=0

𝑘=0

(1)))) = |𝑖 → 𝑖 + 10, 𝑗 → 𝑗 + 10 𝑒𝑡𝑐| =

460−𝑖−𝑗−𝑘

= ∑( ∑ ( ∑ (
𝑖=0

500−𝑖−𝑗−𝑘

(∑𝑚=10


490

480−𝑖

470−𝑖−𝑗

(1)))) = ∑ ( ∑ ( ∑ (461 − 𝑖 − 𝑗 − 𝑘))) =

𝑚=0

𝑖=0

𝑗=0

𝑘=0

1
= ∑ ( ∑ ((461 − 𝑖 − 𝑗)(471 − 𝑖 − 𝑗) − (470 − 𝑖 − 𝑗)(471 − 𝑖 − 𝑗))) =
2
490

480−𝑖

𝑖=0

𝑗=0

490

480−𝑖

𝑖=0
490

𝑗=0

1
= ∑ ( ∑ ((471 − 𝑖 − 𝑗)(452 − 𝑖 − 𝑗))) =
2
1
= ∑ ( ∑ ((471 − 𝑖)(452 − 𝑖) − 𝑗(923 − 2𝑖) + 𝑗 2 )) =
2
1
1
= ∑ ((481 − 𝑖)(471 − 𝑖)(452 − 𝑖) − (923 − 2𝑖) (480 − 𝑖)(481 − 𝑖)
2
2
𝑖=0

1
+ (480 − 𝑖)(481 − 𝑖)(961 − 2𝑖)) = ⋯
6
Here we need to change variables again and finish computations. Technology says the
answer is 1901790791.
It says the same about the initial expression and the last one, so we did not make any
errors😊

10−𝑖−𝑗
10−𝑖−𝑗−𝑘
10−𝑖
(1)))) = 𝟏𝟎𝟎𝟏
3. It is ∑10
(∑𝑚=0
𝑖=0(∑𝑗=0 (∑𝑘=0
(no doubt we can compute this the same way as above; I used technology here).

𝑖, 𝑗, 𝑘, 𝑚 correspond to the first 4 digits here.

𝑛+2
).
3
...


Anonymous
This is great! Exactly what I wanted.

Studypool
4.7
Trustpilot
4.5
Sitejabber
4.4

Similar Content

Related Tags