Topic 1.1 - Data Structures Flashcards
What is a data structure?
A data structure is a store of a group of related items
What is an array?
It is a data store where:
- All the data is of the same type
- Elements accessed via an index
- Has a predetermined size
What is a record?
A record is a set of data items which are all related to one entity
What is a stack?
It is a data store in the form of a linear list where the list items added are the first items to be removed
- Uses a stack pointer is a small register that stores the address of the last program request in a stack
Give an example of where a stack is used
- Stacks are used to store subprogram return addresses
- Good when using reverse polish notation
What is a queue?
A queue is a data structure where data can only be added to the end of it and is then retrieved from the front of the queue
- A queue has two queue pointers, one for the front and one for the rear
What is a binary tree?
Trees are a large store of data and are quick to search through but needs to be balanced to be efficient
- Each node has a left and a right pointer which points to items either greater or less than it
- The first node is known as the root node
What is pre-order, in-order and post-order
- Pre-order is when you first meet a node
- In-order is when you travel under a node (this is the correct order of the data)
- Post-order is when you’ve visited both of that nodes children
What is a linked list?
Has a logical order which is different to its physical order (data items can be anywhere in memory)
- Each item in the list is composed of two parts, data and a pointer to the next item to the list
What’s a benefit and dis-advantage of using a linked list?
- New items can be added anywhere in the list
- Saves on memory if programmed dynamically
- Complex to program
- Only accessed in a linear fashion
Give an example of where a queue would be used
- Download buffer
- Keyboard buffer
Why’s it bad for a binary tree to be unbalanced?
An unbalanced binary tree can significantly increases the number of comparisons to be made when searching through the tree.
What is hashing?
Hashing uses is the mod function to store different items of data in a table according to its remainder. If a data collision occurs, it goes into the overflow area.
- Random access file where physical location is calculated using the hashing algorithm.
- Known as Direct Acess
Give an advantage and disadvantage of hashing
- Equally fast access to any record in the file
- Addresses may not be unique leading to collisions which reduces the efficiency of the solution.
- SOLUTION, create a new, larger hashing table
What is the top/first item in a binary tree known as?
The root node