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
What does each node on a tree have to have?
- sub-tree pointers that point to any subtrees for that node
- data accosted with that node
- pointers to other nodes at the same level
What is a binary tree?
- specific kind of tree, each node can only have two children
- each node contains; left and right pointers and data
What is preorder traversal of trees?
- start at root node
- traverse left sub-tree
- traverse right sub-tree
What is in-order tree traversal?
- Traverse the left sub tree
- visit the root node of the left
- traverse right sub tree
- visit root node of the right
What is post order tree traversal?
- traverse left sub tree
- traverse right sub tree
- return to root node
Why would we use pre and post order traversal?
- provide a means of writing expressions without needing brackets
- postorder traversal of a tree is one method of converting between infix (human syntax) and reverse polish
What is reverse polish? What is it good for?
- postorder (postfix) notation
- able to utilise the stack effectively when processing an expression
What is the processes of reverse polish?
- If the next symbol is an operand load it to the stack
- If the next symbol is an operator, pop the last two items off the stack, perform the operation and place the result in the stack
What is a graph?
- collection of data nodes and the connections between them
- nodes are referred to as vertices
- connections are edges
- edges can be directional (making a directed graph)
- if edges are bi-directional then its an undirected graph
- numbers represent measurements between then