Fundamentals of Data Structures Flashcards

1
Q

What is an array

A

An array is an indexed set of elements. An array must be finite, indexed and must only contain elements with the same data types.

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. Queues are FIFO abstract data structures (First in First out)

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

What is a Linear Queue

A

A linear queue has two pointers, a front pointer and a rear pointer. The queue is full if there are no available positions on or after the rear pointer.

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

What is a Circular Queue

A

A circular queue is a queue in which the front and rear pointers can move over the two ends of the queue, making for a more memory efficient data structure.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
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. If two items have the same priority, FIFO is used.

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

Name 3 operations that can be performed on a queue

A

Enqueue

Dequeue

IsEmpty

IsFull

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

What is a stack

A

A stack is a FILO (first in last out) abstract data structure. Stacks have just one pointer, a top pointer.

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

Name 3 operations that can be performed on a stack

A

Push
Pop
PeekIsFull
IsEmpty

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

What is a stack overflow error

A

When you attempt to add an item to a stack with no available spaces

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

What is a stack underflow error

A

When you attempt to pop an item from an empty stack

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

What is a graph

A

A graph is an abstract data structure used to represent complex relationships between items within datasets. A graph consists of nodes (vertices) which are joined by edges (arcs).

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

What is the difference between a graph and a weighted graph.

A

A weighted graph is one in which edges are assigned a value, representing a value such as time, distance, cost, etc.

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

What is an Adjacency Matrix

A

An adjacency matric is a tabular representation of a graph, each of the nodes in the graph is assigned both a row and a column in the table, a 1 is used to show an edge exists between 2 nodes and a 0 indicates that there is no connection. (if the graph is weighted, use the weight instead of 1, and infinity instead of 0)

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

What is an Adjacency List

A

Rather than using a table to represent a graph, a list can be used. For each node in the graph, a list of adjacent nodes is created, this means that only existing connections are stored, which is more memory efficient.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
15
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
16
Q

What is a rooted tree

A

a rooted tree has a root node from which all the other nodes stem. When displayed as a diagram, the root node is usually at the top of the tree. Nodes with children are called parent nodes, nodes with a parent are called child nodes, and nodes with no children are called leaf nodes.

17
Q

What is a binary tree

A

A binary tree is a rooted tree in which each parent node has no more than two child nodes.

18
Q

What is a Hash Table

A

hash tables are a way of storing data that allows data to be retrieved with a constant time complexity of O(1). A hashing algorithm takes an input and returns a unique irreversible hash. The has is used as an index in the hash table which stores key-value pairs.

19
Q

How do you deal with collisions in a hash table

A

There are many techniques to deal with collisions, one is to keep on moving to the next position until an available one is found.

20
Q

What is a dictionary

A

A dictionary is a collection of key-value pairs in which the value is accessed by its associated key.

21
Q

What is Convex combination of two vectors.

A

If you have two vectors, a and b, then a convex combination of the two would be ax + by where x and y are both non-zero numbers less than 1 that add to 1

22
Q

What is the dot product of two vectors

A

The dot product is a single number derived from the components of two vectors that can be used to determine the angle between them.

23
Q

What is the difference between a static and dynamic data structure.

A

Static data structures have a fixed size (stores items as a series of sequential memory locations) whereas dynamic data structures can be any size, instead of being stored sequentially, each item is stored alongside a reference to where the next item is stored. The advantage to dynamic structures is the dynamic size, however a downside is that they require more work on the part of the computer to set up and use.

24
Q

Define “Abstract data structure”

A

Data structures that dont exist as data structures in their own right, by make use of other data structures to form a new way of storing data.

25
Q

Which are best suited to dense graphs, adjacency matrices or adjacency lists

A

adjacency matrices are better for dense graphs, adjacency lists are better for sparse graphs.