Mapa mental
Searching
Conteúdo do mapa
Searching
The simplest search method is to start at the top, and check every element until the search term is found, or the entire list has been searched. This is called a Linear Search.
- Advantages Simple algorithm Works on any list Disadvantages Slow on large lists
If the data is ordered, then a binary search can be used. With a binary search, we check the middle value of the list, then depending on whether it is higher or lower than the search value, eliminate half and try again.
- Advantages Very fast on large lists Disadvantages Only works if the data is sorted
Sorting
- Merge sort as a divide and conquer algorithm where: An unsorted list is divided into n sublists, each containing 1 element. The sublists are repeatedly merged to produce new sorted sublists until there is only 1 sorted sublist remaining.
- Bubble sort as a simple sorting algorithm where: The algorithm that repeatedly stepsthrough the list to be sorted. The algorithm compares each pair of adjacent items and swaps them if they are in the wrong order. The passes through the list are repeated until no swaps are needed