Data Structures Flashcards

You may prefer our related Brainscape-certified flashcards:
1
Q

What is a data structure?

A

A way of organising data in a computer so it can be accessed / modified

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

List the data structures you need to know for the exam

A

Stack, Queue, Graph, Hash Table, Dictionary

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

What is an array?

A

An array is an indexed set of related elements, it allows you to store a finite number of items of the same data type under a common name.

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

What are the limitations of arrays?

A

They must store the same data type

They are a static data structure

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

What is a static data structure?

A

Where the data structure cannot change in size once it’s been declared

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

When is a record data structure used?

A

Is used when you want to group together a collection of related fields under a single name

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

What is an advantage of records?

A

They can contain different data types

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

What are the 3 steps to creating a record?

A

Define the record, what fields will be in the record
Declare a variable or an array to use
Assign and retrieve data from the variable record

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

What are lists and tuples and what type of brackets do they use?

A

They are pythons versions of arrays, lists use square brackets, tuples use round brackets

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

What are tuples?

A

Tuples are immutable - they can’t be changed once created

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

What are lists?

A

Lists are mutable - they can be edited after creation

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

Explain the circumstances in which it would be more

appropriate to use an adjacency list instead of an adjacency matrix.

A
  • When graph is sparse
  • When edges rarely changed;
  • When presence/absence of specific edges does not need to be tested frequently
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q

State one reason why the graph shown in Figure 1 is not a tree.

A

It contains a cycle / cycles

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

The graph in Figure 1 is a weighted graph. Explain what is meant by a weighted graph.

A

A graph where each edge has a weight/value associated with it

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

What are files composed of?

A

A file is made up of records which are composed of a number of fields.

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

What index do arrays/lists start from?

A

They start from 0

17
Q

Explain two differences between static and dynamic data structures

A
  • Static data structures can waste storage space, where as dynamic data structures only take up the storage required for the actual data
  • Static data structures have a fixed size whereas dynamic data structures can change size
18
Q

Why is the static implementation less efficient at inserting new items into the list than the dynamic implementation

A
  • It’s not possible to insert items into the middle of the list, so all the items that come after that item must be moved down.
  • This is time consuming than the dynamic implementation
19
Q

How is dynamic data structure implementation achieved

A

By adjusting pointers when a new item is inserted

20
Q

How could a static data structure be implemented?

A

As an ordered list using fixed size array

21
Q

How could a dynamic data structure be implemented?

A

As a linked list using dynamic memory allocation