Data Types, Data structures and algorithms 1.4 Flashcards
What data type should be used for storing a phone number?
String - if stored as an integer this would remove the zero at the start of the number
What is an Array?
An ordered, finite set of elements of a single type
How can you visualize a two-dimensional array?
A spreadsheet or table
How can you visualize a three-dimensional array?
A three dimensional array can be visualized as a multipage
What is a record?
A row in a file
What is a record made up of?
A record is made up of fields
What is the definition of a list?
A data structure consisting of a number of items. Items can appear more than once
What are the main differences between an array and a list?
- List can store data Non-contiguously whereas arrays store data in order
- List can store many data types
What is a tuple?
An immutable, ordered set of values of any type
What is the difference between a tuple and an array?
Tuples use normal brackets instead of square brackets
What is a linked list?
A linked list is a dynamic data structure used to hold an ordered set of items that are not stored in contiguous locations.
What is the name of an item in a linked list?
Nodes
What does each node in a linked list contain?
each node contains its data and the address of the next node
What is a stack?
A LIFO data structure where items can only be removed and added on the top of the stack
LIFO = Last in First out
Give an example of when a stack may be used
Back button in a web page
What is a queue?
A FIFO data structure where items are added to the back of the queue and removed from the front
FIFO = First in first out
What is a Tree?
A data structure with a root node and a child node connected with branches
What is the purpose of a binary search tree?
A binary search tree is used to search for values quickly
What is a Hash Table?
A hash table is an array which is coupled with a hash function. The hash function takes in data (a key) and releases an output (the hash). The role of the hash function is to map the key to an index in the hash table.
What is a collision? (hashing)
A collision is when two inputs result in the same hash value
What properties does a good hashing algorithm have?
- Low chance of collision
- Fast
What does the operation isEmpty() do?
Checks if the list is empty
What does the operation pop() do?
(Stack)
takes out the last item in the stack out
What does the operation Push(value) do?
(Stack)
It adds the value to the top of the stack
What does the operation peek() do?
(Stack)
Returns the top value of the stack
What does the operation isFull() do
(Stack)
Checks if the stack is full
What does the operation size() do
(stack)
Returns the size of the stack
What does the operation enQueue do
Add a item to the back of the queue
- What does the operation deQueue() do?
Removes the item from the end of the queue
Add questions of hash(maps)