1.4.2 Flashcards
Data structures (12 cards)
1
Q
Linear data structures
A
-arrays
-lists
-stacks
-queues
-hash table
2
Q
Non linear data structures
A
-graphs
-trees
-binary search
3
Q
Records
A
- A row in a file or table
- Widely used in databases
- Made up of fields
4
Q
Lists
A
- A number of items
- Items can occur more than once
- Data can be of more than one data type
5
Q
Tuples
A
- An ordered set of values
- Cannot be changed once initialised
- Initialised with regular rather than square brackets
6
Q
Arrays
A
- An ordered set of elements, each of the same type.
- A 1D array is like a list.
- A 2D array is like a table.
- A 3D array is like a multi page spreadsheet.
- 2D arrays are searched first by the rows and then the columns.
7
Q
Linked Lists
A
- Dynamic data structure.
- Stores an ordered list.
- Contents need not be in contiguous data locations.
- Items are called nodes.
- Each node contains a data field and a link or pointer field.
- The data field contains the data itself.
- The pointer field contains the address of the next item.
8
Q
Graphs
A
- Notes connected by edges or arcs.
- Directed graphs allow edges to be traversed in one direction only.
- Undirected graphs allow edges to be traversed in both directions.
- Weighted graphs attach a cost to each arc.
- Implemented using an adjacency list or adjacency matrix.
- Adjacency matrix - easy to add nodes and to work with.
- Adjacency list - space efficient.
9
Q
Stacks
A
- Last in first out
- Items can only be added or removed from the top
- Used for back or undo buttons
- Can be dynamic or static structure
10
Q
Queues
A
- First in first out data structure
- Items are added at the beginning and removed at the end
- Used in printers and keyboards
- Linear queue with items added into the next space
- Space inefficient
- Uses pointers at the front and back
- Circular queues have a rear pointer that can loop back to the beginning to use empty space.
11
Q
Stacks operations
A
- isEmpty() - Checks if the stack is empty
- push(value) - Adds a new value to the top of the stack
- peek() - Returns the top value of the stack
- pop() - Returns and removes the top value of the stack
- size() - Returns the size of the stack
- isFull() - Checks if the stack is full
12
Q
Queues operations
A
- enQueue(value) - Adds a new item at the end of the queue
- deQueue() - Removes the item at the end of the queue
- isEmpty() - Checks if the queue if empty
- isFull() - Checks if the queue is full