3.1- Fundamentals of Algorithms

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

1/20

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.

21 Terms

1
New cards

Algorithm

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

2
New cards

Decomposition and an example of its use.

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

3
New cards

Abstraction and an example of how it would be used.

Abstraction is the process of removing unnecessary detail from a problem. For example when designing a game, unnecessary information is removed in order to make it easier to play and easier to make

4
New cards

Which shape means a procedure

Rectangle

<p>Rectangle</p>
5
New cards

Which shape is used for start and end

Stadium (rounded rectangle)

<p>Stadium (rounded rectangle)</p>
6
New cards

Which shape is used for decisions

Diamond

<p>Diamond</p>
7
New cards

Which shape is used for input/output

Parallelogram

<p>Parallelogram</p>
8
New cards

What represents the direction of flow in flowcharts

Arrow

<p>Arrow</p>
9
New cards

Define Sequence

Stand-alone lines in code, that don't apply to selection or iteration. E.g count=0

10
New cards

Define Selection

A decision or question in a statement. E.g an if statement

11
New cards

Define iteration

Repetition. Can be indefinite if the statement is conditional, and definite if the amount is specified. E.g a while loop

12
New cards

Boolean Operators:
<
>
<=
>=
==
!=

Less than
Greater than
Less than or equal to
Greater than or equal to
Equal to
Not equal to

13
New cards

Describe how a binary search works

The list must be in order, and it is then halved repeatedly until the value is found

14
New cards

Which of these would be examined in a binary search for 4

1 2 4 12 21 33 44 57 61 73

21 2 4

15
New cards

Describe how a linear search works

  • Starts at the beginning of the list

  • Iterates sequentially through the list

  • Compares the contents of each position with the data being searched

  • If it matches, the item has been found, and the search ends

  • If the end of the list is reached without finding the data being searched for, the item is not in the list

16
New cards

Which of these will be examined in a linear search for 44
1 2 4 12 21 33 44 57 61 73

1 2 4 12 21 33 44

17
New cards

Describe how a bubble sort works

  • Compare first two values in the list

  • Swap numbers if they are in the wrong order- which ever is highest should be in front

  • Continue on in the list, swapping values to get the highest value- the highest value is now at the end

  • Go back to the start of the list and repeat

  • Continue this until the list is in order

18
New cards

Show the steps of a bubble sort for this list
21 15 34 9 57 61 77 45

15 21 9 34 57 61 45 77
15 9 21 34 57 45 61 77
9 15 21 34 45 57 61 77

19
New cards

Describe how a merge sort works

  • Lists are continuously divided in half, until each list has one component

  • Adjacent lists are compared- whichever has the lower value goes first, then the higher- the lists are merged into ordered lists with two components

  • This continues, repeating this pattern, of merging the lists by comparing the first values of each list and seeing which is smaller, then moving onto the next component, until the list has been fully merged into an ordered list

20
New cards

Show the steps of a merge sort for this list
21 15 34 9 57 61 77 45

21 15 34 9 57 61 77 45
21 15 34 9 / 57 61 77 45
21 15 / 34 9 / 57 61 / 77 45
21 / 15 / 34 / 9 / 57 / 61 / 77 / 45
15 21 / 9 34 / 57 61 / 45 77
15 21 9 34 / 57 61 45 77
9 15 21 34 / 45 57 61 77
9 15 21 34 45 57 61 77

21
New cards

Compare the advantages and disadvantages of merge sort and bubble sort

Merge Sort
Adv- Its generally faster
Dis- It takes up more memory, due to making new lists

Bubble Sort
Adv- It takes up less space, due to only editing the same list
Dis- Its generally slower