Lecture 5 - Arrays and Structs Flashcards
organized collection of values that may be used for data together with a set of operations that may be performed with the data.
Data Structures
data whose values are directly supported in the hardware of the computer (int, float, double, char)
Elementary or Scalar
contains group of scalars, each accessed by a referencing mechanism. (array, records, structures)
Structure
data types that are defined by the developers (enumeration, type declaration)
Abstract
a finite, ordered collection of homogeneous elements, each accessed through a subscript value.
Arrays
all the elements are arranged in order (first, second, third, and so on)
ordered
there is a specific number of elements in the array
finite
all the elements in the array must be of the same type (e.g. all integers, all characters or all floating point)
homogeneous
type of the values used to access the individual elements of the array
Index (subscript type)
type of elements or components
of the array.
Base Type (common type)
specifies the position of the component of the array
indexExp
How to Declare Arrays?
dataType, array_name, array_size
How to Initialize Arrays
dataType array_name
usually enclosed in brackets, determines the number of elements that an array has to contain
array_size
How to access arrays
array_name[indexExp]
a function that accepts an array variable, indicated by its array name and element of its index type and returns the arrays content
Extraction
an operation that accepts a value and stores it in an array variable
Storing
the process of arranging items of information into a desired form
Sorting
performs sorting by repeatedly comparing the neighboring element as the sorting process goes and any time it finds a larger element before a smaller element, it swaps the elements until the whole array is sorted.
Bubble Sort
Methods in Searching Algorithm:
☞ Sequential Search
☞ Binary Search
performs sorting by repeatedly putting the largest element in the unsorted portion of the array to the end of this unsorted portion until the whole array is sorted.
Selection Sort
process of finding a particular element (key) in an array
Searching
the list or array is traversed sequentially and every element is checked
Sequential Search
repeatedly target the center of the search structure and divide the search space in half
Binary Search
collection of variables that are referenced under one name, providing convenient means of keeping related information together
Structures
components of Structure Variables
Individual structure elements are referenced by using the . (“ dot”)