Fundamentals of Algorithms Flashcards

You may prefer our related Brainscape-certified flashcards:
1
Q

Understand and explain the term algorithm

A

An algorithm is a sequence of steps that can be followed to complete a task

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

Understand and explain the term decomposition

A

Breaking a problem into a number of sub-problems, so that each sub- problem accomplishes an identifiable task, which might itself be further subdivided

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

Understand and explain the term abstraction

A

the process of removing unnecessary detail from a problem

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

Understand and explain how the linear search algorithm works.

A

Goes through the list checking each element until it has found a match

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

Understand and explain how the binary search algorithm works.

A

Continues dividing list into 2 until element is found. Has to be in order

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

Understand and explain how bubble sort works.

A

Swaps the elements until they are in order

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

Understand and explain how merge sort works.

A

DIVIDE, CONQUER AND COMBINE

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

Advantages and disadvantages of the searches

A

Linear is much more simpler but binary is more efficient. Linear can be used on any type of list, even unordered, usually smaller ones. Binary can only be used on ordered lists, takes fewer steps so can be used on larger lists

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

Compare and contrast merge sort and bubble sort algorithms

A

Bubble sort: Easily implemented on a computer, efficient way to check if list is already in order. Doesn’t use much memory.
Inefficient way to sort a list, does not cope well with a very large list.
Merge sort: More efficient and quicker than bubble sort for large lists, very consistent running time.
Slower than other algorithms for smaller lists, uses more memory

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

Understand the concept of a data type

A

A means of classifying different data. Determines what operations can be conducted and how the data will be stored.

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

What is casting?

A

Changing the data type

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

What is a sequence, iteration and selection?

A

Sequence - all lines executed
Selection - decisions made that determine the execution
Iteration - code repeated until specified conditions met

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

What is a variable?

A

References to locations in the memory containing single values

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

What is a constant?

A

Identifier that are associated with values that remain fixed during the programs execution

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

Why are constants and variables used?

A

They are easier to read by making the code more clear. and have a better ability to update as you only need to update the initial value once

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

What is a subprogram?

A

An “out of line” block of code that performs a specific task

17
Q

Advantages of subprogram

A

Saves time when there is a pattern in a codecan be either user-written or pre-existing

18
Q

What is a local variable?

A

Variables that are only declared inside a function and are local to that subroutine

19
Q

Explain why it is good practice to use local variables?

A

You can use multiple variables with the same name in a program as they take precedence over variables with the same name

20
Q

Describe the structured approach to programming

A

The three controls should have a single entry and exit and the problem should be decomposed into specific, sea-contained and independent modules.
Independent subroutines should not be reliant of global variables as data should be passed through parameters and there should be indentations.