MIDTERM TOPICS Flashcards

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

refers to rearrangement of a given array or list of elements according to a comparison operator on the elements.

A

Sorting

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

Sorting Terminology:

A

In-place Sorting
Internal Sorting
External Sorting
Stable sorting
Unstable sorting

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

uses constant space for producing the output (modifies the given array only) or copying elements to a temporary storage

A

In-place Sorting

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

is when all the data is placed in the main memory or internal memory

A

Internal Sorting

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

is when all the data that needs to be sorted cannot be placed in memory at a time

A

External Sorting

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

when two same items appear in the same order in sorted data as in the original array

A

Stable sorting

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

When two same data appear in the different order in sorted data

A

Unstable sorting

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

Characteristics of Sorting Algorithms

A

Time Complexity
Auxiliary Space
Stability
In-Place Sorting
Adaptivity

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

a measure of how long it takes to run an algorithm, is used to categorize sorting algorithms

A

Time Complexity

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

This is the amount of extra space (apart from input array) needed to sort

A

Auxiliary Space

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

A sorting algorithm is said to be stable if the relative order of equal elements is preserved after sorting

A

Stability

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
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

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

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

A

Adaptivity

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

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
16
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

A

Searching Algorithms

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

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

A

Data management

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
18
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
19
Q

Sorting is used to prepare data for training machine learning models

A

Machine learning

20
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

21
Q

Sorting algorithms are used in __ ___ for tasks like task scheduling, memory management, and file system organization.

A

operating systems

22
Q

is a simple and efficient sorting algorithm that works by repeatedly selecting the smallest (or largest) element from the unsorted portion of the list and moving it to the sorted portion of the list.

A

Selection sort

23
Q

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

A

Merge Sort

24
Q

divide a problem into subproblems. When the solution to each subproblem is ready, we ‘combine’ the results from the subproblems to solve the main problem.

A

Divide and Conquer

25
repeatedly divides the array into two halves until we reach a stage where we try to perform
MergeSort Algorithm
26
Given a list, take the current element and exchange it with the smallest element on the right hand side of the current element
Selection Sort
27
Given a list, take the current element and insert it at the appropriate position of the list, adjusting the list every time you insert. It is similar to arranging the cards in a Card game.
Insertion Sort
28
Time Complexity of selection sort is always
n(n - 1)/2
29
is a fundamental concept in computer science used for storing and managing data in a specific order. It follows the principle of “First in, First out” (FIFO), where the first element added to the queue is the first one to be removed.
Queue Data Structure
30
It operates like a line where elements are added at one end (rear) and removed from the other end (front).
First-In-First-Out (FIFO)
31
Basic Operations of Queue Data Structure
Enqueue (Insert) Dequeue (Delete) Peek Empty Full size
32
Adds an element to the rear of the queue
Enqueue (Insert)
33
Removes and returns the element from the front of the queue.
Dequeue (Delete)
34
Returns the element at the front of the queue without removing it
Peek
35
Checks if the queue is empty.
Empty
36
Checks if the queue is full.
Full
37
This operation returns the size of the queue i.e. the total number of elements it contains
size
38
Applications of Queue
Task scheduling Data transfer Simulation Priority queues
39
Implementation of Queues
Array Linked List
40
is the index up to which the elements are stored in the array including the rear index itself.
rear
41
is the index of the first element of the array
front
42
is a comparison-based sorting technique based on Binary Heap Data Structure. It can be seen as an optimization over selection sort where we first find the max (or min) element and swap it with the last (or first).
Heap sort
43
convert the array into a max heap
heapify
44
is defined as a type of Heap Data Structure in which each internal node is greater than or equal to its children.
Max-Heap
45
Advantages of Heap Sort
Efficient Time Complexity Memory Usage Simplicity
46
Disadvantages of Heap Sort
Costly Unstable Inefficient