100% satisfaction guarantee Immediately available after payment Both online and in PDF No strings attached 4,6 TrustPilot
logo-home
Summary

Summary Programming Logic and Design Ch 8

Rating
-
Sold
-
Pages
5
Uploaded on
15-11-2025
Written in
2025/2026

This document provides an in depth and thorough summary of chapter 8 of Programming Logic and Design. It is ready for exam and tests. Everything is laid out as it is in the textbook. All needed information is provided in short. It is written in an easy to study format and reads easy. I got distinctions in exams and tests.

Show more Read less
Institution
Course









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

Connected book

Written for

Institution
Course

Document information

Summarized whole book?
No
Which chapters are summarized?
8
Uploaded on
November 15, 2025
Number of pages
5
Written in
2025/2026
Type
Summary

Subjects

Content preview

Chapter 8
Explain the need for storing data
 Sequential order
 Placed in order based on the value of some field
 Alphabetical or numerical
 Ascending order (arranging records from A to Z or lowest to highest)
 Descending order (arranging records from Z to A or highest to lowest)
 The median value in a list is the value of the middle item when the values are listed in order
 not the same as the arithmetic average, or mean

 When computers sort data
 Always use numeric values when making comparisons between values
 Letters are translated into numbers using coding schemes such as ASCII, Unicode, or
EBCDIC
 “B” is numerically one greater than “A”
 “y” is numerically one less than “z”
 Whether “A” is represented by a number that is greater or smaller than the number
representing “a” depends on your system
 Professional programmers might never have to write a program that sorts data
 Organizations can purchase prewritten sorting programs
 Many popular language compilers come with built-in methods that can sort data for you
 Beneficial to understand the sorting process


Describe the bubble sort algorithm
 An algorithm is a list of instructions that accomplish a task, such as a sort
 Bubble sort
 Items in a list are compared with each other in pairs
 Items are then swapped based on which is larger or smaller
 Sometimes called a sinking sort
 Ascending sorts put the smaller item on top, so the largest item sinks to the bottom
 Descending sorts put the larger item on top, so the smallest item sinks to the bottom
 An algorithm contains instructions for swapping values
 To swap values stored in two variables:
 Exchange their values
 Set the first variable equal to the value of the second
 Set the second variable equal to the value of the first
 There is a trick to swapping any two values
 Example
 num score1 = 90
 num score2 = 85
 This is what could go wrong

,  If you first assign score1 to score2 using a statement such as score2 = score1
 Both score1 and score2 hold 90, and the value 85 is lost
 Must create a temporary variable to hold one of the scores
 temp = score2 (temp and score2 both contain 85)
 score2 = score1 (score2 contains 90)
 score1 = temp (score1 contains 85)


 Nested loops
 Inner loop swaps out-of-order pairs
 Outer loop goes through the list multiple times
 General rules
 Greatest number of pair comparisons is one less than the number of elements in the array
 Number of times you need to process the list of values is one less than the number of
elements in the array


Sort records on multiple field values
 Might not know how many array elements will hold valid values
 Keep track of the number of elements stored in an array
 Store number of elements
 Compute comparisons as number of elements – 1


 If you are performing an ascending sort
 After you have made one pass through the list, the largest value is guaranteed to be in its
correct final position

1. Compare every element pair in the list on every pass through the list
2. Comparing elements that are already guaranteed to be in their final correct position
3. On each pass through the array, stop your pair comparisons one element sooner
4. Create a new variable pairsToCompare
5. Set it equal to the value of numberOfEls – 1
6. On each subsequent pass through the list, reduce pairsToCompare by 1
7. Create a new variable didSwap
8. Set it equal to the value of “No”
9. Each time the swap () module executes, change the value to “Yes”

Class
 Sorting data stored in parallel arrays
 Each array must stay in sync StudentRecord

 Sorting records as a whole string name

 Create groups called record structures or classes num score

 Defining a class allows you to sort by either name or scoreendClass

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.
tanjanel1303 Rosebank College (Pretoria)
Follow You need to be logged in order to follow users or courses
Sold
10
Member since
1 year
Number of followers
2
Documents
47
Last sold
2 months ago

5.0

2 reviews

5
2
4
0
3
0
2
0
1
0

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 exams and reviewed by others who've used these notes.

Didn't get what you expected? Choose another document

No worries! You can immediately select a different document that better matches what you need.

Pay how you prefer, start learning right away

No subscription, no commitments. Pay the way you're used to via credit card or EFT 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