Lesson 2 (MIDTERM) Flashcards

(29 cards)

1
Q

is used to rearrange a given array or list of elements according to a comparison operator on the elements.

A

Sorting Algorithm

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

is used to decide the new order of elements in the respective data structure

A

Comparison Operator

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

What are the applications of sorting algorithms

A

Searching Algorithms
Data Management
Database Optimization
Machine Learning
Data Analysis
Operating Systems

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

Sorting is often a crucial step in search algorithms like binary search and ternary search. A lot of Greedy Algorithms use sorting as a first step to apply Greedy Approach. For example Activity Selection, Fractional Knapsack, Weighted Job Scheduling, etc.

A

Searching Algorithms

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

Sorting data makes it easier to search, retrieve, and analyze. For example the order by operations in SQL queries requires sorting

A

Data Management

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

Sorting data in databases improves query performance. We preprocess the data by sorting so that efficient searching can be applied

A

Database Optimization

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

Sorting is used to prepare data for training machine learning models

A

Machine Learning

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

Sorting helps in identifying patterns, trends, and outliers in datasets. It plays a vital role in statistical analysis, financial modeling, and other data-driven fields

A

Data Analysis

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

Sorting algorithms are used in operating systems for tasks like task scheduling, memory management, and file system organizations

A

Operating Systems

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

Types of Sorting Algorithms

A

Bubble Sort
Insertion Sort
Selection Sort
Merge Sort
Quick Sort
Heap Sort
Bogo Sort

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

Repeatedly compares and swaps adjacent elements if they are in the wrong order. SImple but inefficient for large data (O(n2))

A

Bubble Sort

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

Builds the sorted array one item at a time by inserting each element into its proper position. Efficient for small or nearly sorted data

A

Insertion Sort

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

Selects the smallest (or largest) element and places it in the correct position, Easy to understand but always O(n2).

A

Selection Sort

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

Divides the array into halves, recursively sors each half, and merges them. Efficient and stable with O(n log n)

A

Merge Sort

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

Pick a pivot element, partitions the array, and sorts each partition recursively. Very fast in practice, average case O(n log n)

A

Quick Sort

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

Builds a binary heap from the data, then repeatedly extracts the maximum (or minimum). Good worst-case performance (O(n log n))

17
Q

Randomly shuffles the array until it becomes sorted. Highly inefficient and used mostly for teaching or fun. Average time complexity is O(n!)

18
Q

What are the Characteristics of Sorting?

A

Time Complexity
Space Complexity
Stability
In-Place Sorting
Adaptivity

19
Q

a measure of how long it takes to run an algorithm, is used to categorize sorting algorithms. The worst-case, average-case, and the best-case performance of a sorting algorithm can be used to quantify the time complexity of the process

A

Time Complexity

20
Q

Which is the amount of memory required to execute the algorithm

A

Space Complexity

21
Q

A sorting algorithm is said to be stable if the relative order of equal elements is preserved after sorting. This is important in certain applications where the original order of equal elements must be maintained

22
Q

is one that does not require additional memory to sort the data. This is important when the available memory is limited or when the data cannot be moved.

A

In-Place Sorting

23
Q

is one that takes advantage of pre-existing order in the data to improve performance

24
Q

What are the Time Complexities

A

O(1) Constant Time
O(log n) Logarithmic Time
O(n) Linear Time
O(n log n) Linearithmic Time
O(n^2) Quadratic Time

25
This means no matter how big your list is, the algorithm takes about the same amount of time
O(1) Constant Time
26
The algorithm gets faster relative to the amount of work it avoids by cutting the problem in half each step
O(log n) Logarithmic Time
27
The algorithm has to look at each item once, so the total time increases proportionally with the number of items
O(n) Linear Time
28
The algorithm does a little bit of extra work for each item, often by splitting the problem into smaller parts, solving each, and then combining them
O(n log n) Linearithmic Time
29
The algorithm has to compare every item with every other item, so the work grows much faster than number of items
O(n^2) Quadratic Time