Unit 4 Flashcards

1
Q

Determine the median of the values in this list:

[23, 42, 1, 17, 24, 38, 15, 19]

A

21

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

What is quick select, and how does it differ from quick sort (in terms of approach and complexity)?

A

Quick select is a divide-and-conquer algorithm.

It uses the same overall approach as quick sort (choosing one item in a list as a pivot and partitioning the list into two based on that pivot, so that one partition has values that are less than the pivot and the other partition has values that are greater than or equal to the pivot).

However, instead of recursing into both partitions, as in quick sort, quick select only recurses into one partition – the one with the item that is being searched for. This reduces the average complexity from O(n log n) (in quick sort) to O(n) (in quick select).

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

Given an alphabet {A, C, G, T} and a target string {GACCTGCT}, calculate a shift table.

A

A = 7

C = 2

G = 3

T = 1

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

Given a string of {ABCCAB}, calculate its prefix table.

A

[0, 0, 0, 0, 1, 2]

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

How is data in a hash table stored?

A

Data in a hash table is stored in a number of slots.

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

What is mid-square an example of?

A

Mid-square is an example of a hash function.

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

Draw a tree showing the correct outcome when the numbers [22, 13, 10, 34, 12, 50] are inserted into an empty binary search tree in the given order.

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

Draw the updated AVL tree after the node with a key of 1 is deleted.

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

Complete the following table, regarding the attached trees:

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

Assuming a hash table with 23 slots, using the folding method, with 2 as the size of each part, what would be the hash value of the item 1459862903?

A

7

  1. Split the item 1459862903 into groups of two (14 59 86 29 03)
  2. Add these groups together, to give 191
  3. Divide this number by the number of slots - 191 / 23 = 8, with a remainder of 7
  4. The remainder is the hash value
How well did you know this?
1
Not at all
2
3
4
5
Perfectly