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
insertion sort ___________- the relative order of elements with the same key
does not affect
26
Advantages of insertion sort
simple implementation, stability, good performance, simplicity, in-place and online nature
27
Disadvantages of insertion sort
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
The best-case scenario for insertion sort occurs when
the input array is already sorted or nearly sorted.
29
The average-case scenario for insertion sort assumes a
more random or unpredictable order of elements in the input array
30
The worst-case scenario for insertion sort occurs when the input array is
sorted in reverse order, meaning the elements are arranged in descending order
31
In this situation, insertion sort is the least efficient, as it requires a maximum number of comparisons and swaps.
sorted in reverse order
32
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)
BINARY INSERTION sort
33
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:)
BINARY INSERTION sort
34
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.
Recursive Insertion Sort
35
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
Insertion Sort on a linked list
36
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.
Double-Ended Insertion Sort: or Double Ended Queue
37
It can sort the elements as soon as it receives them.
insertion sort
38
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.
QuickSort
39
Quicksort, a widely used sorting algorithm, developed by
Tony Hoare in 1959
40
Tony Hoare later improved and published the algorithm in The __________ and an updated version in __________ in the Communications of the Association for Computing Machinery.
Computer Journal in 1962 ALGOL
41
contributed to the analysis of Quicksort, resolving pivot selection issues and deriving the expected number of comparisons and swaps.
Robert Sedgewick's
42
made further improvements to the algorithm, including a pivot scheme called "pseudomedian of nine"
Jon Bentley and Doug McIlroy
43
Quicksort compact partitioning scheme attributed to
Nico Lomuto.
44
developed an "AntiQuicksort" function that can intentionally make Quicksort perform poorly under specific conditions.
McIlroy
45
one of the most efficient sorting algorithms.
quicksort
46
is one of the most popular sorting algorithms that uses nlogn comparisons to sort an array of n elements in a typical situation.
Quicksort
47
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 _._______
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
Partition is done recursively on __________ of the pivot after it is placed in its correct position.
each side
49
Advantages quicksort
Efficiency In-place sorting Good for Random Data
50
Disadvantages quicksort
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
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
merge sort
52
s a recursive algorithm that continuously splits the array in half until it cannot be divided
merge sort
53
APPLICATIONS OF MERGE SORT:
sorting large datasets external sorting custom sorting
54
ADVANTAGES OF MERGE SORT
stability guaranteed worst case performance parallelizable
55
disadvantages merge sort
space complexity not in place not always optimal for small datasets
56
works by examining each set of adjacent elements in the string, from left to right, switching their positions if they are out of order.
bubble sort
57
Bubble sort advantages
Simplicity, No Additional Memory, Stable Sort
58
bubble sorrt disadvantages
Poor Performance, No Benefit from the Presorted Data, Not Suitable for Modern Applications