Java - data structures Flashcards
primitive data types
data types from which more advanced data structures are made: include ints, doubles, longs, floats, shorts, booleans, and chars
Int
whole number (32 bits) - most commonly used
Float
decimal (32 bits)
Short
whole number (16 bits)
Long
whole number (64 bits)
Double
decimal (32 bits) - most commonly used
reference types
more complex data types
String
sequence of chars
array
a list that has both an index (number in the list) and data for what’s at that index
multidimensional array
an array of arrays – the data at the first index has an array, so the index therefore has two points (0,0). 0 for the first slot in the array, and then the next 0 represents the slot in the array for that data
jagged array
a multidimensional array where the number of columns is not fixed. some index positions might have an array of 5, the next an array of 20, the next just 1
resizable array
an array whose length you can change as needed
how do you search an array
for loop
Big O Notation
Describe the performance or complexity of an algorithm
O(1) time
consistent duration of algorithm execution in same time (or space) regardless of the size of the input. Also called constant time.
O(n) time
if the size of the input increases, the computation time directly increases in proportion to the input’s increase. Sample tasks would be for loops that have to look through everything.
common operations you might do with lists
access, update, insert, search, and delete
linked list
Like an array, but not necessarily contiguous. Uses pointers to refer to other list items. Doesn’t have to use contiguous locations in memory but can link to any memory slot. Just need a memory address, or rather the next pointer. You just indicate what is next and use that to sort your list.
Array class in Java
ArrayList class
Linked list class in Java
LinkedList class