PDE - What's a Search? (Lesson)

What's a Search?

Searches to Know

A search is going through a set of similar type data and looking for a particular one.  There are two types of searches to know for this course. 

  • Linear or Sequential Search
  • Binary Search

Both of these are important in computer science.  Searches look through data and find a specific information.  Using a data set, an array or list, of information could include:

  • finding whether a value exists
  • finding a specific data value and returning it's location in the data set
  • finding how many of a specific value exist in a set of data
  • examining a data set and dividing the parts into separate data sets depending on need
  • putting an unordered data set in order

Types of Arrays or Lists of Data

Linear has the word line in it so a linear search is following the data in order that the information is in the set, one data value after another.  This also follows with the word sequential which means to handle in order that the data is organized in.  

This type of search allows for the data set to be ordered or unordered. 

Ordered List

An ordered data set of numbers would have the numbers from lowest starting the set to the highest at the end or vice versa.  Whatever place you start, highest or lowest the next value would be lower or higher respectively.  Example: 1, 2, 3, 4, 5 . . .     An ordered alpha set would have the information in alphabetical order from a to z, or z to a.  In both cases the ordering low to high or high to low would be dependent on the most frequently used information.  If this information was normally in the lower end of the set, then low to high would be used for efficiency whereas if the higher end of the set was most often used, then high to low would be more efficient.

Unordered List

This is a list, array, or other set of data that is put together without thought to having any of the data in order.  An example of this list would be a grocery list?  Do you organize this by the aisle of the store the product is found of alphabetically, or is the list then created and a sequential scan down the list is used as items are looked for in the store.  An unordered list usually has data that does not benefit from being ordered, a list of data based on when it was considered to be needed.  Example:  a list grocery list, a list of barnyard animals, a list of names, etc.

Which to use, ordered or unordered?

Sometimes you will have a choice if you are building the data? 

  • the size of the data set.
  • how often it will be accessed?
  • what will the data be accessed for?and for what? 
  • Are others using the data as well as you?  In the larger scheme of things data is used by many.
  • If this is your private program, then you need to decide what is best for your program analysis, programming, and code, and analysis proficiency.