Data Types and Structures COPY Flashcards

1
Q

Describe a 1D array

A

Data structure which contains as set of variables of the same data type
Position is stored using an integer index

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

What is a 2D array?

A

An array of arrays

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

What is the difference between an array and a linked list?

A

Array - items organised sequentially

Linked List - items organised sequentially, but each item contains a link to next item

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

Give two advantages of linked lists

A

Dynamic Data structure, can grow and shrink
Very flexible, order of items can be changed without moving data
More memory efficent

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

Give a disadvantage of a linked list

A

Not possible to identify a specific item directly using its index

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

Give an example of a dynamic data structure which linked lists are used to implement

A

Queues

Stacks

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

Why is it inefficient to to resize an array in the middle of execution?

A

Array has to be copied into new memory to accommodate the extra added items
Double array in memory

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

What is a stack?

A

A stack is a data structure which behaves like a vertical list
Elements can be added or deleted from the top of the stack
‘Last in, First out’

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

In what situation would a stack be useful?

A

Situation which calls for the most recent items to be accessed
Store code produced during compilation of high level languages
Intermediate results of calculations

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

If you have a stack overflow error on a computer what does this mean?

A

Program has attempted to place too many items on the stack

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

Describe a queue

A

1D array or list, items are inserted and retrieved at different ends
‘First in, First Out’

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

Identify three variables required for implementation of a stack

A

Stack Pointer
Maximum stack size
An array

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q

How can a 2D array be accessed?

A

Nested loops

Two fixed loops

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
14
Q

Describe a linked last

A

Dynamic data structure where data items have a link to the next item in the list

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
15
Q

Describe a record

A

Data structure consisting of several variables of different types

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
16
Q

Describe situations where queues are useful to implement

A
  • multiple printing jobs have to be processed
  • scheduling of tasks in a multitasking environment.
  • event-driven languages where events are placed in a queuing system to wait being processed
17
Q

What is a circular queue?

A

A queue which uses a system where only the start and end pointers move, allowing the array to behave as if its spaces were arranged in a circle.

18
Q

Where will a link to the last data item point to?

A

NULL

19
Q

How many pointers does a queue usually need?

A

2

20
Q

What is a dynamic data structure?

A

Data structure that can grow or shrink during execution

21
Q

What are two advantages of a 1D array over a 2D array?

A
  • Allows different data types

- More memory efficient if stored in suitable data type

22
Q

A call stack is a stack data structure used to keep track of the active subprograms.
Explain the role of a stack data structure in the execution of this search procedure

A
Whenever the search procedure is
called, it is added to the call stack
When the base case is reached, the
last procedure call added to the
stack is removed and value is
passed to the previous procedure
call. This repeats until the first
procedure call is reached and a
value is returned