Chapter 23 Flashcards

1
Q

The best-time complexity for insertion sort is _____________.

		A.
O(1)
		B.
O(logn)
		C.
O(n)
		D.
O(nlogn)
		E.
O(n*n)
A

C.O(n)

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

The worst-time complexity for insertion sort is _____________.

		A.
O(1)
		B.
O(logn)
		C.
O(n)
		D.
O(nlogn)
		E.
O(n*n)
A

E.O(n*n)

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

Suppose a list is {2, 9, 5, 4, 8, 1}. After the first pass of bubble sort, the list becomes

		A.
2, 9, 5, 4, 8, 1
		B.
2, 9, 5, 4, 1, 8
		C.
2, 5, 9, 4, 8, 1
		D.
2, 5, 4, 8, 1, 9
		E.
2, 1, 5, 4, 8, 9
A

D.2, 5, 4, 8, 1, 9

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

The best-time complexity for bubble sort is
_____________.

		A.
O(1)
		B.
O(logn)
		C.
O(n)
		D.
O(nlogn)
		E.
O(n*n)
A

C.O(n)

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

The worst-time complexity for bubble sort is _____________.

		A.
O(1)
		B.
O(logn)
		C.
O(n)
		D.
O(nlogn)
		E.
O(n*n)
A

E.O(n*n)

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

The time to merge two sorted lists of size n is _________.

		A.
O(1)
		B.
O(logn)
		C.
O(n)
		D.
O(nlogn)
		E.
O(n*n)
A

C.O(n)

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

The worst-time complexity for merge sort is _________.

		A.
O(1)
		B.
O(logn)
		C.
O(n)
		D.
O(nlogn)
		E.
O(n*n)
A

D.O(nlogn)

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

The average-time complexity for merge sort is _________.

		A.
O(1)
		B.
O(logn)
		C.
O(n)
		D.
O(nlogn)
		E.
O(n*n)
A

D.O(nlogn)

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

Suppose you choose the first element as a pivot in the list {5 2 9 3 8 4 0 1 6 7}. Using the partition algorithm in the book, what is the new list after the partition?

		A.
5 2 9 3 8 4 0 1 6 7
		B.
4 2 3 0 1 5 6 7 9 8
		C.
4 2 1 3 0 5 8 9 6 7
		D.
2 3 4 0 1 5 9 8 6 7
		E.
2 3 4 0 1 5 6 7 8 9
A

C.

4 2 1 3 0 5 8 9 6 7

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

The worst-time complexity for quick sort is _________.

		A.
O(1)
		B.
O(logn)
		C.
O(n)
		D.
O(nlogn)
		E.
O(n*n)
A

E.O(n*n)

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

The average-time complexity for quick sort is _________.

		A.
O(1)
		B.
O(logn)
		C.
O(n)
		D.
O(nlogn)
		E.
O(n*n)
A

D.O(nlogn)

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

Using the partition algorithm to partition an array {5, 8, 10, 3, 4, 19, 2} for a quick sort, what is the resulting array after the partition?

		A.
{5, 8, 10, 3, 4, 19, 2}
		B.
{2, 3, 4, 5, 8, 10, 19}
		C.
{2, 3, 4, 5, 10, 19, 8}
		D.
{3, 2, 4, 5, 10, 19, 8}
		E.
{3, 2, 4, 5, 8, 10, 19}
A

D.{3, 2, 4, 5, 10, 19, 8}

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

To remove the root, you need to start a process by first placing _______ to the place of the root and move it down to maintain the heap property.

		A.
one of the root's children
		B.
the larger child of the root
		C.
the smaller child of the root
		D.
the last node in the heap
A

D.the last node in the heap

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

To add a new node, you need to start a process by first placing it as _______ and move it up to maintain the heap property.

		A.
the new root
		B.
the last node in the heap
		C.
the left child of the root
		D.
the right child of the root
A

B.the last node in the heap

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

A heap is represented using an array. Is the array {1 2 4 5 9 3} a heap?

	A. Yes
	B. No
A

B. No

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

A heap is represented using an array. Is the array {64 42 59 32 39 44} a heap?

	A. Yes
	B. No
A

A. Yes

17
Q

The worst-time complexity for heap sort is _________

		A.
O(1)
		B.
O(logn)
		C.
O(n)
		D.
O(nlogn)
		E.
O(n*n)
A

D.O(nlogn)

18
Q

The average-time complexity for heap sort is _________

		A.
O(1)
		B.
O(logn)
		C.
O(n)
		D.
O(nlogn)
		E.
O(n*n)
A

D.O(nlogn)

19
Q

Suppose a heap is stored in an array list as follows: {100, 55, 92, 23, 33, 81}. The parent of 81 is _______.

		A.
100
		B.
55
		C.
92
		D.
23
		E.
33
A

C.92

20
Q

Suppose a heap is stored in an array list as follows: {100, 55, 92, 23, 33, 81}. After inserting 103, what is the content of the array list?

		A.
{100, 55, 92, 23, 33, 81, 103}
		B.
{100, 55, 103, 23, 33, 92, 81}
		C.
{103, 55, 92, 23, 33, 81, 92}
		D.
{103, 55, 100, 23, 33, 81, 92}
		E.
{103, 55, 92, 23, 33, 81, 100}
A

D.{103, 55, 100, 23, 33, 81, 92}

21
Q

The most efficient algorithm for sorting integer keys is __________.

		A.
quick sort
		B.
merge sort
		C.
heap sort
		D.
radix sort
A

D.radix sort

22
Q

The __________ algorithm does not compare keys.

		A.
quick sort
		B.
merge sort
		C.
heap sort
		D.
radix sort
A

D.radix sort