Data structure Flashcards
name data structures
any type of array, such as arrays, arrays of records, 2D/3D arrays
Algorithms
procedure to solve a problem, any code that does something is an algorithm
priming read
setting the initial condition using a read statement
such as having the value determined outside of a loop by having user enter value and if stays the same unless its incorrect/needs to be changed
binary search
has to be in numbered order (ascending)
divides the data set by 2 and checks if the value is greater than or lower than the middle value
continues doing that until number is found
linear search
doesnt have to be in numerical order
is usually slower than binary for large data sets
just does through the data linearly to find out answer
bubble sort
Repeatedly steps through the input list element by element, comparing the current element with the one after it, swapping their values if needed.
basically compares elements with the one next to it and swaps if they need to be depending on the sort (ascending descending)
insertion sort
has a complete side and an incomplete side.
builds the final sorted array one item at a time by comparisons. It is much less efficient on large lists
selection sort
an effective and efficient sort algorithm based on comparison operations. It adds one element in each iteration. You need to select the smallest element in the array and move it to the beginning of the array by swapping with the front element.
multidimensional arrays, 2d/3d
2d array is an array that has 2 variables and is like a table, you give coordinates to find a value e.g. array(2,3)
3d array is the same as 2d array but there is another additional dimension so there will be 3 coordinates to give to find a value e.g. array(2,3,5)
array of records
array of records is an array that has multiple different arrays that can have diff data types as a normal array cannot have different data types. e.g. you can store customer birth date, firstname, phone number in the same array by using a record
sequential file
one in which the individual records can only be accessed sequentially, that is, in the same order as they were originally written to the file. New records are always added to the end of the file.
sequential file has be be accessed in a certain order
relative file
a file in which each record is identified by its ordinal position in the file (record 1, record 2 and so on). This means that records can be accessed randomly as well as sequentially: For sequential access, simply execute a READ or WRITE statement to access the next record in the file.
relative file can be accessed in any order, can edit anything in file
local variable
a variable that only gets effected locally and doesn’t have a value outside the loop/module also declared within the loop/module
global variable
value is declared outside loop/module and gets effected throughout the program so that the whole system can use that value
ebnf
()
|
{}
value shown without <>
<variable>
</variable>
() - groups terms
{} - loop 0 or more repetitions
<variable> - the terms that go with the variable are defined elsewhere
without <> - literal, write value as seen
| - OR
| - OR
</variable>