What is the Insertion Sort Code?.



What is the Insertion Sort Code?...

Answer / Amit Chauhan

Here's a simple implementation of Insertion Sort in Python:n```pythonndef insertion_sort(arr):n n = len(arr)n for i in range(1, n):n key = arr[i]n j = i - 1n while j >= 0 and key < arr[j]:n arr[j + 1] = arr[j]n j -= 1n arr[j + 1] = keyn return arr

Is This Answer Correct ?    0 Yes 0 No

Post New Answer

More Data Structures Interview Questions

Why do we need to recycle?

1 Answers  


What sort does arrays sort use?

1 Answers  


What data type is enum?

1 Answers  


Explain what are the major data structures used in the hierarchical data model?

1 Answers  


How do stacks work?

1 Answers  


Name two algorithms two find minimum spanning tree?

1 Answers  


Does stringutils isempty check for null?

1 Answers  


Which collection type is used to maintain uniqueness of data structure?

1 Answers  


Are dictionaries mutable?

1 Answers  


What is difference between hashmap and hashset?

1 Answers  


Difference between arrays and linked list?

1 Answers  


what is Linked lists?

1 Answers  


Categories