Chapter 11 Flashcards

1
Q

What Q(n) time algorithm do

A

Normally, a Q (n) time algorithm would make a single or perhaps a constant number of passes of the data set.

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

Array of objects sort on which attribute

A

the key value

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

What are slow O(n2) sorting algorithms

A

Bubble sort, Insertion sort, Selection sort

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

What is bubble sort

A

Scan the array. Whenever two consecutive items are found that are out of order, swap them. Repeat until all consecutive items are in order.

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

What is insertion sort

A

Assume that A[1..i - 1] have already been sorted. Insert A [i] into its proper position in this sub array. Create this position by shifting all larger elements to the right.

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

What is Selection sort

A

The selection sort is a combination of searching and sorting. During each pass, the unsorted element with the smallest (or largest) value is moved to its proper position in the array. The number of times the sort passes through the array is one less than the number of items in the array.

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

What is the worst case of running of Bubble sort, Insertion sort, Selection sort

A

Q(n2)

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

What are 3 methods of sorting in O(n log n) time

A

Merge sort
Heap sort
Quick sort

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

What is heap

A

A heap is a left-complete binary tree that confirms to the heap order. The parent node has key smaller than or equal to both of its children nodes.

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

What is max heap

A

in a max heap, the parent has a key larger than or equal both of its children Thus the smallest key is in the root in a min heap; in the max heap, the largest is in the root.

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

Does heap use pointer

A

No

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

Which order traversal is used in heap tree

A

level-order traversal

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

What arithmetic operation is required to access left node in heap tree

A

returns 2i

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

What arithmetic operation is required to access right node in heap tree

A

returns 2i + 1

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

What arithmetic operation is required to access parent node in heap tree

A

returns bi/2c

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

What is the position of root in array of heap

A

1