2 - Fundamentals of Data Structures Flashcards

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

Explain the differences between static and dynamic data structures.

A

Static data structures have fixed maximum size, whereas the size of dynamic data structures can change.

Static data structures also typically store data in consecutive memory locations whereas dynamic structures typically do not.

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

Explain why a static implementation of a priority queue is less efficient than a dynamic implementation.

A

The items that come after the new item must be moved down in the array and moving items is time consuming.

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

Why is a circular queue often a better choice of data structure than a shuffling linear queue?

A

Items in a linear queue are all shuffled forward when an item is deleted from the front of the queue, whereas items don’t need to shuffle forward in a circular queue. This makes circular queues more time efficient when removing an item.

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

What is the difference between an abstract data type and a data stucture?

A

An abstract data type is a theoretical description of a way of organising data, with particular features and access restrictions.

A data structure is a concrete realisation of an abstract data type in code.

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

What are the advantages and disadvantages of dynamic data structures over static data structures?

A

Advantages:
• No wasted memory
• Can grow as more data is added to the data structure
• Resources only allocated as they are needed

Disadvantages:
• Additional memory needed for pointers
• Can result in memory leak
• Can take longer to access an item directly

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

Describe the steps involved in adding an item to a linear queue that has been implemented as a static data structure using an array.

A

Check that the queue is not already full, if it isn’t, then add 1 to the value of the rear pointer then add the new item to the position in the array indicated by the rear pointer.

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

Describe the steps involved when adding an item to a priority queue, implemented as a static data structure using an array, that are not required when adding an item to a linear queue.

A

Starting with the item at the rear of the queue, move each item back one place in the array until find an item with the same or higher priority than the new item. Then add the new item in the position before that item.

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

What is a graph?

A

A graph is a collection of vertices and a collection of edges connecting these vertices.

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

What is a weighted graph?

A

A graph with a weight associated with each edge.

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

What is a vertex/node?

A

An object in a graph.

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

What is an edge/arc?

A

A line representing a connection between two vertices in a graph.

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

What is a directed graph?

A

A graph where the edges have a direction.

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

What is an undirected graph?

A

A graph where no edges have a direction.

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

What is a tree?

A

A connected, undirected graph with no cycles.

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

What are the main operations that can be performed on a stack and what do they do?

A
  • Push - adds an element to the top of the stack
  • Pop - removes an element from the top of the stack and returns it
  • Peek - returns a copy of the element from the top of the stack
  • Is Empty - Checks whether the stack is empty
  • Is Full - Checks whether a stack is at maximum capacity
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
16
Q

What are the main operations that can be performed on a queue and what do they do?

A
  • Enqueue - adds an element to the back of the queue
  • Dequeue - removes the element at the front of the queue and returns it
  • Is Empty - checks whether the queue is empty
  • Is full - checks whether the queue is at maximum capacity
17
Q

What is a queue?

A

A queue is an abstract data type that holds an ordered, linear sequence of items. It is a first in first out (FIFO) structure.

18
Q

What is a stack?

A

A stack is an abstract data type that holds an ordered, linear sequence of items. It is a last in first out (LIFO) structure.

19
Q

What is a disadvantage of an array implementation of a queue?

A
  • Memory wasted when not full

* Size is limited by array size