unit 7 Flashcards

1
Q

what is an array?

A

an array is an ordered static set of elements that can only store data type

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

what is a 2D array?

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

what is a record?

A

a row in a file made up of fields

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

what is a list?

A

a dynamic data structure that consists of a number of items where the items can occur more than once
they can contain elements of different data types

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

what are the operations in a list?

A

isEmpty()
append(value)
remove(value)
length()
index(value)
insert(p,v)
pop()

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

what is a tuple?

A

a tuple is an ordered set of values of any type
immutable = cannot be changed, after creation

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

what is a linked list?

A

a dynamic data structure that is used to hold an ordered sequence
items do not have to be in contiguous data locations
each item is a node which contains a data field alongside another address is called a pointer

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

how does a linked list work?

A

data field contains the value of the actual data
pointer field contains the address of the next item in the list
linked lists also store the index of the first item as a pointer
also store a pointer identifying the index of the next available space

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

what are the steps to traverse a linked list?

A

check if list is empty
start at the node the pointer is pointing to
output the item at the current node
follow the pointer to the next node repeating through each node
when the pointer field is empty it means the end of the linked list has been reached

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

how do you add a node in a linked list?

A

check if there is space to insert data
add the new value to the end of the linked list and update the next pointer

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

how do you remove a node in a linked list?

A

update the pointer field of the item pointing to the node you want to delete
it should point to the node after the deleted node
the node pointing from the deleted node to the next node is then ignored (this wastes memory)

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

what is a stack?

A

LIFO data structure
items only added or removed from the top of the stack
static ds

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

what are the operations in a stack?

A

isEmpty()
push(value)
peek()
pop()
size()
isFull()

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

how does a stack use pointers?

A

uses a pointer to point to the top of the stack where the next piece of data will be added or current is removed
pointer then + 1

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

what is stack overflow?

A

attempt to push an item onto a full stack

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

what is stack underflow?

A

attempt to remove an item from an empty stack
pointer then - 1

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

what is a queue?

A

a FIFO data structure
items are added to the end and removed from the front

18
Q

how does a queue work?

A

has a front and rear pointer
track the position of the front and back of the queue

19
Q

what are the 3 types of queue?

A

linear
circular
priority

20
Q

what are the operations in a queue?

A

enQueue(value)
deQueue()
peek()
isEmpty()
isFull()

21
Q

what are linear queues?

A

a data structure that consists of an array
items added to the next available space in the queue starting from the front

22
Q

what are circular queues?

A

a static array that has a fixed capacity
space is freed up at the start of the array
reuses empty slots at the front as the rear pointer wraps round to point to the start

23
Q

what is a graph?

A

a set of nodes that are connected by edges

24
Q

what are the different types of graphs?

A

directed
undirected
weighted

25
what is a weighted graph?
edges can only be traversed in 1 direction
26
what is an undirected graph?
the edges can be traversed in both directions
27
what is a weighted graph?
a value is attached to each edge
28
how can graphs be represented?
by an adjacency matrix or an adjacency list
29
what are some applications of graphs?
social networks transport networks operating systems
30
what is a tree?
a connected, undirected graph which have a root node
31
what is a leaf?
a node with no children
32
what is a subtree?
a subsection of a tree consisting of a parent and all the children of a parent
33
what is a root?
a single node which does not have any incoming nodes
34
what are trees used for?
managing structures store routing tables speed up searching
35
what is a binary tree?
a rooted tree where every node has a maximum of 2 child nodes
36
what is a hash table?
an associative array which is coupled with a hash function which takes data in and releases an output
37
what is a hash function?
a function that maps the key to an index in a hash table
38
what is a collision?
when the hash function generates the same hash value for two or more inputs
39
why are hash tables used for indexing?
provide fast access to data due to keys having unique 1-1 relationships with the address at which they are stored
40
what are the ways to deal with collisions?
linear probing and chaining
41
what is linear probing?
data is placed in the next free position in the hash table can probe sequentially or use an interval like every 3rd slot
42
what is chaining?
using linked lists store a pointer to a location where the data is stored each data item is stored as a node with key value, data, pointer to next node