- 2.6 SORTING TECHNIQUES
- WHY IS EFFICIENT SORTING SO IMPORTANT?
- Sorting is very important so we can carry out efficient Binary Searches on large databases.
- Interactive systems rely on data being retrieved from these systems quickly.
- For example : Amazon
- BUBBLE SORT
- Start at the beginning of the list.
- Compare each pair of items.
- If they are not in order swap them.
- Work through the list n-1 times.
- Let’s look at an example.....
- INSERTION SORT
- Advantage
- Faster than a Bubble Sort
- Disadvantage
- More complex to code.
- In an Insertion Sort each element in turn is inserted into its correct place in the sorted list.
- The next element to be inserted into the correct place is shown in red. The sorted part of the list is green
No comments:
Post a Comment