Topic Two- Data Structures Flashcards

1
Q

What is an abstract data structure?

A

Abstract data structures don’t exist as data structures in their own right, instead they make use of other data structures such as arrays to form a new way of storing data.

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

What is a Queue?

A

A queue is an abstract data structure based on an array. Just like a queue at a bus stop,the first item added to a queue is the first to be removed. Because of this, queues are referred to as “first in, first out” (or FIFO) abstract data structures.

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

When is a Queue used?

A

In keyboard buffers in computers, when each keypress is pressed, it is added to the queue and then removed once the computer has processed this. This means that the keys will appear in the order they were pressed.
The breadth-first search algorithm also uses a queue.

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

What is a priority Queue?

A

In a priority queue, items are assigned a priority. Items with the highest priority are dequeued before low-priority items. In the case that two or more items have the same priority, the items are removed in the usual first-in, first-out order.

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

When is a priority Queue used?

A

Processors assign priority to applications - Applications currently in use by the user are prioritised over background applications, allowing for a faster user experience.

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

Operation of a stack

A

A stack is a first in, last out (FILO) abstract data structure. Like queues, stacks are often based on an array but have just one pointer: a top pointer. Operations that can be performed on a stack include Push (add an item), Pop (remove the item at the top) and Peek. Peek is a function which returns the value of the item at the top of the stack without actually removing the item. The functions IsFull and IsEmpty can also be executed on stacks, just like with a queue.

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

Advantages and Disadvantages of an adjacency matrix in comparison to an adjacency list.

A

matrix:
-Allows a specific edge to be queried quickly as you just have to look up the row and column
- Well suited to dense graphs where there are lots of connections so it is not memory inefficient as usually you would be wasting space if you use this as there would be many empty spaces.

list:
-Memory efficient, only stores the edges that exist in the graphs
-Slow to query as each item in the list must be searched sequentially until the desired edge is found so it is time inefficient

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

What is a graph and when is it used?

A

It is used to portray complex relationships between data sets. it could be used when representing networks like transport networks, IT networks, and the Internet. It consists of nodes/vertices (the circles) and edges. the edges may have a weighting (a number) which will represent something (e.g. in a map the weightings could represent the distance between two cities.

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

What is a tree?

A

A tree is a connected, undirected graph with no cycles

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

What is a rooted tree?

A

It is where the tree starts from a root node (one node) and travels down. It progresses as root node, parent node, child node(nodes with a parent), and leaf node (child node with no children).

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

What is a binary tree?

A

A rooted tree in which the parent node has no more than two child nodes.

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

What can rooted trees be used for?

A

Can be used to represent family trees or file systems on a computers hard drive

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

What are the three ways to traverse a binary tree?

A
  • Pre order- Visit the root then traverse the left subtree , then the right subtree
  • In-order: Traverse the left subtree, visit the root then traverse the right subtree.
    Post-order: Traverse the left subtree then the right subtree then visit the root .
    In order, pre-order and post order refer to when the root is visited
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
14
Q

What is a binary search tree? How is it done?

A

A BST holds items in a way that the tree can be searched quickly and easily for a particular item. Nodes are added in the order given with the first item at the root. Starting ay the root each time, the node is added to the left or the right depending on its value (if it is larger than the root- the right) Apply the same rule to the root of each subtree.

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

How to do Vector Addition?

A

The vector sum (a+b) is found by relocating b so that the head touches the tail. Add vectors by adding x and y parts separately. Addition is like translation as it is the shifting of the vector.

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

Scalar multiplication

A

Multiplying a vector by a scalar value changes the magnitude of the vector. Multiply x and y by the scalar value.

17
Q

Describe three ways to represent a vector

A
  • A list
  • a function
    -A point in space
18
Q

What is the convex combination of two vectors?

A

The space bounded by the two vectors and the red line. It is an expression of the form ( w= alpha u + beta v)
where alpha and beta must always be smaller than 0 and alpha and beta must add up to give 1.

19
Q

What is dot product?

A

A method for multiplying two vectors , written using a dot. Multiply the corresponding components of each vector.

20
Q

Uses of dot product

A
  • One vector contains unit prices and another contains numbers sold then dot product gives the amount of money taken. Or it can be used to find the angle between two vectors.
21
Q
A
22
Q

Describe the principles of operation of a hash table.

A

A hashing algorithm takes an input and returns a hash that corresponds to the location in memory where the value should be stored. The value is then stored alongside the key.

23
Q
A
24
Q
A
25
Q
A
26
Q
A
27
Q
A
28
Q
A
29
Q
A
30
Q
A
31
Q
A
32
Q
A