예제 #1
0
 def test_case_2(self):
     self.assertEqual([1, 2, 3], bubble_sort([1, 2, 3]))
     self.assertEqual([1, 2, 3], bubble_sort([1, 3, 2]))
     self.assertEqual([1, 2, 3], bubble_sort([2, 1, 3]))
     self.assertEqual([1, 2, 3], bubble_sort([2, 3, 1]))
     self.assertEqual([1, 2, 3], bubble_sort([3, 2, 1]))
     self.assertEqual([1, 2, 3], bubble_sort([3, 1, 2]))
예제 #2
0
from search.linear import linear_search
from search.binary import binary_search
from sort.select import select_sort
from sort.insert import insert_sort
from sort.bubble import bubble_sort
from sort.merge import merge_sort
from sort.quick import quick_sort

data1 = [i for i in range(10)]
print(linear_search(data1, 4))
print(binary_search(data1, 4))

data2 = [1, 4, 0, 6, 7]
print(select_sort(data2))
print(insert_sort(data2))
print(bubble_sort(data2))
print(merge_sort(data2))
print(quick_sort(data2))
예제 #3
0
 def test_case_base(self):
     self.assertEqual([], bubble_sort([]))
     self.assertEqual([1], bubble_sort([1]))
     self.assertEqual(['a'], bubble_sort(['a']))
     self.assertEqual([[]], bubble_sort([[]]))
예제 #4
0
 def test_case_3(self):
     self.assertEqual(sorted(list("dhausdhuashdfjasjdfkjaskldf")),
                      bubble_sort(list("dhausdhuashdfjasjdfkjaskldf")))
예제 #5
0
 def test_case_1(self):
     self.assertEqual([1, 2], bubble_sort([1, 2]))
     self.assertEqual([1, 2], bubble_sort([2, 1]))
     self.assertEqual(['a', 'b'], bubble_sort(['a', 'b']))
     self.assertEqual(['a', 'b'], bubble_sort(['b', 'a']))
예제 #6
0
# -*- coding:utf-8 -*-
"""
author:
date:
version:
content:
"""
from sort import bubble, insert, shell, quick, select, heap
from tools import generate_list

if __name__ == '__main__':
    source = generate_list(14, True)
    print(bubble.bubble_sort(source.copy()))
    print(insert.insert_sort(source.copy()))
    print(shell.shell_sort(source.copy()))
    s = source.copy()
    quick.quick_sort(s, 0, len(s) - 1)
    print(s)
    print(select.simple_select_sort(source.copy()))
    print(heap.heap_sort(source.copy()))
    print(source)