# Data Structures Flashcards Preview

## Paper 1 - Computer Science > Data Structures > Flashcards

Flashcards in Data Structures Deck (21)
1
Q

What is a data structure?

A

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

2
Q

List the data structures you need to know for the exam

A

Stack, Queue, Graph, Hash Table, Dictionary

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.

4
Q

What are the limitations of arrays?

A

They must store the same data type

They are a static data structure

5
Q

What is a static data structure?

A

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

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

7
Q

What is an advantage of records?

A

They can contain different data types

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

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

10
Q

What are tuples?

A

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

11
Q

What are lists?

A

Lists are mutable - they can be edited after creation

12
Q

Explain the circumstances in which it would be more

A
• When graph is sparse
• When edges rarely changed;
• When presence/absence of specific edges does not need to be tested frequently
13
Q

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

A

It contains a cycle / cycles

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

15
Q

What are files composed of?

A

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

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