Flashcards
COMP 2
Flashcards do conjunto (6)
- 1Bubble sortCompares each pair of adjacent elements from the beginning of the array to the end, then swaps said adjacent elements if they are in the wrong order until no more swaps are needed (n - 1 times).
- 2Selection sortSplit the data into two arrays, sorted and unsorted. First iteration you find the minimum element in the whole array then swap it with element 0, you do this for each element in the array.
- 3Insertion sortYou Divide the array into a sorted portion and unsorted portion, you sort each element in the unsorted portion by comparing each element and then swapping it into the sorted portion if it's out of order, you do this for each element in the array.
- 4Shell sortH sorting with decreasing values of H including one, H sort is like insertion sort except you sort elements H distance away from each other instead of by 1.
- 5Heap sortYou heapify the array then remove the maximum element n - 1 times. Heapify turns an array into a heap representation by calling fix down by starting in the middle of the array ignoring all the leaf nodes and going from the middle to the beginning calling fixed down on the nodes.
- 6QuicksortYou have a pivot, a left handle and a right handle. You select a pivot (an element) then you put all the elements smaller than the pivot to the left, and all the elements that are larger to the right of the pivot, after that’s done you call quicksort on the left and the right. You then use the handles to find an element where they meet, ultimately swapping the pivot. You then do this until no more elements need to be swapped.
Informações
- Descrição
- Information Technology FlashCards sobre COMP 2, criado por Aryaman Shah em 19-04-2024.
- Criado por
- Aryaman Shah
- Visualizações
- 0
- Avaliação