Chapter 15 Flashcards

1
Q

What is stable sorting

A

Unlike unstable sorting, If there are duplicate keys in data set then after sorting the duplicate keys order will be the same as before. And also the data associated with keys maintain its key value pair position.

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

Does bubble sort, selection sort and insertion sort are in-place sorting algorithm

A

Yes

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

Which sorting algorithm is stable and which sorting algorithm unstable by nature

A

Bubble sort
Insertion sort
are stable algorithm but
Selection sort is unstable algorithm

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

Does mergesort stable and in-place algorithm

A

Merge sort is a stable algorithm but not in-place algorithm.

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

Does quicksort stable and in-place algorithm

A

Quicksort is not stable but an in-place algorithm

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

Does heapsort stable and in-place algorithm

A

Heapsort is not stable but an in-place algorithm

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

Does comparison based algorithm always n log n

A

Yes

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

What is in-place algorithm

A

In computer science, an in-place algorithm is an algorithm which transforms input using no auxiliary data structure. The input is usually overwritten by the output as the algorithm executes. It requires 2 arrays one is origin and other is target.

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

What is T(n)

A

Running time

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

What is Stirling’s approximation

A

Stirling’s approximation (or Stirling’s formula) is an approximation for factorials. It is a good-quality approximation, leading to accurate results even for small values of n.

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

Is it possible to sort without making comparison

A

Yes

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

What is linear time sorting

A

There are sorting algorithms that run faster than O(n lg n) time but they require special assumptions about the input sequence to be sort. Examples of sorting algorithms that run in linear time are counting sort, radix sort and bucket sort.

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

What is counting sort

A

Recall that the rank of an item is the number of elements that are less than or equal to. Once we know the ranks, we simply copy numbers to their final position in an output array.

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

If k is theta(n) then counting sort is an theta(n) time algorithm. True/False

A

True

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