Examples

Trace Tables

Write down inputs, outputs and variables needed in a readable format. e.g.


  • Below is a flowchart to determine the highest number of ten user-entered numbers

  • The algorithm prompts the user to enter the first number which automatically becomes the highest number entered

  • The user is then prompted to enter nine more numbers.

    • If a new number is higher than an older number then it is replaced

  • Once all ten numbers are entered, the algorithm outputs which number was the highest

  • Example test data to be used is: 4, 3, 7, 1, 8, 3, 6, 9, 12, 10


flowchart question


answer:

white;padding:0.5rem;box−shadow:rgba(0,0,0,0)0px0px0px9999pxinset;"><pclass="text−center"style="text−align:center;"><strong>Count</strong></p></td><tdcolspan="1"rowspan="1"style="box−sizing:border−box;border−width:0px0.8px;border−image:none100white; padding: 0.5rem; box-shadow: rgba(0, 0, 0, 0) 0px 0px 0px 9999px inset;"><p class="text-center" style="text-align: center;"><strong>Count</strong></p></td><td colspan="1" rowspan="1" style="box-sizing: border-box; border-width: 0px 0.8px; border-image: none 100% / 1 / 0 stretch; --bs-border-opacity: 1; --bs-table-bg: theme.white; padding: 0.5rem; box-shadow: rgba(0, 0, 0, 0) 0px 0px 0px 9999px inset;">

Highest

white;padding:0.5rem;box−shadow:rgba(0,0,0,0)0px0px0px9999pxinset;"><pclass="text−center"style="text−align:center;"><strong>Number</strong></p></td><tdcolspan="1"rowspan="1"style="box−sizing:border−box;border−width:0px0.8px;border−image:none100white; padding: 0.5rem; box-shadow: rgba(0, 0, 0, 0) 0px 0px 0px 9999px inset;"><p class="text-center" style="text-align: center;"><strong>Number</strong></p></td><td colspan="1" rowspan="1" style="box-sizing: border-box; border-width: 0px 0.8px; border-image: none 100% / 1 / 0 stretch; --bs-border-opacity: 1; --bs-table-bg: theme.white; padding: 0.5rem; box-shadow: rgba(0, 0, 0, 0) 0px 0px 0px 9999px inset;">

Output

white;padding:0.5rem;box−shadow:rgba(0,0,0,0)0px0px0px9999pxinset;"><p>1</p></td><tdcolspan="1"rowspan="1"style="box−sizing:border−box;border−width:0px0.8px;border−image:none100white; padding: 0.5rem; box-shadow: rgba(0, 0, 0, 0) 0px 0px 0px 9999px inset;"><p>1</p></td><td colspan="1" rowspan="1" style="box-sizing: border-box; border-width: 0px 0.8px; border-image: none 100% / 1 / 0 stretch; --bs-border-opacity: 1; --bs-table-bg: theme.white; padding: 0.5rem; box-shadow: rgba(0, 0, 0, 0) 0px 0px 0px 9999px inset;">

 

white;padding:0.5rem;box−shadow:rgba(0,0,0,0)0px0px0px9999pxinset;"><p> </p></td><tdcolspan="1"rowspan="1"style="box−sizing:border−box;border−width:0px0.8px;border−image:none100white; padding: 0.5rem; box-shadow: rgba(0, 0, 0, 0) 0px 0px 0px 9999px inset;"><p> </p></td><td colspan="1" rowspan="1" style="box-sizing: border-box; border-width: 0px 0.8px; border-image: none 100% / 1 / 0 stretch; --bs-border-opacity: 1; --bs-table-bg: theme.white; padding: 0.5rem; box-shadow: rgba(0, 0, 0, 0) 0px 0px 0px 9999px inset;">

Enter ten numbers

white;padding:0.5rem;box−shadow:rgba(0,0,0,0)0px0px0px9999pxinset;"><p> </p></td><tdcolspan="1"rowspan="1"style="box−sizing:border−box;border−width:0px0.8px;border−image:none100white; padding: 0.5rem; box-shadow: rgba(0, 0, 0, 0) 0px 0px 0px 9999px inset;"><p> </p></td><td colspan="1" rowspan="1" style="box-sizing: border-box; border-width: 0px 0.8px; border-image: none 100% / 1 / 0 stretch; --bs-border-opacity: 1; --bs-table-bg: theme.white; padding: 0.5rem; box-shadow: rgba(0, 0, 0, 0) 0px 0px 0px 9999px inset;">

4

white;padding:0.5rem;box−shadow:rgba(0,0,0,0)0px0px0px9999pxinset;"><p> </p></td><tdcolspan="1"rowspan="1"style="box−sizing:border−box;border−width:0px0.8px;border−image:none100white; padding: 0.5rem; box-shadow: rgba(0, 0, 0, 0) 0px 0px 0px 9999px inset;"><p> </p></td><td colspan="1" rowspan="1" style="box-sizing: border-box; border-width: 0px 0.8px; border-image: none 100% / 1 / 0 stretch; --bs-border-opacity: 1; --bs-table-bg: theme.white; padding: 0.5rem; box-shadow: rgba(0, 0, 0, 0) 0px 0px 0px 9999px inset;">

Enter your first number

white;padding:0.5rem;box−shadow:rgba(0,0,0,0)0px0px0px9999pxinset;"><p>2</p></td><tdcolspan="1"rowspan="1"style="box−sizing:border−box;border−width:0px0.8px;border−image:none100white; padding: 0.5rem; box-shadow: rgba(0, 0, 0, 0) 0px 0px 0px 9999px inset;"><p>2</p></td><td colspan="1" rowspan="1" style="box-sizing: border-box; border-width: 0px 0.8px; border-image: none 100% / 1 / 0 stretch; --bs-border-opacity: 1; --bs-table-bg: theme.white; padding: 0.5rem; box-shadow: rgba(0, 0, 0, 0) 0px 0px 0px 9999px inset;">

 

white;padding:0.5rem;box−shadow:rgba(0,0,0,0)0px0px0px9999pxinset;"><p>3</p></td><tdcolspan="1"rowspan="1"style="box−sizing:border−box;border−width:0px0.8px;border−image:none100white; padding: 0.5rem; box-shadow: rgba(0, 0, 0, 0) 0px 0px 0px 9999px inset;"><p>3</p></td><td colspan="1" rowspan="1" style="box-sizing: border-box; border-width: 0px 0.8px; border-image: none 100% / 1 / 0 stretch; --bs-border-opacity: 1; --bs-table-bg: theme.white; padding: 0.5rem; box-shadow: rgba(0, 0, 0, 0) 0px 0px 0px 9999px inset;">

Enter your next number

white;padding:0.5rem;box−shadow:rgba(0,0,0,0)0px0px0px9999pxinset;"><p>3</p></td><tdcolspan="1"rowspan="1"style="box−sizing:border−box;border−width:0px0.8px;border−image:none100white; padding: 0.5rem; box-shadow: rgba(0, 0, 0, 0) 0px 0px 0px 9999px inset;"><p>3</p></td><td colspan="1" rowspan="1" style="box-sizing: border-box; border-width: 0px 0.8px; border-image: none 100% / 1 / 0 stretch; --bs-border-opacity: 1; --bs-table-bg: theme.white; padding: 0.5rem; box-shadow: rgba(0, 0, 0, 0) 0px 0px 0px 9999px inset;">

7

white;padding:0.5rem;box−shadow:rgba(0,0,0,0)0px0px0px9999pxinset;"><p>7</p></td><tdcolspan="1"rowspan="1"style="box−sizing:border−box;border−width:0px0.8px;border−image:none100white; padding: 0.5rem; box-shadow: rgba(0, 0, 0, 0) 0px 0px 0px 9999px inset;"><p>7</p></td><td colspan="1" rowspan="1" style="box-sizing: border-box; border-width: 0px 0.8px; border-image: none 100% / 1 / 0 stretch; --bs-border-opacity: 1; --bs-table-bg: theme.white; padding: 0.5rem; box-shadow: rgba(0, 0, 0, 0) 0px 0px 0px 9999px inset;">

 

white;padding:0.5rem;box−shadow:rgba(0,0,0,0)0px0px0px9999pxinset;"><p>4</p></td><tdcolspan="1"rowspan="1"style="box−sizing:border−box;border−width:0px0.8px;border−image:none100white; padding: 0.5rem; box-shadow: rgba(0, 0, 0, 0) 0px 0px 0px 9999px inset;"><p>4</p></td><td colspan="1" rowspan="1" style="box-sizing: border-box; border-width: 0px 0.8px; border-image: none 100% / 1 / 0 stretch; --bs-border-opacity: 1; --bs-table-bg: theme.white; padding: 0.5rem; box-shadow: rgba(0, 0, 0, 0) 0px 0px 0px 9999px inset;">

 

white;padding:0.5rem;box−shadow:rgba(0,0,0,0)0px0px0px9999pxinset;"><p>1</p></td><tdcolspan="1"rowspan="1"style="box−sizing:border−box;border−width:0px0.8px;border−image:none100white; padding: 0.5rem; box-shadow: rgba(0, 0, 0, 0) 0px 0px 0px 9999px inset;"><p>1</p></td><td colspan="1" rowspan="1" style="box-sizing: border-box; border-width: 0px 0.8px; border-image: none 100% / 1 / 0 stretch; --bs-border-opacity: 1; --bs-table-bg: theme.white; padding: 0.5rem; box-shadow: rgba(0, 0, 0, 0) 0px 0px 0px 9999px inset;">

 

white;padding:0.5rem;box−shadow:rgba(0,0,0,0)0px0px0px9999pxinset;"><p>5</p></td><tdcolspan="1"rowspan="1"style="box−sizing:border−box;border−width:0px0.8px;border−image:none100white; padding: 0.5rem; box-shadow: rgba(0, 0, 0, 0) 0px 0px 0px 9999px inset;"><p>5</p></td><td colspan="1" rowspan="1" style="box-sizing: border-box; border-width: 0px 0.8px; border-image: none 100% / 1 / 0 stretch; --bs-border-opacity: 1; --bs-table-bg: theme.white; padding: 0.5rem; box-shadow: rgba(0, 0, 0, 0) 0px 0px 0px 9999px inset;">

8

white;padding:0.5rem;box−shadow:rgba(0,0,0,0)0px0px0px9999pxinset;"><p>8</p></td><tdcolspan="1"rowspan="1"style="box−sizing:border−box;border−width:0px0.8px;border−image:none100white; padding: 0.5rem; box-shadow: rgba(0, 0, 0, 0) 0px 0px 0px 9999px inset;"><p>8</p></td><td colspan="1" rowspan="1" style="box-sizing: border-box; border-width: 0px 0.8px; border-image: none 100% / 1 / 0 stretch; --bs-border-opacity: 1; --bs-table-bg: theme.white; padding: 0.5rem; box-shadow: rgba(0, 0, 0, 0) 0px 0px 0px 9999px inset;">

 

white;padding:0.5rem;box−shadow:rgba(0,0,0,0)0px0px0px9999pxinset;"><p>6</p></td><tdcolspan="1"rowspan="1"style="box−sizing:border−box;border−width:0px0.8px;border−image:none100white; padding: 0.5rem; box-shadow: rgba(0, 0, 0, 0) 0px 0px 0px 9999px inset;"><p>6</p></td><td colspan="1" rowspan="1" style="box-sizing: border-box; border-width: 0px 0.8px; border-image: none 100% / 1 / 0 stretch; --bs-border-opacity: 1; --bs-table-bg: theme.white; padding: 0.5rem; box-shadow: rgba(0, 0, 0, 0) 0px 0px 0px 9999px inset;">

 

white;padding:0.5rem;box−shadow:rgba(0,0,0,0)0px0px0px9999pxinset;"><p>3</p></td><tdcolspan="1"rowspan="1"style="box−sizing:border−box;border−width:0px0.8px;border−image:none100white; padding: 0.5rem; box-shadow: rgba(0, 0, 0, 0) 0px 0px 0px 9999px inset;"><p>3</p></td><td colspan="1" rowspan="1" style="box-sizing: border-box; border-width: 0px 0.8px; border-image: none 100% / 1 / 0 stretch; --bs-border-opacity: 1; --bs-table-bg: theme.white; padding: 0.5rem; box-shadow: rgba(0, 0, 0, 0) 0px 0px 0px 9999px inset;">

 

white;padding:0.5rem;box−shadow:rgba(0,0,0,0)0px0px0px9999pxinset;"><p>7</p></td><tdcolspan="1"rowspan="1"style="box−sizing:border−box;border−width:0px0.8px;border−image:none100white; padding: 0.5rem; box-shadow: rgba(0, 0, 0, 0) 0px 0px 0px 9999px inset;"><p>7</p></td><td colspan="1" rowspan="1" style="box-sizing: border-box; border-width: 0px 0.8px; border-image: none 100% / 1 / 0 stretch; --bs-border-opacity: 1; --bs-table-bg: theme.white; padding: 0.5rem; box-shadow: rgba(0, 0, 0, 0) 0px 0px 0px 9999px inset;">

 

white;padding:0.5rem;box−shadow:rgba(0,0,0,0)0px0px0px9999pxinset;"><p>6</p></td><tdcolspan="1"rowspan="1"style="box−sizing:border−box;border−width:0px0.8px;border−image:none100white; padding: 0.5rem; box-shadow: rgba(0, 0, 0, 0) 0px 0px 0px 9999px inset;"><p>6</p></td><td colspan="1" rowspan="1" style="box-sizing: border-box; border-width: 0px 0.8px; border-image: none 100% / 1 / 0 stretch; --bs-border-opacity: 1; --bs-table-bg: theme.white; padding: 0.5rem; box-shadow: rgba(0, 0, 0, 0) 0px 0px 0px 9999px inset;">

 

white;padding:0.5rem;box−shadow:rgba(0,0,0,0)0px0px0px9999pxinset;"><p>8</p></td><tdcolspan="1"rowspan="1"style="box−sizing:border−box;border−width:0px0.8px;border−image:none100white; padding: 0.5rem; box-shadow: rgba(0, 0, 0, 0) 0px 0px 0px 9999px inset;"><p>8</p></td><td colspan="1" rowspan="1" style="box-sizing: border-box; border-width: 0px 0.8px; border-image: none 100% / 1 / 0 stretch; --bs-border-opacity: 1; --bs-table-bg: theme.white; padding: 0.5rem; box-shadow: rgba(0, 0, 0, 0) 0px 0px 0px 9999px inset;">

9

white;padding:0.5rem;box−shadow:rgba(0,0,0,0)0px0px0px9999pxinset;"><p>9</p></td><tdcolspan="1"rowspan="1"style="box−sizing:border−box;border−width:0px0.8px;border−image:none100white; padding: 0.5rem; box-shadow: rgba(0, 0, 0, 0) 0px 0px 0px 9999px inset;"><p>9</p></td><td colspan="1" rowspan="1" style="box-sizing: border-box; border-width: 0px 0.8px; border-image: none 100% / 1 / 0 stretch; --bs-border-opacity: 1; --bs-table-bg: theme.white; padding: 0.5rem; box-shadow: rgba(0, 0, 0, 0) 0px 0px 0px 9999px inset;">

 

white;padding:0.5rem;box−shadow:rgba(0,0,0,0)0px0px0px9999pxinset;"><p>9</p></td><tdcolspan="1"rowspan="1"style="box−sizing:border−box;border−width:0px0.8px;border−image:none100white; padding: 0.5rem; box-shadow: rgba(0, 0, 0, 0) 0px 0px 0px 9999px inset;"><p>9</p></td><td colspan="1" rowspan="1" style="box-sizing: border-box; border-width: 0px 0.8px; border-image: none 100% / 1 / 0 stretch; --bs-border-opacity: 1; --bs-table-bg: theme.white; padding: 0.5rem; box-shadow: rgba(0, 0, 0, 0) 0px 0px 0px 9999px inset;">

12

white;padding:0.5rem;box−shadow:rgba(0,0,0,0)0px0px0px9999pxinset;"><p>12</p></td><tdcolspan="1"rowspan="1"style="box−sizing:border−box;border−width:0px0.8px;border−image:none100white; padding: 0.5rem; box-shadow: rgba(0, 0, 0, 0) 0px 0px 0px 9999px inset;"><p>12</p></td><td colspan="1" rowspan="1" style="box-sizing: border-box; border-width: 0px 0.8px; border-image: none 100% / 1 / 0 stretch; --bs-border-opacity: 1; --bs-table-bg: theme.white; padding: 0.5rem; box-shadow: rgba(0, 0, 0, 0) 0px 0px 0px 9999px inset;">

 

white;padding:0.5rem;box−shadow:rgba(0,0,0,0)0px0px0px9999pxinset;"><p>10</p></td><tdcolspan="1"rowspan="1"style="box−sizing:border−box;border−width:0px0.8px;border−image:none100white; padding: 0.5rem; box-shadow: rgba(0, 0, 0, 0) 0px 0px 0px 9999px inset;"><p>10</p></td><td colspan="1" rowspan="1" style="box-sizing: border-box; border-width: 0px 0.8px; border-image: none 100% / 1 / 0 stretch; --bs-border-opacity: 1; --bs-table-bg: theme.white; padding: 0.5rem; box-shadow: rgba(0, 0, 0, 0) 0px 0px 0px 9999px inset;">

 

white;padding:0.5rem;box−shadow:rgba(0,0,0,0)0px0px0px9999pxinset;"><p>10</p></td><tdcolspan="1"rowspan="1"style="box−sizing:border−box;border−width:0px0.8px;border−image:none100white; padding: 0.5rem; box-shadow: rgba(0, 0, 0, 0) 0px 0px 0px 9999px inset;"><p>10</p></td><td colspan="1" rowspan="1" style="box-sizing: border-box; border-width: 0px 0.8px; border-image: none 100% / 1 / 0 stretch; --bs-border-opacity: 1; --bs-table-bg: theme.white; padding: 0.5rem; box-shadow: rgba(0, 0, 0, 0) 0px 0px 0px 9999px inset;">

12 is your highest number


  • Only write when change is made in the program, convert python into flowchart if necessary

SORTING ALGORITHMS


Bubble

Bubble Sort

Step

Instructions

white;padding:0.5rem;box−shadow:rgba(0,0,0,0)0px0px0px9999pxinset;"><p><strong>1</strong></p></td><tdcolspan="1"rowspan="1"style="box−sizing:border−box;border−width:0px0.8px;border−image:none100white; padding: 0.5rem; box-shadow: rgba(0, 0, 0, 0) 0px 0px 0px 9999px inset;"><p><strong>1</strong></p></td><td colspan="1" rowspan="1" style="box-sizing: border-box; border-width: 0px 0.8px; border-image: none 100% / 1 / 0 stretch; --bs-border-opacity: 1; --bs-table-bg: theme.white; padding: 0.5rem; box-shadow: rgba(0, 0, 0, 0) 0px 0px 0px 9999px inset;">

Compare the first two values in the dataset

white;padding:0.5rem;box−shadow:rgba(0,0,0,0)0px0px0px9999pxinset;"><p><strong>2</strong></p></td><tdcolspan="1"rowspan="1"style="box−sizing:border−box;border−width:0px0.8px;border−image:none100white; padding: 0.5rem; box-shadow: rgba(0, 0, 0, 0) 0px 0px 0px 9999px inset;"><p><strong>2</strong></p></td><td colspan="1" rowspan="1" style="box-sizing: border-box; border-width: 0px 0.8px; border-image: none 100% / 1 / 0 stretch; --bs-border-opacity: 1; --bs-table-bg: theme.white; padding: 0.5rem; box-shadow: rgba(0, 0, 0, 0) 0px 0px 0px 9999px inset;">

IF they are in the wrong order...

  • Swap them

white;padding:0.5rem;box−shadow:rgba(0,0,0,0)0px0px0px9999pxinset;"><p><strong>3</strong></p></td><tdcolspan="1"rowspan="1"style="box−sizing:border−box;border−width:0px0.8px;border−image:none100white; padding: 0.5rem; box-shadow: rgba(0, 0, 0, 0) 0px 0px 0px 9999px inset;"><p><strong>3</strong></p></td><td colspan="1" rowspan="1" style="box-sizing: border-box; border-width: 0px 0.8px; border-image: none 100% / 1 / 0 stretch; --bs-border-opacity: 1; --bs-table-bg: theme.white; padding: 0.5rem; box-shadow: rgba(0, 0, 0, 0) 0px 0px 0px 9999px inset;">

Compare the next two values

white;padding:0.5rem;box−shadow:rgba(0,0,0,0)0px0px0px9999pxinset;"><p><strong>4</strong></p></td><tdcolspan="1"rowspan="1"style="box−sizing:border−box;border−width:0px0.8px;border−image:none100white; padding: 0.5rem; box-shadow: rgba(0, 0, 0, 0) 0px 0px 0px 9999px inset;"><p><strong>4</strong></p></td><td colspan="1" rowspan="1" style="box-sizing: border-box; border-width: 0px 0.8px; border-image: none 100% / 1 / 0 stretch; --bs-border-opacity: 1; --bs-table-bg: theme.white; padding: 0.5rem; box-shadow: rgba(0, 0, 0, 0) 0px 0px 0px 9999px inset;">

REPEAT step 2 & 3 until you reach the end of the dataset (pass 1)

white;padding:0.5rem;box−shadow:rgba(0,0,0,0)0px0px0px9999pxinset;"><p><strong>5</strong></p></td><tdcolspan="1"rowspan="1"style="box−sizing:border−box;border−width:0px0.8px;border−image:none100white; padding: 0.5rem; box-shadow: rgba(0, 0, 0, 0) 0px 0px 0px 9999px inset;"><p><strong>5</strong></p></td><td colspan="1" rowspan="1" style="box-sizing: border-box; border-width: 0px 0.8px; border-image: none 100% / 1 / 0 stretch; --bs-border-opacity: 1; --bs-table-bg: theme.white; padding: 0.5rem; box-shadow: rgba(0, 0, 0, 0) 0px 0px 0px 9999px inset;">

IF you have made any swaps...

  • REPEAT from the start (pass 2,3,4...)

white;padding:0.5rem;box−shadow:rgba(0,0,0,0)0px0px0px9999pxinset;"><p><strong>6</strong></p></td><tdcolspan="1"rowspan="1"style="box−sizing:border−box;border−width:0px0.8px;border−image:none100white; padding: 0.5rem; box-shadow: rgba(0, 0, 0, 0) 0px 0px 0px 9999px inset;"><p><strong>6</strong></p></td><td colspan="1" rowspan="1" style="box-sizing: border-box; border-width: 0px 0.8px; border-image: none 100% / 1 / 0 stretch; --bs-border-opacity: 1; --bs-table-bg: theme.white; padding: 0.5rem; box-shadow: rgba(0, 0, 0, 0) 0px 0px 0px 9999px inset;">

ELSE you have not made any swaps...

  • STOP! the list is in the correct order


Insertion

Step

Instruction

white;padding:0.5rem;box−shadow:rgba(0,0,0,0)0px0px0px9999pxinset;"><p><strong>1</strong></p></td><tdcolspan="1"rowspan="1"style="box−sizing:border−box;border−width:0px0.8px;border−image:none100white; padding: 0.5rem; box-shadow: rgba(0, 0, 0, 0) 0px 0px 0px 9999px inset;"><p><strong>1</strong></p></td><td colspan="1" rowspan="1" style="box-sizing: border-box; border-width: 0px 0.8px; border-image: none 100% / 1 / 0 stretch; --bs-border-opacity: 1; --bs-table-bg: theme.white; padding: 0.5rem; box-shadow: rgba(0, 0, 0, 0) 0px 0px 0px 9999px inset;">

Take the first value in the dataset, this is now the sorted list

white;padding:0.5rem;box−shadow:rgba(0,0,0,0)0px0px0px9999pxinset;"><p><strong>2</strong></p></td><tdcolspan="1"rowspan="1"style="box−sizing:border−box;border−width:0px0.8px;border−image:none100white; padding: 0.5rem; box-shadow: rgba(0, 0, 0, 0) 0px 0px 0px 9999px inset;"><p><strong>2</strong></p></td><td colspan="1" rowspan="1" style="box-sizing: border-box; border-width: 0px 0.8px; border-image: none 100% / 1 / 0 stretch; --bs-border-opacity: 1; --bs-table-bg: theme.white; padding: 0.5rem; box-shadow: rgba(0, 0, 0, 0) 0px 0px 0px 9999px inset;">

Look at the next value in the dataset and compare it to the first value

IF it is smaller

  • insert it into the correct position to the left

white;padding:0.5rem;box−shadow:rgba(0,0,0,0)0px0px0px9999pxinset;"><p><strong>3</strong></p></td><tdcolspan="1"rowspan="1"style="box−sizing:border−box;border−width:0px0.8px;border−image:none100white; padding: 0.5rem; box-shadow: rgba(0, 0, 0, 0) 0px 0px 0px 9999px inset;"><p><strong>3</strong></p></td><td colspan="1" rowspan="1" style="box-sizing: border-box; border-width: 0px 0.8px; border-image: none 100% / 1 / 0 stretch; --bs-border-opacity: 1; --bs-table-bg: theme.white; padding: 0.5rem; box-shadow: rgba(0, 0, 0, 0) 0px 0px 0px 9999px inset;">

ELSE

  • Keep in the same position

white;padding:0.5rem;box−shadow:rgba(0,0,0,0)0px0px0px9999pxinset;"><p><strong>4</strong></p></td><tdcolspan="1"rowspan="1"style="box−sizing:border−box;border−width:0px0.8px;border−image:none100white; padding: 0.5rem; box-shadow: rgba(0, 0, 0, 0) 0px 0px 0px 9999px inset;"><p><strong>4</strong></p></td><td colspan="1" rowspan="1" style="box-sizing: border-box; border-width: 0px 0.8px; border-image: none 100% / 1 / 0 stretch; --bs-border-opacity: 1; --bs-table-bg: theme.white; padding: 0.5rem; box-shadow: rgba(0, 0, 0, 0) 0px 0px 0px 9999px inset;">

REPEAT steps 2 & 3 until all values in the dataset have been compared, the list should now be in order


Insertion Sort Algorithm


Merge

Step

Instruction

white;padding:0.5rem;box−shadow:rgba(0,0,0,0)0px0px0px9999pxinset;"><p><strong>1</strong></p></td><tdcolspan="1"rowspan="1"style="box−sizing:border−box;border−width:0px0.8px;border−image:none100white; padding: 0.5rem; box-shadow: rgba(0, 0, 0, 0) 0px 0px 0px 9999px inset;"><p><strong>1</strong></p></td><td colspan="1" rowspan="1" style="box-sizing: border-box; border-width: 0px 0.8px; border-image: none 100% / 1 / 0 stretch; --bs-border-opacity: 1; --bs-table-bg: theme.white; padding: 0.5rem; box-shadow: rgba(0, 0, 0, 0) 0px 0px 0px 9999px inset;">

Divide the dataset into individual datasets by repeatedly splitting the dataset in half (DIVIDE)

white;padding:0.5rem;box−shadow:rgba(0,0,0,0)0px0px0px9999pxinset;"><p><strong>2</strong></p></td><tdcolspan="1"rowspan="1"style="box−sizing:border−box;border−width:0px0.8px;border−image:none100white; padding: 0.5rem; box-shadow: rgba(0, 0, 0, 0) 0px 0px 0px 9999px inset;"><p><strong>2</strong></p></td><td colspan="1" rowspan="1" style="box-sizing: border-box; border-width: 0px 0.8px; border-image: none 100% / 1 / 0 stretch; --bs-border-opacity: 1; --bs-table-bg: theme.white; padding: 0.5rem; box-shadow: rgba(0, 0, 0, 0) 0px 0px 0px 9999px inset;">

Merge pairs of sub-datasets together by comparing the first value in each dataset (CONQUER)

white;padding:0.5rem;box−shadow:rgba(0,0,0,0)0px0px0px9999pxinset;"><p><strong>3</strong></p></td><tdcolspan="1"rowspan="1"style="box−sizing:border−box;border−width:0px0.8px;border−image:none100white; padding: 0.5rem; box-shadow: rgba(0, 0, 0, 0) 0px 0px 0px 9999px inset;"><p><strong>3</strong></p></td><td colspan="1" rowspan="1" style="box-sizing: border-box; border-width: 0px 0.8px; border-image: none 100% / 1 / 0 stretch; --bs-border-opacity: 1; --bs-table-bg: theme.white; padding: 0.5rem; box-shadow: rgba(0, 0, 0, 0) 0px 0px 0px 9999px inset;">

REPEAT step 2 until all sub-datasets are merged together into one dataset


Merge Sort


SEARCHING ALGORITHMS

Linear Search

white;padding:0.5rem;box−shadow:rgba(0,0,0,0)0px0px0px9999pxinset;"><pclass="text−center"style="text−align:center;"><strong>1</strong></p></td><tdcolspan="1"rowspan="1"style="box−sizing:border−box;border−width:0px0.8px;border−image:none100white; padding: 0.5rem; box-shadow: rgba(0, 0, 0, 0) 0px 0px 0px 9999px inset;"><p class="text-center" style="text-align: center;"><strong>1</strong></p></td><td colspan="1" rowspan="1" style="box-sizing: border-box; border-width: 0px 0.8px; border-image: none 100% / 1 / 0 stretch; --bs-border-opacity: 1; --bs-table-bg: theme.white; padding: 0.5rem; box-shadow: rgba(0, 0, 0, 0) 0px 0px 0px 9999px inset;">

Check the first value

white;padding:0.5rem;box−shadow:rgba(0,0,0,0)0px0px0px9999pxinset;"><pclass="text−center"style="text−align:center;"><strong>2</strong></p></td><tdcolspan="1"rowspan="1"style="box−sizing:border−box;border−width:0px0.8px;border−image:none100white; padding: 0.5rem; box-shadow: rgba(0, 0, 0, 0) 0px 0px 0px 9999px inset;"><p class="text-center" style="text-align: center;"><strong>2</strong></p></td><td colspan="1" rowspan="1" style="box-sizing: border-box; border-width: 0px 0.8px; border-image: none 100% / 1 / 0 stretch; --bs-border-opacity: 1; --bs-table-bg: theme.white; padding: 0.5rem; box-shadow: rgba(0, 0, 0, 0) 0px 0px 0px 9999px inset;">

IF it is the value you are looking for

  • STOP!

white;padding:0.5rem;box−shadow:rgba(0,0,0,0)0px0px0px9999pxinset;"><pclass="text−center"style="text−align:center;"><strong>3</strong></p></td><tdcolspan="1"rowspan="1"style="box−sizing:border−box;border−width:0px0.8px;border−image:none100white; padding: 0.5rem; box-shadow: rgba(0, 0, 0, 0) 0px 0px 0px 9999px inset;"><p class="text-center" style="text-align: center;"><strong>3</strong></p></td><td colspan="1" rowspan="1" style="box-sizing: border-box; border-width: 0px 0.8px; border-image: none 100% / 1 / 0 stretch; --bs-border-opacity: 1; --bs-table-bg: theme.white; padding: 0.5rem; box-shadow: rgba(0, 0, 0, 0) 0px 0px 0px 9999px inset;">

ELSE move to the next value and check

white;padding:0.5rem;box−shadow:rgba(0,0,0,0)0px0px0px9999pxinset;"><pclass="text−center"style="text−align:center;"><strong>4</strong></p></td><tdcolspan="1"rowspan="1"style="box−sizing:border−box;border−width:0px0.8px;border−image:none100white; padding: 0.5rem; box-shadow: rgba(0, 0, 0, 0) 0px 0px 0px 9999px inset;"><p class="text-center" style="text-align: center;"><strong>4</strong></p></td><td colspan="1" rowspan="1" style="box-sizing: border-box; border-width: 0px 0.8px; border-image: none 100% / 1 / 0 stretch; --bs-border-opacity: 1; --bs-table-bg: theme.white; padding: 0.5rem; box-shadow: rgba(0, 0, 0, 0) 0px 0px 0px 9999px inset;">

REPEAT UNTIL you have checked all values and not found the value you are looking for


Linear Search


Binary Search


white;padding:0.5rem;box−shadow:rgba(0,0,0,0)0px0px0px9999pxinset;"><p><strong>1</strong></p></td><tdcolspan="1"rowspan="1"style="box−sizing:border−box;border−width:0px0.8px;border−image:none100white; padding: 0.5rem; box-shadow: rgba(0, 0, 0, 0) 0px 0px 0px 9999px inset;"><p><strong>1</strong></p></td><td colspan="1" rowspan="1" style="box-sizing: border-box; border-width: 0px 0.8px; border-image: none 100% / 1 / 0 stretch; --bs-border-opacity: 1; --bs-table-bg: theme.white; padding: 0.5rem; box-shadow: rgba(0, 0, 0, 0) 0px 0px 0px 9999px inset;">

Identify the middle value (12) (total values + 1 divided by 2, if 0.5 then round up)

white;padding:0.5rem;box−shadow:rgba(0,0,0,0)0px0px0px9999pxinset;"><p><strong> </strong></p></td><tdcolspan="1"rowspan="1"style="box−sizing:border−box;border−width:0px0.8px;border−image:none100white; padding: 0.5rem; box-shadow: rgba(0, 0, 0, 0) 0px 0px 0px 9999px inset;"><p><strong> </strong></p></td><td colspan="1" rowspan="1" style="box-sizing: border-box; border-width: 0px 0.8px; border-image: none 100% / 1 / 0 stretch; --bs-border-opacity: 1; --bs-table-bg: theme.white; padding: 0.5rem; box-shadow: rgba(0, 0, 0, 0) 0px 0px 0px 9999px inset;">
white;padding:0.5rem;box−shadow:rgba(0,0,0,0)0px0px0px9999pxinset;"><p><strong>2</strong></p></td><tdcolspan="1"rowspan="1"style="box−sizing:border−box;border−width:0px0.8px;border−image:none100white; padding: 0.5rem; box-shadow: rgba(0, 0, 0, 0) 0px 0px 0px 9999px inset;"><p><strong>2</strong></p></td><td colspan="1" rowspan="1" style="box-sizing: border-box; border-width: 0px 0.8px; border-image: none 100% / 1 / 0 stretch; --bs-border-opacity: 1; --bs-table-bg: theme.white; padding: 0.5rem; box-shadow: rgba(0, 0, 0, 0) 0px 0px 0px 9999px inset;">

5

white;padding:0.5rem;box−shadow:rgba(0,0,0,0)0px0px0px9999pxinset;"><p><strong>7</strong></p></td><tdcolspan="1"rowspan="1"style="box−sizing:border−box;border−width:0px0.8px;border−image:none100white; padding: 0.5rem; box-shadow: rgba(0, 0, 0, 0) 0px 0px 0px 9999px inset;"><p><strong>7</strong></p></td><td colspan="1" rowspan="1" style="box-sizing: border-box; border-width: 0px 0.8px; border-image: none 100% / 1 / 0 stretch; --bs-border-opacity: 1; --bs-table-bg: theme.white; padding: 0.5rem; box-shadow: rgba(0, 0, 0, 0) 0px 0px 0px 9999px inset;">

12

white;padding:0.5rem;box−shadow:rgba(0,0,0,0)0px0px0px9999pxinset;"><p><strong>15</strong></p></td><tdcolspan="1"rowspan="1"style="box−sizing:border−box;border−width:0px0.8px;border−image:none100white; padding: 0.5rem; box-shadow: rgba(0, 0, 0, 0) 0px 0px 0px 9999px inset;"><p><strong>15</strong></p></td><td colspan="1" rowspan="1" style="box-sizing: border-box; border-width: 0px 0.8px; border-image: none 100% / 1 / 0 stretch; --bs-border-opacity: 1; --bs-table-bg: theme.white; padding: 0.5rem; box-shadow: rgba(0, 0, 0, 0) 0px 0px 0px 9999px inset;">

22

white;padding:0.5rem;box−shadow:rgba(0,0,0,0)0px0px0px9999pxinset;"><p><strong>46</strong></p></td></tr></tbody></table></td></tr><tr><tdcolspan="1"rowspan="1"style="box−sizing:border−box;border−width:0px0.8px;border−image:none100white; padding: 0.5rem; box-shadow: rgba(0, 0, 0, 0) 0px 0px 0px 9999px inset;"><p><strong>46</strong></p></td></tr></tbody></table></td></tr><tr><td colspan="1" rowspan="1" style="box-sizing: border-box; border-width: 0px 0.8px; border-image: none 100% / 1 / 0 stretch; --bs-border-opacity: 1; --bs-table-bg: theme.white; padding: 0.5rem; box-shadow: rgba(0, 0, 0, 0) 0px 0px 0px 9999px inset;">

2

white;padding:0.5rem;box−shadow:rgba(0,0,0,0)0px0px0px9999pxinset;"><p><strong>Compare </strong>tothevalueyouarelookingfor−<strong>Is12==7?</strong></p></td></tr><tr><tdcolspan="1"rowspan="1"style="box−sizing:border−box;border−width:0px0.8px;border−image:none100white; padding: 0.5rem; box-shadow: rgba(0, 0, 0, 0) 0px 0px 0px 9999px inset;"><p><strong>Compare </strong>to the value you are looking for - <strong>Is 12 == 7?</strong></p></td></tr><tr><td colspan="1" rowspan="1" style="box-sizing: border-box; border-width: 0px 0.8px; border-image: none 100% / 1 / 0 stretch; --bs-border-opacity: 1; --bs-table-bg: theme.white; padding: 0.5rem; box-shadow: rgba(0, 0, 0, 0) 0px 0px 0px 9999px inset;">

3

white;padding:0.5rem;box−shadow:rgba(0,0,0,0)0px0px0px9999pxinset;"><p><strong>IF </strong>itisthevalueyouarelookingfor...</p><ul><li><p>Stop!−<strong>12isnotequalto7</strong></p></li></ul></td></tr><tr><tdcolspan="1"rowspan="1"style="box−sizing:border−box;border−width:0px0.8px;border−image:none100white; padding: 0.5rem; box-shadow: rgba(0, 0, 0, 0) 0px 0px 0px 9999px inset;"><p><strong>IF </strong>it is the value you are looking for...</p><ul><li><p>Stop! - <strong>12 is not equal to 7</strong></p></li></ul></td></tr><tr><td colspan="1" rowspan="1" style="box-sizing: border-box; border-width: 0px 0.8px; border-image: none 100% / 1 / 0 stretch; --bs-border-opacity: 1; --bs-table-bg: theme.white; padding: 0.5rem; box-shadow: rgba(0, 0, 0, 0) 0px 0px 0px 9999px inset;">

4

white;padding:0.5rem;box−shadow:rgba(0,0,0,0)0px0px0px9999pxinset;"><p><strong>ELSEIF </strong>isitbiggerthantheoneyouarelookingfor... <strong>Is12>7?YES</strong></p><ul><li><p>Createanewlistwiththevaluesontheleftofthemiddlevalue</p></li></ul><tablestyle="min−width:75px;"><colgroup><colstyle="min−width:25px;"><colstyle="min−width:25px;"><colstyle="min−width:25px;"></colgroup><tbody><tr><tdcolspan="1"rowspan="1"style="box−sizing:border−box;border−width:0px0.8px;border−image:none100white; padding: 0.5rem; box-shadow: rgba(0, 0, 0, 0) 0px 0px 0px 9999px inset;"><p><strong>ELSE IF </strong>is it bigger than the one you are looking for... <strong>Is 12 > 7? YES</strong></p><ul><li><p>Create a new list with the values on the left of the middle value</p></li></ul><table style="min-width: 75px;"><colgroup><col style="min-width: 25px;"><col style="min-width: 25px;"><col style="min-width: 25px;"></colgroup><tbody><tr><td colspan="1" rowspan="1" style="box-sizing: border-box; border-width: 0px 0.8px; border-image: none 100% / 1 / 0 stretch; --bs-border-opacity: 1; --bs-table-bg: theme.white; padding: 0.5rem; box-shadow: rgba(0, 0, 0, 0) 0px 0px 0px 9999px inset;">

2

white;padding:0.5rem;box−shadow:rgba(0,0,0,0)0px0px0px9999pxinset;"><p><strong>5</strong></p></td><tdcolspan="1"rowspan="1"style="box−sizing:border−box;border−width:0px0.8px;border−image:none100white; padding: 0.5rem; box-shadow: rgba(0, 0, 0, 0) 0px 0px 0px 9999px inset;"><p><strong>5</strong></p></td><td colspan="1" rowspan="1" style="box-sizing: border-box; border-width: 0px 0.8px; border-image: none 100% / 1 / 0 stretch; --bs-border-opacity: 1; --bs-table-bg: theme.white; padding: 0.5rem; box-shadow: rgba(0, 0, 0, 0) 0px 0px 0px 9999px inset;">

7

white;padding:0.5rem;box−shadow:rgba(0,0,0,0)0px0px0px9999pxinset;"><p><strong>5</strong></p></td><tdcolspan="1"rowspan="1"style="box−sizing:border−box;border−width:0px0.8px;border−image:none100white; padding: 0.5rem; box-shadow: rgba(0, 0, 0, 0) 0px 0px 0px 9999px inset;"><p><strong>5</strong></p></td><td colspan="1" rowspan="1" style="box-sizing: border-box; border-width: 0px 0.8px; border-image: none 100% / 1 / 0 stretch; --bs-border-opacity: 1; --bs-table-bg: theme.white; padding: 0.5rem; box-shadow: rgba(0, 0, 0, 0) 0px 0px 0px 9999px inset;">

IF it is smaller than the one you are looking for...

  • Create a new list with the values on the right of the middle value

white;padding:0.5rem;box−shadow:rgba(0,0,0,0)0px0px0px9999pxinset;"><p><strong>6</strong></p></td><tdcolspan="1"rowspan="1"style="box−sizing:border−box;border−width:0px0.8px;border−image:none100white; padding: 0.5rem; box-shadow: rgba(0, 0, 0, 0) 0px 0px 0px 9999px inset;"><p><strong>6</strong></p></td><td colspan="1" rowspan="1" style="box-sizing: border-box; border-width: 0px 0.8px; border-image: none 100% / 1 / 0 stretch; --bs-border-opacity: 1; --bs-table-bg: theme.white; padding: 0.5rem; box-shadow: rgba(0, 0, 0, 0) 0px 0px 0px 9999px inset;">

REPEAT with the new list

white;padding:0.5rem;box−shadow:rgba(0,0,0,0)0px0px0px9999pxinset;"><p><strong>2</strong></p></td><tdcolspan="1"rowspan="1"style="box−sizing:border−box;border−width:0px0.8px;border−image:none100white; padding: 0.5rem; box-shadow: rgba(0, 0, 0, 0) 0px 0px 0px 9999px inset;"><p><strong>2</strong></p></td><td colspan="1" rowspan="1" style="box-sizing: border-box; border-width: 0px 0.8px; border-image: none 100% / 1 / 0 stretch; --bs-border-opacity: 1; --bs-table-bg: theme.white; padding: 0.5rem; box-shadow: rgba(0, 0, 0, 0) 0px 0px 0px 9999px inset;">

5

white;padding:0.5rem;box−shadow:rgba(0,0,0,0)0px0px0px9999pxinset;"><p><strong>7</strong></p></td></tr></tbody></table><p><br><strong>Is5==7?NO</strong></p><p><strong>Is5 >7?NO−createnewlistwithvaluestotheright</strong></p><tablestyle="min−width:25px;"><colgroup><colstyle="min−width:25px;"></colgroup><tbody><tr><tdcolspan="1"rowspan="1"style="box−sizing:border−box;border−width:0px0.8px;border−image:none100white; padding: 0.5rem; box-shadow: rgba(0, 0, 0, 0) 0px 0px 0px 9999px inset;"><p><strong>7</strong></p></td></tr></tbody></table><p><br><strong>Is 5 == 7? NO</strong></p><p><strong>Is 5  > 7? NO - create new list with values to the right</strong></p><table style="min-width: 25px;"><colgroup><col style="min-width: 25px;"></colgroup><tbody><tr><td colspan="1" rowspan="1" style="box-sizing: border-box; border-width: 0px 0.8px; border-image: none 100% / 1 / 0 stretch; --bs-border-opacity: 1; --bs-table-bg: theme.white; padding: 0.5rem; box-shadow: rgba(0, 0, 0, 0) 0px 0px 0px 9999px inset;">

7


Is 7 == 7? YES

STOP!


Binary Search