Section 7: Data structures Flashcards
When searching for a value in a 2-D array table, would you start with columns or rows?
In a 2-D array table you start your search along the rows.
How does a tuple differ from an array?
Unlike an array, a tuple can have different data types. However, a tuple is immutable i.e. its elements can’t be changed.
What is a record?
A record is a way of storing data from a program permanently. It stores values in columns as a table.
What is an abstract data type?
An abstract data type is a data type that is created by the programmer rather than embedded in the language itself.
What are some examples of abstract data types?
Examples include queues, stacks, trees and graphs.
What is the basic dynamic of a queue?
The basic dynamic of a queue is First in First out.
Where can queues be used?
Examples of uses for queues:
- Keyboard
- Simulation e.g. simulating customers at a checkout
- Outputs waiting to be printed (stored as a queue on the disk)
What is a dynamic data structure?
A dynamic data structure refers to a collection of data in the memory that has the ability to shrink or grow in size.
What is heap?
Heap is a portion of memory from which space is allocated or de-allocated.
What is a static data structure?
A static data structure refers to a data structure that is fixed in size, meaning it cannot increase or decrease its memory allocation while the program is running.
What is a linked list?
A linked list is a dynamic data structure used to hold ordered data that may not be held in contiguous memory locations.
What is a stack?
A stack is a Last in First out data structure.
What are the main areas that a stack will be used?
A major use of stacks is to store information about the active subroutines while a program is running. This includes holding return addresses, parameters and local variables.
Is a stack a dynamic or static data structure?
A stack can be implemented as EITHER a dynamic data structure or a static data structure, depending on the preference of the programmer and the context in which it is being implemented.
What does the “peek()” operation do when applied to a stack?
The “peek()” operation returns the item at the top of the stack, but does not remove it from the stack.