Câu hỏi phỏng vấn Sorting
Câu hỏi

When is each Sorting algorithm used?

Câu trả lời

Here is a concise overview of when each sorting algorithm is commonly used:

Bubble Sort

  • Used for small datasets
  • When simplicity is more important than efficiency
  • When the input is already mostly sorted[1][2]

Selection Sort

  • Used for small datasets
  • When memory usage is a concern, as it is an in-place algorithm[1][2]

Insertion Sort

  • Used for small datasets
  • When the input is already mostly sorted, as it has a linear time complexity in this case[1][2][4]
  • When data is being sorted as it comes in, as it can efficiently insert new elements into a sorted list[2]

Merge Sort

  • Used for large datasets
  • When stability is required, as it is a stable sorting algorithm[1][2][4]
  • When the data is stored externally and needs to be divided and merged efficiently[2]
  • When sorting linked lists, as it can efficiently split and merge linked lists[2]

Quick Sort

  • Used for large datasets
  • When space is limited, as it is an in-place algorithm[1][2][4]
  • When the input data has many duplicates[4]

Heap Sort

  • Used for large datasets
  • When an in-place sorting algorithm is required[1][2]

Radix Sort

  • Used...
middle

middle

Gợi ý câu hỏi phỏng vấn

middle

When is Quicksort better than Mergesort?

middle

What's the difference between External vs Internal sorting?

junior

Classify Sorting Algorithms

Bình luận

Chưa có bình luận nào

Chưa có bình luận nào