100% satisfaction guarantee Immediately available after payment Both online and in PDF No strings attached 4.6 TrustPilot
logo-home
Exam (elaborations)

Programming Logic and Design Chap. 8 Arrays Complete Answers

Rating
-
Sold
-
Pages
6
Grade
A+
Uploaded on
22-03-2025
Written in
2024/2025

Programming Logic and Design Chap. 8 Arrays Complete Answers

Institution
Programming Logic And Design
Course
Programming Logic and Design









Whoops! We can’t load your doc right now. Try again or contact support.

Written for

Institution
Programming Logic and Design
Course
Programming Logic and Design

Document information

Uploaded on
March 22, 2025
Number of pages
6
Written in
2024/2025
Type
Exam (elaborations)
Contains
Questions & answers

Subjects

Content preview

Programming Logic and Design Chap.
8 Arrays Complete Answers



Each element of the array has a unique number called a subscript that identifies it

the subscript always starts at 0

Assigning values can be done individually using a subscript

Include example

What is a more effective way to step through the array - ANSWER-Set numbers[0] =
20 Set numbers[1] = 30
Set numbers[2] = 40 Set numbers[3] = 50 Set numbers[4[ = 60

But, it is much more efficient to use a Loop to step through the array

Arrays can be initialized to 0 or specific values

What should be done to avoid use of an invalid subscript - ANSWER-Array bounds
checking should be performed to avoid use of an invalid subscript

A common error is running a loop one time more than is
necessary, exceeding the bound of the array

Off-by-one Error

What is a partial filled array - ANSWER-To avoid processing the unfilled elements,
you must have an accompanying integer variable that holds the number of items
stored in the array

When the array is empty, 0 is stored in this variable

The variable is incremented each time an item is added to
the array

The variable's value is used as the array's size when stepping through the array

Other information - ANSWER-The For Each Loop

Some languages provide a For Each loop

It works with an array, iterating once for each array
element

During each iteration, the loop copies an element's value to a variable.

, For Each example: - ANSWER-Constant Integer SIZE = 5
Declare Integer numbers[SIZE] = 5, 10, 15, 20, 25
Declare Integer num


For Each num In numbers
Display num
End For

What is a sequential teach algorithm - ANSWER-A sequential search algorithm is a
simple technique for finding an item in a string or numeric array

Uses a loop to sequentially step through an array

Compares each element with the value being searched for

More information - ANSWER-Totaling the values in an array and calculating
average

Loops are used to accumulate the values

Then, the total is simply divided by the size

Finding the highest and lowest values in an array - ANSWER-The highest

Create a variable to hold the highest value

Assign the value at element 0 to the highest

Use a loop to step through the rest of the elements

Each iteration, a comparison is made to the highest variable

If the element is greater than the highest value, that value is then the assigned to the
highest variable


The lowest

Same process, but checks if the element is less than the lowest value

Copying an array can be done using loops - ANSWER-Copying an array can be
done using loops
For index = 0 to SIZE - 1
Set secondArray[index] = firstArray[index]
End For

Passing an Array as an Argument

Get to know the seller

Seller avatar
Reputation scores are based on the amount of documents a seller has sold for a fee and the reviews they have received for those documents. There are three levels: Bronze, Silver and Gold. The better the reputation, the more your can rely on the quality of the sellers work.
lectknancy Boston University
View profile
Follow You need to be logged in order to follow users or courses
Sold
286
Member since
2 year
Number of followers
28
Documents
26010
Last sold
19 hours ago

3.6

57 reviews

5
23
4
10
3
11
2
3
1
10

Recently viewed by you

Why students choose Stuvia

Created by fellow students, verified by reviews

Quality you can trust: written by students who passed their tests and reviewed by others who've used these notes.

Didn't get what you expected? Choose another document

No worries! You can instantly pick a different document that better fits what you're looking for.

Pay as you like, start learning right away

No subscription, no commitments. Pay the way you're used to via credit card and download your PDF document instantly.

Student with book image

“Bought, downloaded, and aced it. It really can be that simple.”

Alisha Student

Frequently asked questions