Module 5: Sorting Algorithms

0.0(0)
studied byStudied by 0 people
learnLearn
examPractice Test
spaced repetitionSpaced Repetition
heart puzzleMatch
flashcardsFlashcards
Card Sorting

1/49

encourage image

There's no tags or description

Looks like no tags are added yet.

Study Analytics
Name
Mastery
Learn
Test
Matching
Spaced

No study sessions yet.

50 Terms

1
New cards

Sorting

_______ is a basic building block that many other algorithms are built upon.

2
New cards

Sorting

_______ is one of the most thoroughly studied algorithms in computer science.

3
New cards

Searching, Selection, Duplicates, Distribution

These range of problems are done much faster if the list is sorted.

4
New cards

Selection

For example, finding the kth-largest or smallest value, or finding the median value of the list, is much easier when the values are in ascending or descending order

5
New cards

Distribution

For example, finding the element that appears most or least often is relatively straightforward with a sorted list

6
New cards

time, space

The efficiency of any sorting algorithm is determined by the ____ complexity and _____ complexity of the algorithm.

7
New cards

Time complexity

_______ refers to the time taken by an algorithm to complete its execution with respect to the size of the input.

8
New cards

O

Big-O notation

9
New cards

Ω

Omega notation

10
New cards

Θ

Theta notation

11
New cards

Space complexity, auxiliary memory, input

_______ refers to the total amount of memory used by the algorithm for a complete execution. It includes both the ______ and the _____.

12
New cards

auxiliary memory

The _______ is the additional space occupied by the algorithm apart from the input data.

13
New cards

auxiliary memory

Usually, _______ is considered for calculating the space complexity of an algorithm.

14
New cards

Bubble sort
Selection sort
Insertion sort
Shell sort
Quick sort
Merge sort
Heap sort
Counting sort
Radix sort

Different Sorting Algorithms

15
New cards

Bubble sort

_____ is one of the most straightforward sorting algorithms.

16
New cards

Bubble sort

_____ is a simple sorting algortihm that works by repeatedly stepping through the list, comparing adjacent elements, and swapping them if they are in the wrong order.

17
New cards

largest

Bubble sort’s name comes from the way the algorithm works: With every new pass, the _____ element in the list “bubbles up” toward its correct position.

18
New cards

Bubble sort

______ consists of making multiple passes through a list, comparing elements one by one, and swapping adjacent items that are out of order.

19
New cards

Selection sort

_______ is a sorting algorithm that selects the smallest element from an unsorted list in each iteration and places that element at the beginning of the unsorted list.

20
New cards

minimum, beginning

The selection sort algorithm sorts an array by repeatedly finding the _____ element (considering ascending order) from unsorted part and putting it at the ______.

21
New cards

insertion sort

Like bubble sort, the______ algorithm is straightforward to implement and understand

22
New cards

Insertion sort

it builds the sorted list one element at a time by comparing each item with the rest of the list and inserting it into its correct position

23
New cards

small

Basically, Insertion sort is efficient for ____ data values

24
New cards

adaptive

Insertion sort is _____ in nature, i.e. it is appropriate for data sets which are already partially sorted.

25
New cards

first, second

In insertion sort, the ____ element in the array is assumed to be sorted. Take the ____ element and store it separately in key.

26
New cards

Shell sort

It is a sorting algorithm that is an extended version of insertion sort.

27
New cards

insertion

Shell sort has improved the average time complexity of _____ sort.

28
New cards

comparison-based, in-place sorting

Shell sort, similar to insertion sort, is a ______ and _______ algorithm

29
New cards

Shell sort

It allows the movement and swapping of far-away elements as well.

30
New cards

Shell sort, interval

______ first sorts the elements that are far away from each other, then it subsequently reduces the gap between them. This gap is called as _____

31
New cards

Quick sort

_______ is a sorting algorithm based on the divide and conquer approach

32
New cards

Quick sort

_____ is a highly efficient sorting algorithm and is based on partitioning of array of data into smaller arrays.

33
New cards

O(n2)

Quick sort partitions an array and then calls itself recursively twice to sort the two resulting subarrays. This algorithm is quite efficient for large-sized data sets as its average and worst-case complexity are _____, respectively

34
New cards

Merge Sort

______ is one of the most popular sorting algorithms that is based on the principle of Divide and Conquer Algorithm.

35
New cards

Ο(n log n)

Merge sort is a sorting technique based on divide and conquer technique. With worst-case time complexity being _____, it is one of the most respected algorithms

36
New cards

Merge sort

______ first divides the array into equal halves and then combines them in a sorted manner

37
New cards

Divide and Conquer technique

Using the ________, we divide a problem into sub-problems. When the solution to each sub-problem is ready, we 'combine' the results from the sub-problems to solve the main problem

38
New cards

Heap sort, arrays, trees

______ is a popular and efficient sorting algorithm in computer programming. Learning how to write the heap sort algorithm requires knowledge of two types of data structures - _____ and _____

39
New cards

heap

Heap sort works by visualizing the elements of the array as a special kind of complete binary tree called a _____

40
New cards

heap, sorted

The concept of heap sort is to eliminate the elements one by one from the ____ part of the list, and then insert them into the ____ part of the list.

41
New cards

in-place

Heap sort is the _____ sorting algorithm

42
New cards

complete, two, last, left

A heap is a _____ binary tree, and the binary tree is a tree in which the node can have the utmost ___ children. A complete binary tree is a binary tree in which all the levels except the ____ level, i.e., leaf node, should be completely filled, and all the nodes should be ___-justified

43
New cards

insertion, merge

The heap sort algorithm is the combination of two other sorting algorithms: _____ sort and _____ sort.

44
New cards

constant

Heap sort’s similarities with insertion sort include that only a _____ number of array elements are stored outside the input array at any time

45
New cards

O(n log n)

The time complexity of the heap sort algorithm is _____, similar to merge sort

46
New cards

Counting sort

______ is a sorting technique that is based on the keys between specific ranges

47
New cards

Counting sort

This sorting technique doesn't perform sorting by comparing elements. It performs sorting by counting objects having distinct key values like hashing

48
New cards

range, number of objects to be sorted, negative

Counting sort is effective when ____ is not greater than _______. It can be used to sort the _____ input values

49
New cards

Radix sort

______ is the linear sorting algorithm that is used for integers

50
New cards

digit by digit, least, most

In Radix sort, _____ sorting is performed that is started from the ____ significant digit to the ____ significant digit.