Algorithm Flashcards

1
Q

Stability

A

A stable sorting algorithm ensures that elements with identical sorting properties still maintain their original order.

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

Space

A

An in-place algorithm does not need to initialise a new array to store the elements in sorted order. All sorting happens within the original array.

An out-of-place algorithm initialises a new array for storing sorted elements. The new array is returned, and the original array discarded.

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

Time complexity

A

time complexity describes how time taken increases as input size grows
Does not include actual time taken

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

time complexity of algorithms

A

Bubble/Insertion SortO(n2)
Merge Sort O(n log n)
Quick Sort Worst case O(n2) O(n log n)

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

Abstraction

A

Abstraction means that the details of implementation are hidden; the end-user only has to know what input is required, and what output to expect.

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

Encapsulation

A

Encapsulation means that data and methods that act on the data are bundled into objects

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

Advantages of encapsulation 4

A

makes the data and methods more easier to import into other programs

associates attribute names with objects, allowing the same names to be reused in other objects/in the global space (minimises name collision)

organises the code into logical units (objects), making the code easier to understand

Prevents inadvertent data modification of private variables from public program codes

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

Inheritance

A

A way of reusing code of existing objects and to establish a subtype from an existing object

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

Advantages of iheritance

A

superclass used to define/establish features that are required by all subclasses

allows existing code to be reused instead of reimplementing for each class,saving time and memory space

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

Polymorphism

A

Two classes that exhibit polymorphism behave the same way by having the same interface, allowing them to be used interchangeably, even if their implementation is different.

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

Advantages of polymorphism

A

This allows the main program to support multiple client instances with the same method names/with the same code, minimises duplication of code

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

Class

A

a blueprint or template that describes the data/attributes and methods to create an object

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

Object

A

An instance of a class with a particular set of associated variables and functions

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

Static and class methods

A

A method that does not have access to its instance inside the method

A method that does not have access to its instance but has access to the class inside the method

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

Variable

A

Variable is a label in the program pointing to a data object

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

Function

A

Function is a predefined set of instructions that can involve one or more input and return zero or more output

17
Q

class diagram

A

lmao