Data Structure Flashcards
What is an attribute?
-Column in a table (like fields in databases)
How does a record store data?
- Stored by attribute
- Accessed by attribute
- Unordered
- Attributes and structure for record need to be set up in advance
- More friendly in use but more complex to set up
- Data can be modified added or deleted
What is a list?
- Ordered set of data organised by an index
- Data accessed through index value (starting at 0)
- Requires little or no set up
- Easier to set up but less user friendly in use
- Data can be modified added or deleted
What is a Tuple?
- Immutable list (cannot be changed once it is set up)
- structure exactly like a list
What is a 1D array?
- very similar to list but also has defined scope (number of elements)
- Defines a set of variables under a single descriptor with an index, names(0), names(1) etc etc
- can access and manipulate the data by its indexed address
What is a 2D array?
- Effectively a table
- data is referred to by its point in a table, (5,5)
- data is accessed by its point in a table
- Data can be altered
What is a 3D array?
-same as 1D and 2D but also has a third coordinate (X,Y,Z)
What is a stack?
- LIFO
- data added to (pushed) and removed from (popped) the top
- implemented using pointers. Pointer increases values when data added and decreases when data removed
- error message generated when stack full or empty
What is a Queues?
- FIFO
- Data does not move forward in the queue but two pointers ,start and end, track the data in the structure
- If item is popped from the queue the start pointer increases in value
- If item is pushed into the queue the end pointer increase in value
- A circular queue can be formed eg; when two locations are free (5 and 1) with 5 being the max location the next items will be added into 5 then 1
- If start pointer = end pointer error message should generate.
- If start pointer = 1 and end pointer = max error message should generate
What is a linked list?
- Allows us to store data on various criteria
- Does not modify data stored in memory (you can sort for certain things but it will not reposition these items in memory)
How does a linked list function?
- Uses pointers to point to the next item in a certain order
- end of list when pointer = 0
- possible to have more than one pointer at the same time
What is the free storage pointer?
-points to the first of these available spaces
How do you add data to a linked list?
1-Store data at the location indicated by free storage pointer
2-Alter the pointer to the next free storage space
3-ID where in the list the data should be inserted
4-set the pointer for the item that preceded it to the new data item
5-Update the pointer for the new data item to that previously stored in the item that preceded it
How do you remove items from linked lists?
- pointer in the preceding node is set to the value of the pointer in the item to be removed
- that value of the pointer in the item that has been removed will be added to the free pool
How do you traverse a linked list?
Algorithms in photos