Algorithms Flashcards

1
Q

What are the two ways of traversing a graph?

A

Breadth first and depth first

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

Whats the difference between depth first and breadth first

A

depth first - start at a node and go as far along the node before backtracking

breadth first - explore nodes that are the closest at first then moving onto nodes that are further away

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

What ways can you traverse a binary tree?

A

Pre-order, in-order and post-order

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

How do you do pre-order, in-order, and post-order

A

pre-order - visit a root, travel up the left subtree, then travel up the right subtree

in-order - traverse a tree by visiting the left subtree, the root and then the right subtree

post-order - travel up the left subtree, the right subtree and then the root

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

What is a binary search

A

split data n half repeatedly until data item is found

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

What is a binary tree search and how can you do it?

A

Binary tree search - traversing a binary tree until the item is found

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

What is reverse polish notation

A

it is postfix notation, where the operators are written after the operands.

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

What is the point of pre fix or postfix notation

A

it removes the need for using brackets

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

how can you evaluate RPN expressions

A

put everything on a stack

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

How do you get different __fix notations from a binary tree?

A

To get infix traverse the binary tree in order

to get postfix, traverse the tree in post order

to get prefix, traverse the binary tree using pre order

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

What is a bubble sort?

A

a sort method that works by repeatedly stepping through an array by comparing adjacent elements and swapping them if necessary.

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

What is a merge sort?

A

a sort where you split lists into single elements and merge them back together

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