2.3.1 Algorithms Flashcards

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

What are the sorting algorithms we’ve learned? (4)

A

Bubble sort (1) insertion sort (1) merge sort (1) Quick sort (1)

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

What are the searching algorithms we’ve learned? (2)

A

Binary search (1) Linear search (1)

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

What is the precondition for a binary search? (1)

A

Data must be in order (1)

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

Which sorting algorithm uses divide and conquer? (2)

A

Merge sort (1)
Quick sort (1)

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

What are the different Big O notation categories? (5)

A

Constant - O(1) (1) linear O(n) (1) polynomial - O(n^2) (1) Exponential - O(2^n) (1) Logarithmic - O(log n) (1)

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

What is the time complexity of bubble and insertion sort? (1)

A

Polynomial - O(n^2)

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

What is the time complexity of merge sort? (1)

A

O(n log n)

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

What is the time complexity of quick sort? (1)

A

Polynomial - O(n^2)

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

What is the time complexity of a linear search? (1)

A

Linear - O(n)

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

What is the time complexity of a binary search? (1)

A

Logarithmic - O(log n)

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

What are the key features of a stack data structure? (4)

A

Last in first out (LIFO) (1) It has an array to store data (1) with a pointer to show the top of the stack (1) items are added to the top using the pointer (1) items are removed from the top using the pointer (1)

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

What are the key features of a queue data structure? (4)

A

First in first out (FIFO) (1) It has an array to store data (1) with a pointer for the head and tail (1) items are removed from the front using head (1) items are added to the rear using tail (1)

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

What are the key features of a tree data structure? (4)

A

1 directional data structure (1) Has a root node with no incoming edges (1) branch nodes with incoming and outgoing edges (1) leaf nodes with incoming edges only (1) unweighted (1) dynamic (1)

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

What are the key features of a binary tree data structure? (4)

A

Each node has maximum 2 outgoing edges (1) data lower in the sequence goes left (1) data higher in the sequence goes right (1) has a root branches and leaves (1)

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

What are the pointers in a linked list? (2)

A

head or headpointer points to the start of the list (1) next free or freelistpointer points to the first free space (1)

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

What is a linked list? (3)

A

A dynamic data structure (1) each node consists of data and pointer (1) pointer gives location of next node (1)

17
Q

What is depth first traversal? (4)

A

Depth first goes to left child node when it can (1) if there is no left child node it goes to right child node (1) if there are no child nodes to visit it backtracks to the parent node (1) uses a stack to order nodes (1)

18
Q

What is breadth first traversal? (3)

A

Breadth first visits all nodes directly connected to start node (1) then visits all nodes directly connected to each of those nodes (1) uses a queue to order nodes. (1)

19
Q

How do you traverse a binary tree in order? (3)

A

Visit the left node (1) then read the data (1) then visit the right node (1)

20
Q

How do you traverse a binary tree in pre-order? (3)

A

Read the data (1) then visit the left node (1) then visit the right node (1)

21
Q

How do you traverse a binary tree in post-order? (3)

A

Visit the left node (1) then visit the right node (1) then read the data (1)

22
Q

Describe a Merge Sort (5)

A

Splits the list in half repeatedly until it is in independent arrays(1) Compare the first two items and combine to create a new array (1) Repeat for the other indexes (1) and then compare the first elements in the first two new arrays choose the largest (decesing order) or smallest (ascending order) writing them into the new array first and reapeat till no elements are left.(1) Combine 2 remaining lists into one list.(5)

23
Q

Describe a Bubble Sort (5)

A

Compare each adjacent pair elements(1) If they are not in the correct order then swap the elements(1) If in correct order do not swap(1) When you read the array return to start and repeat for n elements times(1) Set a Flag to false whenever swap is made and repeat loop if flag is not false.(1)

24
Q

Describe Insertion sort (3)

A

One item at a time(1) Moved into correct position(1) Until all items in list are checked (1)

25
Q

Describe Quick Sort (5)

A

Choose a pivot OR identify start and end pointers (1) Compare each element to the pivot OR compares start and end pointers (1) Put item < pivot in left sublist and items > pivot in the right sublist (1) Choose a pivot in each sublist(1) If start pointer is larger than end pointer then swap them around(1) Repeat the process until each item becomes a pivot(1)

26
Q

State Purpose Of Big O Notation(1)

A

Either One: Evaluate the complexity of the algorithms (1) Show how the time / memory / resources increase as the data size increases (1) Evaluate worst case scenario for the algorithms

27
Q
A
28
Q
A