Fs Of Data Structures Flashcards

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

What are the 4 categories for data types?

A

Strong types
Static types
Dynamic types
Abstract types

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

Define strong data types.

A

Standard data types; integer, character etc. They’re the basis for all other types, and a fixed amount of memory is defined.

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

Define static data types?

A

Those that require a fixed amount of memory, such as arrays and sets. But are not included in the pre-defined data types.

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

Define dynamic data types?

A

Those that may be expanded given the limitation of the memory. For example files and pointers.

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

What are abstract data types

A

Abstract means they don’t usually exist as a pre-built data structure but instead must be manually built. Such as stacks and queues.

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

What structure does a stack have?

A

LIFO (last in first out)

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

What sort of structure does a queue have?

A

FIFO (First in first out)

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

What are the 3 commands used in stacks?

A
Pushing = adding an item
Popping = taking an item off
Peeking = finds the start (bottom) of the stack
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

What happens to the pointer as an item is pushed or popped?

A

When an item is popped the pointer moves down.

When an item is pushed the pointer moves up.

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

What are stack overflow and underflow errors?

A

Overflow - When an item is pushed onto a full stack.

Underflow - When an item is popped from an empty stack.

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

What is an advantage and disadvantage of implementing a queue as an array.

A

Advantage - faster and more memory efficient than a linked list.
Disadvantage - fixed size

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

What is an advantage and disadvantage to implementing a queue as a linked list?

A

Advantage - Dynamic size. Means no wasted memory.

Disadvantage - Not as memory efficient as an array. Requires more memory per element.

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

What operations are needed in a queue?

A
Add item 
Remove item 
Front item
Is queue empty
Is queue full
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
14
Q

What are the 3 types of queue?

A

Linear queue
Circular queue
Priority queue

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

Define a linear queue.

A

A queue with a fixed amount of memory. Usually implemented using a 1D array. Items added to the back and removed from the front, memory can not be re-used.

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

Define a circular queue.

A

A queue with a fixed amount of memory.
The back of is connected to the front.
Memory can be re-used.
This is often used to store data waiting to be transferred from one device to another.

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

Define a priority queue.

A

Elements in the queue are ordered into levels of priority.

18
Q

What are vertices in a graph?

A

Objects in the graph (represented by a circle)

19
Q

What is an edge in a graph?

A

A connection between two vertices (or nodes)

20
Q

What does neighbour mean (graphs)?

A

A vertex connected to another vertex via an edge is a neighbour.

21
Q

What is the degree of a vertex (graphs)?

A

The number of neighbours it has.

22
Q

What are some uses of graphs?

A
Mapping 
Game theory 
Electrical circuits 
Social networks 
The internet
23
Q

What are undirected graphs?

A

Graphs without arrows (direction)

24
Q

What is a weighted/labelled graph?

A

A graph with values attached to edges (usually numerical)

25
Q

What is a directed graph?

A

A diagram with arrows (direction)

26
Q

What is a graph?

A

A graph is an abstract data type used to model the relationship between 2 or more vertices.

27
Q

What are the two ways of storing a graph of a computer?

A

Adjacency lists

Adjacency matrices

28
Q

How do adjacency lists work?

A

By recording the relationship between all relevant vertices.

Only records vertices with edges between them.

29
Q

What are all separate values separated by on an adjacency list?

A

;

For example: D,15; H,10; C,20

30
Q

What is an advantage and disadvantage of an adjacency list?

A

Advantage - Good for graphs with fewer edges than nodes.

Disadvantage- Bad for graphs with more edges than nodes.

31
Q

How do adjacency matrices work?

A

By recording the relationship between vertices in 2D array or grid populated with 1s or 0s.
An adjacency matrix also records when there isn’t an edge between vertices.

32
Q

What is an advantage and disadvantage of an adjacency matrix?

A

Advantage - Good for graphs with more edges than nodes.

Disadvantage - Bad for graphs with less edges than nodes.

33
Q

Adjacency List vs matrix?

A

List:
Stores data only when there is edge = less memory.
Has to check if adjacencies exist = more time.
Quicker for sparse graphs.

Matrix:
Stores data for every combination = more memory
Because of ^ easier to ID adjacencies = less time
Quicker for dense graphs

34
Q

What is a tree?

A

An abstract data structure with a structure similar to a graph but with a hierarchical structure.

35
Q

How does a tree differ from a graph?

A

It has a hierarchical structure.
It is undirected.
It has no loops.

36
Q

What is a rooted tree?

A

A tree with one vertex designed as the root in which all other vertices spread out from.

37
Q

How do you construct a binary tree?

A
  1. Create a root node
  2. Insert data into root node
  3. Compare new item with root node
  4. If it’s > root follow the right pointer otherwise follow the left
  5. Compare until left of right pointer is null
  6. Create node, insert right and left pointers and set them to null
  7. Connect the node to the tree
38
Q

What methods can be used to traverse a tree?

A

Breadth first

Depth first

39
Q

What methods can be used to traverse a tree?

A
Breadth first
Depth first
Pre-order
In-order
Post-order
40
Q

What are the four CRUD operations?

A

Create
Retrieve
Update
Delete

41
Q

What are the four CRUD operations in their SQL and HTTP method format?

A

(SQL , HTTP):

INSERT , POST
SELECT , GET
UPDATE , PUT
DELETE , DELETE

42
Q

What is a priority queue and how does it work?

A

It has different points at which items can join according to priority.
They join at the back of their priority section.
If there are no items in correct priority section they join the front of the next lower section.