Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Please see screenshot attached. The value of comparison count is not 4 5 I dont know where is mistake. In this part you will investigate

Please see screenshot attached. The value of comparison count is not 45 I dont know where is mistake.
In this part you will investigate how many comparisons between list items exchange sort requires to sort some lists of different lengths.
i.To count the comparisons, we have provided a variable comparison_count.
The only place where list items are compared is in the when_green_flag_clicked script. Add a block to this script at an appropriate point to increment comparison_count each time two list items are compared.
We are not quite done, because comparison_count needs to be initialised to 0 at the start of the when_green_flag_clicked script, before we start the sort. Add a block to initialise comparison_count at an appropriate point in the script.
Then make sure the watcher for comparison_count is visible on the stage, and run the when_green_flag_clicked script.
You should find that once the script has run the value of comparison_count is 45.
image text in transcribed

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Students also viewed these Databases questions