COMP.1020 Exam II

studied byStudied by 57 people
5.0(1)
learn
LearnA personalized and smart learning plan
exam
Practice TestTake a test on your terms and definitions
spaced repetition
Spaced RepetitionScientifically backed study method
heart puzzle
Matching GameHow quick can you match all your cards?
flashcards
FlashcardsStudy terms and definitions
Get a hint
Hint

Bubble Sort

1 / 18

encourage image

There's no tags or description

Looks like no one added any tags here yet for you.

19 Terms

1

Bubble Sort

Starting from the beginning of a list compare adjacent pairs, if they are out of order swap them, do this for the entire list n-1 times.

New cards
2

Selection Sort

The smallest element is selected from a list and swapped with the leftmost element, and that element becomes a part of the sorted array. This process continues, swapping the smallest element found in the unsorted list to the end of the sorted list, do this n-1 times.

New cards
3

Insertion Sort

Assume first item in the list is a sorted list, take the element in the unsorted list that is adjacent to the sorted list and swap it into the correct position in the sorted list, do this n-1 times.

New cards
4

Shell Sort

h sort the list with decreasing values of h, until and including h = 1. h sort is just insertion sort but instead of looking at items that are 1 apart look at items that are h apart.

New cards
5

Heap Sort

Heapify the array, remove the max n-1 times. Call fix down on every node in the tree, starting from the back of the array, ignoring leaf nodes.

New cards
6

Quick Sort

Pick a pivot and move it over to the edge of the list. Do an operation so all items that are smaller end up on the left of the pivot and all items that are greater than the pivot end up to the right of it. This is done by first scanning from the right of the list until an item that should be to the left of the pivot is found. Then scan from the left until an item that should be to the right of the pivot is found. Swap them. Do this until the until the scanners both meet at one item. Then swap the pivot in to that location.

New cards
7

Pre-order Traversal

SLR

New cards
8

In-order Traversal

LSR

New cards
9

Post-order Traversal

LRS

New cards
10

Complete Tree

Filled top to bottom, left to right

New cards
11

Full Tree

Every node that has a child has the maximum amount of children, in our case that is 2 children.

New cards
12

BST - Binary Search Tree

If value if greater it gets placed to the right, if smaller goes to the left.

New cards
13

Heap

Make sure that the parent is bigger than the child and fill top to bottom left to right

New cards
14

Heapify

Call fix down on every node in the tree, starting from the back of the array, ignoring leaf nodes.

New cards
15

Fix Down

Compare parent to its children, swap it with the largest of its children. *This is often done recursively, so then after swapping you compare the node just brought in to its new children and swap until you cannot anymore.

New cards
16

Remove Max

To remove the max take the largest value of the nodes and swap it with the lowest and rightmost leave node. Then pretend that the largest node is gone and call fix down until the node that was swapped to the root is now in the right location. *Doing this to every element of a list creates a sorted list.

New cards
17

Improvements to Insertion Sort

Sentinel Value and Shifting

New cards
18

What is the shifting improvement for insertion sort?

Instead of assigning the value of the element you are trying to insert into the sorted list and then comparing again. Compare it to each value until you find the correct index to insert the value into.

New cards
19

What is the sentinel improvement for insertion sort?

Do 1 round of selection sort before doing insertion sort. Do not comparison to the first element in the sorted list (the sentinel).

New cards

Explore top notes

note Note
studied byStudied by 11 people
838 days ago
5.0(1)
note Note
studied byStudied by 2 people
12 days ago
5.0(1)
note Note
studied byStudied by 46 people
720 days ago
5.0(2)
note Note
studied byStudied by 13 people
456 days ago
5.0(1)
note Note
studied byStudied by 7 people
707 days ago
5.0(1)
note Note
studied byStudied by 99 people
802 days ago
5.0(1)
note Note
studied byStudied by 7 people
673 days ago
5.0(1)
note Note
studied byStudied by 164 people
576 days ago
4.0(4)

Explore top flashcards

flashcards Flashcard (166)
studied byStudied by 1 person
110 days ago
5.0(1)
flashcards Flashcard (152)
studied byStudied by 3 people
229 days ago
5.0(1)
flashcards Flashcard (105)
studied byStudied by 2 people
765 days ago
4.0(283)
flashcards Flashcard (98)
studied byStudied by 20 people
423 days ago
5.0(1)
flashcards Flashcard (20)
studied byStudied by 5 people
445 days ago
5.0(1)
flashcards Flashcard (123)
studied byStudied by 8 people
79 days ago
5.0(1)
flashcards Flashcard (88)
studied byStudied by 16 people
267 days ago
4.0(1)
flashcards Flashcard (106)
studied byStudied by 4 people
368 days ago
5.0(1)
robot