Bubble in Array Issue with calculating checksum (task 23)

Back to General discussions forum

tinzendA     2015-02-19 22:28:13

The code i use calculates the first checksum problem accurately, but not the example data. The value i get is diff on either sorted or unsorted. I even calculated the checksum(for the example data) on a calculator and get the same value as my code. I can't see what i'm doing wrong, is it possible there is a mistake in the task?

Christopher Matthews     2015-02-20 08:01:43

There's no mistake in the task. You need to calculate the checksum of the (partially) sorted array; i.e., loop over each value and perform necessary calculations.

Christopher P. Matthews

tinzendA     2015-02-20 12:29:21

Blast!!. The task states to perform the checksum on the array after processing. How did you know to only partially sort? Thank you.

tinzendA     2015-02-20 14:05:10

Sorry disregard that, i got it. Thank you.

Rodion (admin)     2015-02-20 16:55:54
User avatar

Hi! Thanks for your question!

I'm sorry for failing to respond speedy enough (and thankful to Christopher for help). And sorry if this problem is somewhat clumsy... It was created long ago when the site have few options to check answer...

Please feel free to suggest any improvement or clarification to problem statement if you feel it is vague or misleading! Be sure it was not my intention to make you feel frustrated :)

Alex Charlton     2015-10-14 07:59:44

Hi, I have also been having problems with this task, I have correctly done the Array checksum task,

So I know there is no issue with that, Also I have successfully writen the bubble sorting code (As the number of swaps is successful when I submit it through codeabbey)

My question is, When should I be performing the checksum on the array? As It's not very clear at all in the description of the task, and I've spent hours now trying to figure it out,

Thanks!

Quandray     2015-10-14 10:30:07
User avatar

Hello Alex,

For the example, you start with 143265 and end up with 132456. You need the checksum of 132456, i.e.
1 x 113 = 113
113 + 3 = 116, 116 x 113 = 13108
13108 + 2 = 13110, 13110 x 113 = 1481430
1481430 + 4 = 1481434, 1481434 x 113 = 167402042, 167402042 mod 10000007 = 7401930
7401930 + 5 = 7401935, 7401935 x 113 = 836418155, 836418155 mod 10000007 = 6418074
6418074 + 6 = 6418080, 6418080 x 113 = 725243040, 725243040 mod 10000007 = 5242536

Alex Charlton     2015-10-14 12:23:58

Hi Quandray,

Thank you for your reply,

Unfortunately this is what I've been trying,

I Shall give it another go, see if I can solve it,

Thanks again.

Rodion (admin)     2015-10-15 05:56:38
User avatar

Alex, Hi!

Sorry for late response! Here is a link to your current solution.

It seems that you perform full sort of the array instead of just a single pass - aren't you?

BTW, thanks a lot to Quandray who emailed me about my stupid typo in the example for this problem.

Quandray     2015-10-15 06:26:25
User avatar

Hi Alex,

Nicely commented code, but I'd suggest you make sure you get the correct answer with the "Example data" before moving on to the "Test data"

Alex Charlton     2015-10-15 07:16:09

Hi, Thank you for all the replies,

Thanks Quandray, I'm new to C++ so I have a lot to learn, so I find adding a lot of comments is good for looking back,

My main language is C# but I really want to learn C++ aswell,

Thank you both for the tips

Alex Charlton     2015-10-15 07:54:58

Finally managed to solve it! Thanks again guys

FoxDie     2016-03-11 18:37:25

Can we Add Quandray's explantion to the explanation to that problem? It greatly cleared up on how to do the problem

Taxometr     2016-06-01 04:47:22
User avatar

Жаль, что слово "частично" отсортированный массив не фигурирует в задании =(

OneMoreTime     2016-11-23 02:38:18

What should be done is to edit the statement and say clearly: "As soon as the major element of the array goes to the last position, you must immediately make the sum checksum", thus avoiding confusion

Please login and solve 5 problems to be able to post at forum