Chapter Eight

¡Supera tus tareas y exámenes ahora con Quizwiz!

a selection sort algorithm moves items immediately to their final position in the array. This is more efficient than a bubble sort. The sorting and searching algorithms you have studied in this chapter may be applied to STL vectors as well as arrays. Simply substitute the vector syntax for the array syntax when necessary

The smallest value in the array is located and moved to element 0. Then the next smallest value is located and moved to element 1. This process continues until all of the elements have been placed in their proper order.

a binary search is an efficient algorithm that is much faster than a linear search that accomplishes the same task. The binary search algorithm will not work properly unless the values in the array are sorted. The binary search is much more efficient than the linear search. Every time it makes a comparison and fails to find the desired item, it eliminates half of the remaining portion of the array that must be searched.

The values in the array be sorted in order (ascending or descending). A binary search starts with the element in the middle. If that element is not the desired value. That value in the middle element is either greater than or less than the value being searched for. It then goes to the middle of the remaining part of the array that may hold the value being searched for. It continues going to the middle of the remaining part of the array until it finds what it's looking for or runs out of array to search.

a bubble sort algorithm is an easy way to arrange data in ascending or descending order .

ascending order = lowest to highest descending order = highest to lowest

a linear search, also known as a sequential search, is a very simple algorithm. However, they are inefficient. linear search should not be used on large arrays if the speed is important.

it uses a loop to sequentially step through an array, starting with the first element. It compares each element with the value being searched for and stops when either the value is found or the end of the array is encountered.


Conjuntos de estudio relacionados

Brokerage activities and requirements

View Set

Cybersecurity Fundamentals - Practice Test

View Set

Animals in Research ICEV Assessments I-IV

View Set

Preguntas de Latinos en los EE.UU.

View Set

Soc 1 - Inquizitive Chapter 1 2017

View Set

Psych 21A Ch. 4 Review Questions

View Set