divyang4481 / mipt-hw

Automatically exported from code.google.com/p/mipt-hw
0 stars 0 forks source link

task07 Сравнение Сортировок (Яковенко) #147

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
iakovenko_pavel/task07_Comparision

Не смог дождаться выполнения InsertSort на 
массиве свыше 1е7. Больше 12 часов 
выполнялось.

Original issue reported on code.google.com by iakovenk...@gmail.com on 1 Dec 2012 at 5:40

Attachments:

GoogleCodeExporter commented 9 years ago
1. Warnings:

main.cpp: In function ‘int main()’:
main.cpp:27: warning: format ‘%Lf’ expects type ‘long double’, but 
argument 2 has type ‘double’
main.cpp:27: warning: format ‘%Lf’ expects type ‘long double’, but 
argument 2 has type ‘double’
main.cpp:34: warning: format ‘%Lf’ expects type ‘long double’, but 
argument 2 has type ‘double’
main.cpp:34: warning: format ‘%Lf’ expects type ‘long double’, but 
argument 2 has type ‘double’
main.cpp:41: warning: format ‘%Lf’ expects type ‘long double’, but 
argument 2 has type ‘double’
main.cpp:41: warning: format ‘%Lf’ expects type ‘long double’, but 
argument 2 has type ‘double’
main.cpp:48: warning: format ‘%Lf’ expects type ‘long double’, but 
argument 2 has type ‘double’
main.cpp:48: warning: format ‘%Lf’ expects type ‘long double’, but 
argument 2 has type ‘double’
main.cpp:55: warning: format ‘%Lf’ expects type ‘long double’, but 
argument 2 has type ‘double’
main.cpp:55: warning: format ‘%Lf’ expects type ‘long double’, but 
argument 2 has type ‘double’
main.cpp:62: warning: format ‘%Lf’ expects type ‘long double’, but 
argument 2 has type ‘double’
main.cpp:62: warning: format ‘%Lf’ expects type ‘long double’, but 
argument 2 has type ‘double’

2. Не забывайте #pragma once в h-файлах

3. Чтобы каждый раз не ждать генерации 
случайных данных, можно один раз их 
сгенерировать. А потом копировать для 
каждого теста.

4. Интересно, что RadixSort у Вас обгоняет qsort. Но 
вот что HeapSort обгоняет qsort - совсем странно.
Запустил Ваш тест на своей машинке (для n = 
1e8):
MergeSort   time:34.742203s correct:true
QuickSort   time:28.858165s correct:true
RadixSort   time:40.189876s correct:true
HeapSort    time:131.801105s    correct:true
qsort   time:40.472078s correct:true

Вы точно ничего не перепутали?

Решение не принято.

Original comment by aivyu...@gmail.com on 22 Dec 2012 at 11:49

GoogleCodeExporter commented 9 years ago
И еще момент: обычно принято называть h и cpp 
файлы одинаково: functions.h и functions.cpp, например.

Тогда понятно, что к чему относится.

Original comment by aivyu...@gmail.com on 22 Dec 2012 at 11:51

GoogleCodeExporter commented 9 years ago
Я нашел ошибку. Я не включил генератор 
случайных чисел, поэтому массив состоял из 
одного числа. Исправил.

Original comment by iakovenk...@gmail.com on 22 Dec 2012 at 7:46

Attachments:

GoogleCodeExporter commented 9 years ago
На картинке теперь MergeSort обгоняет qsort, что 
очень странно :)

Думаю, где-то еще баг. Может быть где-то 
время направильно меряете?

Original comment by aivyu...@gmail.com on 22 Dec 2012 at 8:18

GoogleCodeExporter commented 9 years ago
Юлий Романович, нашел ошибку в QuickSort. 
Поправил. Он стал быстрее. Но вот с qsort 
ничего поделать не могу. Может вы когда 
нибудь встречались с этим?

Original comment by iakovenk...@gmail.com on 23 Dec 2012 at 7:25

Attachments:

GoogleCodeExporter commented 9 years ago
Посмотрел код. Сам с ходу не вижу...

Решение принято.

Original comment by aivyu...@gmail.com on 23 Dec 2012 at 9:41