1 / 8

Sorting and Searching Arrays

Sorting and Searching Arrays. Partially Filled Arrays. Not all elements of the array might receive values: This is termed a partially filled array. Programmer must keep track of how much of array is used.

ogden
Télécharger la présentation

Sorting and Searching Arrays

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Sorting and Searching Arrays

  2. Partially Filled Arrays • Not all elements of the array might receive values: • This is termed a partially filled array. • Programmer must keep track of how much of array is used.

  3. Consider arranging elements of an array so that they have an ascending order. • Algorithm is to step through the array: • Place the smallest element in index 0. • Swap elements as needed to sort the entire array.

  4. This method sorts the array This method searches for the next smallest element

  5. “selectionSort (arg)” is a static method ClassName . staticMethodName (arg)

  6. MultidimensionalArray we can access elements of the table with a nested“for” loop

  7. column 0 1 2 3 4 5 5 5.5 6 6.5 7 7.5 declaring a 2-dimentional array year 1 2 3 4 5 6 7 8 9 10 computing the contents of the array printing the contents of the array

  8. using System.out.println(…); using 2 “for” loops and System.out.println(…);

More Related