Deprecated: Methods with the same name as their class will not be constructors in a future version of PHP; plgContentJComments has a deprecated constructor in /var/www/astarmathsandphysics/plugins/content/jcomments/jcomments.php on line 25 Call Stack: 0.0001 360728 1. {main}() /var/www/astarmathsandphysics/index.php:0 0.0557 1209376 2. Joomla\CMS\Application\SiteApplication->execute() /var/www/astarmathsandphysics/index.php:49 0.0557 1209376 3. Joomla\CMS\Application\SiteApplication->doExecute() /var/www/astarmathsandphysics/libraries/src/Application/CMSApplication.php:267 0.1272 4036848 4. Joomla\CMS\Application\SiteApplication->dispatch() /var/www/astarmathsandphysics/libraries/src/Application/SiteApplication.php:233 0.1286 4064400 5. Joomla\CMS\Component\ComponentHelper::renderComponent() /var/www/astarmathsandphysics/libraries/src/Application/SiteApplication.php:194 0.1293 4082112 6. Joomla\CMS\Component\ComponentHelper::executeComponent() /var/www/astarmathsandphysics/libraries/src/Component/ComponentHelper.php:356 0.1294 4099120 7. require_once('/var/www/astarmathsandphysics/components/com_content/content.php') /var/www/astarmathsandphysics/libraries/src/Component/ComponentHelper.php:381 0.1302 4106856 8. ContentController->execute() /var/www/astarmathsandphysics/components/com_content/content.php:42 0.1302 4106856 9. ContentController->display() /var/www/astarmathsandphysics/libraries/src/MVC/Controller/BaseController.php:710 0.2058 4341456 10. ContentController->display() /var/www/astarmathsandphysics/components/com_content/controller.php:113 0.2074 4358856 11. Joomla\CMS\Cache\Controller\ViewController->get() /var/www/astarmathsandphysics/libraries/src/MVC/Controller/BaseController.php:663 0.2080 4379784 12. ContentViewArticle->display() /var/www/astarmathsandphysics/libraries/src/Cache/Controller/ViewController.php:102 0.2172 4446656 13. Joomla\CMS\Plugin\PluginHelper::importPlugin() /var/www/astarmathsandphysics/components/com_content/views/article/view.html.php:189 0.2172 4446912 14. Joomla\CMS\Plugin\PluginHelper::import() /var/www/astarmathsandphysics/libraries/src/Plugin/PluginHelper.php:182 Deprecated: Methods with the same name as their class will not be constructors in a future version of PHP; JCommentsACL has a deprecated constructor in /var/www/astarmathsandphysics/components/com_jcomments/classes/acl.php on line 17 Call Stack: 0.0001 360728 1. {main}() /var/www/astarmathsandphysics/index.php:0 0.0557 1209376 2. Joomla\CMS\Application\SiteApplication->execute() /var/www/astarmathsandphysics/index.php:49 0.0557 1209376 3. Joomla\CMS\Application\SiteApplication->doExecute() /var/www/astarmathsandphysics/libraries/src/Application/CMSApplication.php:267 0.1272 4036848 4. Joomla\CMS\Application\SiteApplication->dispatch() /var/www/astarmathsandphysics/libraries/src/Application/SiteApplication.php:233 0.1286 4064400 5. Joomla\CMS\Component\ComponentHelper::renderComponent() /var/www/astarmathsandphysics/libraries/src/Application/SiteApplication.php:194 0.1293 4082112 6. Joomla\CMS\Component\ComponentHelper::executeComponent() /var/www/astarmathsandphysics/libraries/src/Component/ComponentHelper.php:356 0.1294 4099120 7. require_once('/var/www/astarmathsandphysics/components/com_content/content.php') /var/www/astarmathsandphysics/libraries/src/Component/ComponentHelper.php:381 0.1302 4106856 8. ContentController->execute() /var/www/astarmathsandphysics/components/com_content/content.php:42 0.1302 4106856 9. ContentController->display() /var/www/astarmathsandphysics/libraries/src/MVC/Controller/BaseController.php:710 0.2058 4341456 10. ContentController->display() /var/www/astarmathsandphysics/components/com_content/controller.php:113 0.2074 4358856 11. Joomla\CMS\Cache\Controller\ViewController->get() /var/www/astarmathsandphysics/libraries/src/MVC/Controller/BaseController.php:663 0.2080 4379784 12. ContentViewArticle->display() /var/www/astarmathsandphysics/libraries/src/Cache/Controller/ViewController.php:102 0.3417 12236728 13. JEventDispatcher->trigger() /var/www/astarmathsandphysics/components/com_content/views/article/view.html.php:199 0.3420 12237176 14. plgContentJComments->update() /var/www/astarmathsandphysics/libraries/joomla/event/dispatcher.php:160 0.3420 12237176 15. plgContentJComments->onContentAfterDisplay() /var/www/astarmathsandphysics/libraries/joomla/event/event.php:70 0.3422 12245424 16. plgContentJComments->onAfterDisplayContent() /var/www/astarmathsandphysics/plugins/content/jcomments/jcomments.php:339 0.3424 12247160 17. JComments::show() /var/www/astarmathsandphysics/plugins/content/jcomments/jcomments.php:282 0.3430 12280208 18. JCommentsFactory::getACL() /var/www/astarmathsandphysics/components/com_jcomments/jcomments.php:188 0.3430 12280608 19. spl_autoload_call() /var/www/astarmathsandphysics/components/com_jcomments/classes/factory.php:274 0.3431 12280688 20. JLoader::load() /var/www/astarmathsandphysics/components/com_jcomments/classes/factory.php:274

The Quick Sort Algorithm

The mid-point of a list has position [½(N+1)]

where [x] is the smallest integer greater than or equal to x

e.g. for 3, 6, 7, 11, 15 [½ (5+1)] = [3] = 3 mid-point = 7

for A, C, Y, B, D, R [½ (6+1)] = [3½] = 4 mid-point = B

Step 1

Locate the pivot element (use the element at the mid-point)

Step 2

Split the list into two sub-lists.

Sublist L1 contains those numbers less than or equal to the pivot and are written to the left of the pivot.

Sublist L2 contains those numbers greater than the pivot element and are written to the right of the pivot.

Do not reorder the numbers in the sub-lists

Step 3

Repeat Step 2 on each sub-list and each successive sub-list

Step 4

Stop when each sub-list contains only one number. The list is now sorted!

Example

Use a quick-sort to arrange these numbers in numerical order

27 15 2 19 16 1

Mid-point = [½(6+1)] = [3½] = 4th number = 19

27 15 2 19 16 1

15 2 16 1 19 27

L1 L2

15 2 16 1 19 27

15 2 1 16 19 27

L1 L2

15 2 1 16 19 27

1 2 15 16 19 27 Stop

Example

Use a quick-sort to arrange these letters in alphabetical order.

Y T A B F S F L

Mid-point = [½(8 + 1)] = [4½] = 5th letter = F

The pivot point is underlined at each stage.

Y T A B F S F L

A B F F Y T S L

A B F F L S Y T

A B F F L S T Y Stop

Example

Use a quick-sort to arrange these letters in numerical order.

16 21 15 3 12 9 27 6 18 17

Mid-point = [½(10 + 1)] = [5½] = 6th number = 9

The pivot point is underlined at each stage.

16 21 15 3 12 9 27 6 18 17

3 6 9 16 21 15 12 27 18 17

3 6 9 12 16 21 15 27 18 17

3 6 9 12 16 21 15 18 17 27

3 6 9 12 15 16 21 18 17 27

3 6 9 12 15 16 17 18 21 27

3 6 9 12 15 16 17 18 21 27 STOP

Common Errors

1) The choice of pivot must be constant. If you have an even number of items in a list, the middle number is not clear. If you choose the right-hand number the first time, you must continue to select the right-hand number each time you have a choice.

2) Do not be tempted to reorder the items in a sub-list.

3) Remember that it is the method that is being assessed and not the answer. So make sure enough working is being shown. The list should be rewritten each time a new sub-list is created.

4) Remember to indicate the stop step.

Add comment

Security code
Refresh