Fundamentals of algorithms- module 3) Sorting Flashcards
What is the definition of a sort?
Sorting algorithms find things quickly by putting data into a sort order.
What are the 2 types of sort?
1) Merge sort.
2) Bubble sort.
What is a merge sort (also known as divide and conquer sort)?
Like a binary search, a merge sort splits data in half and works on each half in turn the computer sorts both small groups before merging the small groups together again.
What does a computer do to complete a merge sort?
1) Repeatedly splits data in 2 halves until each list contains only a single data item.
2) Merges these 2 lists back together in order (descending or ascending).
What is bubble sort (also known as sinking sort)?
Slow methodical nature.
Compares which of the 1st 2 items is larger then swaps so that the larger is 1st.
Then checks next one.
If any position changes have happened, whole process is begun again until computer can go from start to finish + no changes to be made. At this point data is in descending order.
What is the definition of descending?
Decreasing in number to 1 downwards, or in value from A.
What is the definition of ascending?
Increasing in number to 1 upwards or in value from Z.
What are the advantages of bubble sort?
Space used in memory stable/ never changes as items just swapped about.
Good for sorting a very small volume of data.
What are the disadvantages of bubble sort?
Very slow.
Can’t efficiently handle a large data set.
What are the advantages of merge sort?
Can efficiently handle a large data set.
Very quick.
What are the disadvantages of merge sort?
Uses more memory and variable amounts of memory as has to split data in 2 each time.