• Wrong document? Swap it for free
  • Written by students who passed
  • Immediately available after payment
  • Read online or as PDF
Sell
Where do you study
Your language
Document preview thumbnail
Preview 2 out of 6 pages
Exam (elaborations)

Programming Logic and Design Chap. 8 Arrays Complete Answers

Document preview thumbnail
Preview 2 out of 6 pages

Programming Logic and Design Chap. 8 Arrays Complete Answers

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

Document information

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

Wrong document? Swap it for free Within 14 days of purchase and before downloading, you can choose a different document. You can simply spend the amount again.
Written by students who passed
Immediately available after payment
Read online or as PDF

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
3.8
(84)
Sold
346
Followers
28
Items
26289
Last sold
2 weeks ago




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

Working on your references?

Create accurate citations in APA, MLA and Harvard with our free citation generator.

Working on your references?

Frequently asked questions