7) Imagine you have a box of rectangular blocks. Write some psuedocode that will
ID: 3891855 • Letter: 7
Question
7) Imagine you have a box of rectangular blocks. Write some psuedocode that will instruct a person to stack twenty blocks into a rectangular array of four rows of five blocks as pictured below. Write the solution in a way that could be generalized easily to larger rectangles. Answer 8) Imagine you have a box of rectangular blocks. Write some psuedocode that will instruct a erson to stack fifteen blocks into the arrangement below. Write the solution in a way that can be eneralized easily to larger arrangements Answer:Explanation / Answer
Ques 7.
Function arrange()
BEGIN
// represent the number of bricks in one row
len = 5
// represent the number of bricks in one column
wid = 4
// traverse the rows
for i = 1 to wid
BEGIN
// traverse the current row
for j = 1 to len
BEGIN
Stack the brick in the current row after the previous brick
END
Go to row above the current row
END
END
Ques 8.
Function arrange()
BEGIN
// represent the number of bricks in one row
len = 5
// represent the number of bricks in one column
wid = 4
// traverse the rows
for i = 1 to wid
BEGIN
// traverse the current row
for j = 1 to ( len – I + 1 )
BEGIN
Stack the brick in the current row after the previous brick
END
Go to row above the current row
END
END
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.