Data structures Flashcards
1
Q
- How to find an element in a 2D array?
A
- To find an element in a 2D arrays you look at first the row, then the column
2
Q
- How to find an element in a 3D array?
A
- To find an element in a 3D arrays you look at the number array (z), the row (y), and then the column(x)
3
Q
- What is a record?
A
- A record is referred as a row in a file and it is made up of fields, commonly used in databases
4
Q
- How is a record declared?
A
- A record is declared in the following way:
fighterDataType = record
integer ID
String
FirstName
Surname
End record
5
Q
- How are list values stored in terms of order?
A
- List values are stored non-contiguously, i.e. not stored next to each other in memory
6
Q
- How many datatypes can a list contain?
A
- List can contain values of more than one datatype
7
Q
- What is a tuple?
A
- A tuple is an immutable object composed of an ordered set of values of any type
8
Q
- What is a stack?
A
- A stack is LIFO data structure, where items can be only added or removed from the top of the stack, that is pointed by a pointer.
9
Q
- What is a stack used for?
A
- A stack is used to reverse an action, such as go back to a webpage in a web browser
10
Q
- How are stacks implemented?
A
- Stacks are implemented using a pointer which points to the top of the stack where the next data will be inserted
11
Q
- Show the code for push(value)
A
- Push(value) –> adds a value, but checks if stack is full before pushing
12
Q
- Show the code for peek()
A
- Peek() –> returns the value at the top of the stack, first checks if stack is empty
13
Q
- Show the code for pop() for a stack
A
- Pop() –> removes and returns the value at the top of the stack, first checks if the stack is empty by looking at the value of the top pointer
14
Q
- Function to show that stack is full?
A
- isFull()
15
Q
- Function to show that stack is empty?
A
- isEmpty()
16
Q
- Function to show that stack’s size ?
A
- Size()
17
Q
- What is an overflow?
A
- Trying to push on to a full stack is an overflow
18
Q
- What is an underflow?
A
- If you try to pop on an empty stack then it is an underflow
19
Q
- What is a queue?
A
- A queue is a FIFO data structure, commonly used in printers, keyboards, and simulators