Sorting Flashcards

1
Q

is an efficient sorting technique based on the >heap data structure.

A

heap sort

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

is a nearly-complete binary tree where the parent node could either be minimum
or maximum.

A

The
heap

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

The heap with minimum root node is called ______- and the root node
with maximum root node is called __________

A

min heap

max heap

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

Build a binary heap from the input array.

A

Build heap

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

Extract the maximum element
from the heap and add it to the sorted region.

A

extract maximum

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

Heapify the remaining elements of the heap
to maintain the heap property.

A

Heapify

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

The time complexity of heap sort is

A

O(n log n)

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

Heap sort is a __________
sorting algorithm, meaning it preserves the relative order of
elements with equal keys.

A

stable

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

can be used to efficiently implement priority queues because
they allow us to insert, delete, and find the element with the highest priority in
logarithmic time.

A

Heap operations

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

a process of creating a heap from an array.

A

heapify

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

process to insert an element in existing heap time complexity
O(log N).

A

Insertion:

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

deleting the top element of the heap or the highest priority
element, and then organizing the heap and returning the element with time
complexity O(log N).

A

Deletion:

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

to check or find the most prior element in the heap, (max or min
element for max and min heap).

A

Peek:

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

The most popular kind of heap sort, arranges the elements of

the array in ascending order.

A

Max heap sort:

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

With a _____________, the array is arranged in ascending order.

A

Min heap sort:

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

a simple sorting algorithm that builds the final
sorted array one item at a time by comparisons.

A

insertion sort

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

It is much less
efficient on large lists than more advanced algorithms such as
quicksort, heapsort, or merge sort.

A

insertion sort

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

t iterates, consuming one input element each repetition,
and grows a sorted output list. At each iteration, it
removes one element from the input data, finds the location it
belongs within the sorted list, and inserts it there

A

insertion sort

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

Insertion sort is also ___________-, i.e., it
is appropriate for data sets that are ___________. Lastly,
it is an___________sorting algorithm and a _____________ sorting algorithm.

A

Insertion sort is also adaptive in nature, i.e., it
is appropriate for data sets that are already partially sorted. Lastly,
it is an in-place sorting algorithm and a stable sorting algorithm.

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

insertion sort best average, worst case time complexity

A

O(n)

O(n^2)

O(n^2)

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

It is efficient for small data sets or nearly sorted
data

A

insertion sort

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

is adaptive in nature, i.e. it is
appropriate for data sets that are already
partially sorted

A

Insertion sort

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

insertion sort memory space

A

constant amount of additional memory space

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

It works well with data sets that have been sorted
in a significant way.

A

insertion sort

25
Q

insertion sort ___________- the relative order of elements
with the same key

A

does not affect

26
Q

Advantages of insertion sort

A

simple implementation, stability, good
performance, simplicity, in-place and online
nature

27
Q

Disadvantages of insertion sort

A

inefficiency on large data sets

its
worst-case time complexity of O(n’2),

and its
modest memory usage

not efficient with
repeated elements,

lacks scalability,

and has limited
parallelization potential

28
Q

The best-case scenario for
insertion sort occurs when

A

the
input array is already sorted or
nearly sorted.

29
Q

The average-case scenario for
insertion sort assumes a

A

more
random or unpredictable order
of elements in the input array

30
Q

The worst-case scenario for
insertion sort occurs when the
input array is

A

sorted in reverse
order, meaning the elements are
arranged in descending order

31
Q

In
this situation, insertion sort is
the least efficient, as it requires
a maximum number of
comparisons and swaps.

A

sorted in reverse
order

32
Q

is a sorting algorithm which is similar to the insertion
sort, but instead of using linear search to find the location where an element
should be inserted, we use binary search. Thus, we reduce the comparative
value of inserting a single element from O (N) to O (log N)

A

BINARY INSERTION sort

33
Q

It is a flexible algorithm, which means it works faster when the same given
members are already heavily sorted, i.e., the current location of the feature
is closer to its actual location in the sorted list (Variant of insertion sort:)

A

BINARY INSERTION sort

34
Q

is a variation of the traditional Insertion
Sort algorithm that uses recursion to sort an array or list of
elements. It shares the same basic principle with regular Insertion
Sort, which involves dividing the list into a sorted and an unsorted
part, but it uses a recursive function to achieve this rather than a
loop.

A

Recursive Insertion Sort

35
Q

sorting algorithm that is used to sort
the elements of a linked list in a specific order, typically in ascending or
descending order. Instead of using array indices like in the traditional
insertion sort for arrays, this variant of the algorithm operates on the
linked structure by repeatedly removing nodes from the original list and
inserting them into their correct position in a new, sorted linked list

A

Insertion Sort on a linked list

36
Q

is also a Queue
data structure in which the insertion and deletion operations are
performed at both the ends (front and rear). That means, we can insert
at both front and rear positions and can delete from both front and rear
positions. This variation works from both ends of the array
simultaneously. It compares and swaps elements at both ends, reducing
the number of shifts or swaps in some cases.

A

Double-Ended Insertion Sort: or Double Ended Queue

37
Q

It can sort the elements as soon as it receives them.

A

insertion sort

38
Q

is a sorting algorithm based on the divide and conquer algorithm that picks an element as a pivot and partitions the given array around the picked pivot by placing the pivot in its correct position in the sorted array.

A

QuickSort

39
Q

Quicksort, a widely used sorting algorithm, developed by

A

Tony Hoare in 1959

40
Q

Tony Hoare later improved and published the algorithm in The __________ and an updated version in __________ in the Communications of the Association for Computing Machinery.

A

Computer Journal in 1962

ALGOL

41
Q

contributed to the analysis of Quicksort, resolving pivot selection issues and deriving the expected number of comparisons and swaps.

A

Robert Sedgewick’s

42
Q

made further improvements to the algorithm, including a pivot scheme called “pseudomedian of nine”

A

Jon Bentley and Doug McIlroy

43
Q

Quicksort compact partitioning scheme attributed to

A

Nico Lomuto.

44
Q

developed an “AntiQuicksort” function that can intentionally make Quicksort perform poorly under specific conditions.

A

McIlroy

45
Q

one of the most efficient sorting algorithms.

A

quicksort

46
Q

is one of the most popular sorting algorithms that uses nlogn comparisons to sort an array of n elements in a typical situation.

A

Quicksort

47
Q

The key process in quicksort is a __________ which targets to place the chosen ________ at its correct position in the sorted array and put all the smaller elements to the ______- of the pivot and all greater elements on the _._______

A

The key process in quicksort is a partition() which targets to place the chosen pivot at its correct position in the sorted array and put all the smaller elements to the left of the pivot and all greater elements on the right.

48
Q

Partition is done recursively on __________ of the pivot after it is placed in its correct position.

A

each side

49
Q

Advantages quicksort

A

Efficiency

In-place sorting

Good for Random Data

50
Q

Disadvantages quicksort

A

unstable

worst-case time complexity

requires careful pivot selection

performance degradation with sorted data

suboptimal performance for equal elements

difficult to implement for non-comparable data

complexity in implementation

51
Q

defined as a sorting algorithm that works by dividing an array
into smaller subarrays, sorting each subarray, and then merging
the sorted subarrays back together to form the final sorted array

A

merge sort

52
Q

s a recursive algorithm that continuously splits
the array in half until it cannot be divided

A

merge sort

53
Q

APPLICATIONS OF
MERGE SORT:

A

sorting large datasets

external sorting

custom sorting

54
Q

ADVANTAGES OF
MERGE SORT

A

stability

guaranteed worst case performance

parallelizable

55
Q

disadvantages merge sort

A

space complexity

not in place

not always optimal for small datasets

56
Q

works by examining each set of adjacent
elements in the string, from left to right, switching their
positions if they are out of order.

A

bubble sort

57
Q

Bubble sort advantages

A

Simplicity, No Additional Memory, Stable
Sort

58
Q

bubble sorrt disadvantages

A

Poor Performance, No Benefit from the
Presorted Data, Not Suitable for Modern
Applications