<Table> <Tr> <Th> Algorithm </Th> <Th> Data structure </Th> <Th> Time complexity : Best </Th> <Th> Time complexity : Average </Th> <Th> Time complexity : Worst </Th> <Th> Space complexity : Worst </Th> </Tr> <Tr> <Td> Quick sort </Td> <Td> Array </Td> <Td> O ( n log ( n ) ) </Td> <Td> O ( n log ( n ) ) </Td> <Td> O ( n ) </Td> <Td> O ( n ) </Td> </Tr> <Tr> <Td> Merge sort </Td> <Td> Array </Td> <Td> O ( n log ( n ) ) </Td> <Td> O ( n log ( n ) ) </Td> <Td> O ( n log ( n ) ) </Td> <Td> O ( n ) </Td> </Tr> <Tr> <Td> Heap sort </Td> <Td> Array </Td> <Td> O ( n log ( n ) ) </Td> <Td> O ( n log ( n ) ) </Td> <Td> O ( n log ( n ) ) </Td> <Td> O ( 1 ) </Td> </Tr> <Tr> <Td> Smooth sort </Td> <Td> Array </Td> <Td> O ( n ) </Td> <Td> O ( n log ( n ) ) </Td> <Td> O ( n log ( n ) ) </Td> <Td> O ( 1 ) </Td> </Tr> <Tr> <Td> Bubble sort </Td> <Td> Array </Td> <Td> O ( n ) </Td> <Td> O ( n ) </Td> <Td> O ( n ) </Td> <Td> O ( 1 ) </Td> </Tr> <Tr> <Td> Insertion sort </Td> <Td> Array </Td> <Td> O ( n ) </Td> <Td> O ( n ) </Td> <Td> O ( n ) </Td> <Td> O ( 1 ) </Td> </Tr> <Tr> <Td> Selection sort </Td> <Td> Array </Td> <Td> O ( n ) </Td> <Td> O ( n ) </Td> <Td> O ( n ) </Td> <Td> O ( 1 ) </Td> </Tr> </Table>
<Table> <Tr> <Th> Algorithm </Th> <Th> Data structure </Th> <Th> Time complexity : Best </Th> <Th> Time complexity : Average </Th> <Th> Time complexity : Worst </Th> <Th> Space complexity : Worst </Th> </Tr> <Tr> <Td> Quick sort </Td> <Td> Array </Td> <Td> O ( n log ( n ) ) </Td> <Td> O ( n log ( n ) ) </Td> <Td> O ( n ) </Td> <Td> O ( n ) </Td> </Tr> <Tr> <Td> Merge sort </Td> <Td> Array </Td> <Td> O ( n log ( n ) ) </Td> <Td> O ( n log ( n ) ) </Td> <Td> O ( n log ( n ) ) </Td> <Td> O ( n ) </Td> </Tr> <Tr> <Td> Heap sort </Td> <Td> Array </Td> <Td> O ( n log ( n ) ) </Td> <Td> O ( n log ( n ) ) </Td> <Td> O ( n log ( n ) ) </Td> <Td> O ( 1 ) </Td> </Tr> <Tr> <Td> Smooth sort </Td> <Td> Array </Td> <Td> O ( n ) </Td> <Td> O ( n log ( n ) ) </Td> <Td> O ( n log ( n ) ) </Td> <Td> O ( 1 ) </Td> </Tr> <Tr> <Td> Bubble sort </Td> <Td> Array </Td> <Td> O ( n ) </Td> <Td> O ( n ) </Td> <Td> O ( n ) </Td> <Td> O ( 1 ) </Td> </Tr> <Tr> <Td> Insertion sort </Td> <Td> Array </Td> <Td> O ( n ) </Td> <Td> O ( n ) </Td> <Td> O ( n ) </Td> <Td> O ( 1 ) </Td> </Tr> <Tr> <Td> Selection sort </Td> <Td> Array </Td> <Td> O ( n ) </Td> <Td> O ( n ) </Td> <Td> O ( n ) </Td> <Td> O ( 1 ) </Td> </Tr> </Table>
the best-case behavior of insertion sort is -- -- -- --
the best-case behavior of insertion sort is -- -- -- --
O ( n )
O ( n )