Data Structures Final

0.0(0)
studied byStudied by 0 people
learnLearn
examPractice Test
spaced repetitionSpaced Repetition
heart puzzleMatch
flashcardsFlashcards
Card Sorting

1/20

encourage image

There's no tags or description

Looks like no tags are added yet.

Study Analytics
Name
Mastery
Learn
Test
Matching
Spaced

No study sessions yet.

21 Terms

1
New cards

Merge Sort O?

All: O(nlogn)

2
New cards

Bubble Sort O?

B: O(n) W: O(n²) A: O(n²)

3
New cards

Selection Sort

All: O(n²)

4
New cards

Insertion Sort

Best: O(n) Worst: O(n²) Av: O(n²)

5
New cards

Quick Sort

Best: O(nlogn) Worst: O(n²) Av: O(nlogn)

6
New cards

Tree

Acyclic, connected, n-1 edges, n=nodes/vertices

7
New cards

BST & AVL Linked&ArrayList O?

Searching, Insertion, and Deletion: O(logn). BST Worst A(n).

Linked&Array: at least one of methods will be O(n).

8
New cards

Full, Complete, and Regular Binary Tree

Binary tree

– A tree where every node has at most two child nodes

Full binary tree

– A binary tree that has exactly two child nodes and is fully occupied

Complete binary tree

– When a binary tree is not fully occupied, a complete binary tree is the closest approximation to a full binary tree

9
New cards

BST Case 3 Delete

Smallest element in right tree of deleted node takes the place of the deleted node (move right, then try/spam left, if not right then again, until null).

10
New cards

Balance Factor

+-1, 0, right-left

11
New cards

Breadth First Search

O(|V| + |E|), Prioritizes visiting nodes closer in distance to the starting node

12
New cards

Depth First Search

O(|V| + |E|), visits connected nodes based on the node currently being explored

13
New cards

Prim

For finding MST, Min Spanning Tree, O(|E| log| V|). From all claimed nodes,chooses the next cheapest edge. Only claims a node once.

14
New cards

Dijkstras

for finding shortest path; no negative weights; O(|E| log| V|). Chooses the next cheapest path from r to reach an adjacent node from the claimed nodes.

15
New cards

Chaining P/C

  • Better with High Load Factors

    • (can be used when (n #keys/m total slots ) > 1)

  • Increased look up time for key due to LinkedList

  • Requires more memory

16
New cards

Mult Hash P/C

Multiply input value by A, then by table length (m)

  • Distributes hash values evenly

  • Often O(1) FAST

  • Not flexible to changing hash table size, or data distributions

  • If A isnt irrational its mid

17
New cards

Division Hash P/C

input % m

  • Simple and fast computations

  • Excess space typically, so memory inefficient

18
New cards

Open Addressing P/C

Linear/Quadratic Probing/ Double Hashing

  • Very memory efficient

  • Clustering

  • Deletion complexity (need to mark deleted)

  • If run out of space and Hash table must double, all saved keys should be relocated

19
New cards

Complete and Simple Graph

C: Max # edges for vertices(n) = n(n-1)/2

S: no self loops or duplicate edges

20
New cards

Adjacency Matrix P/C

two vertices (i, j) stored as 1 or weight # in matrix

if directional, first vertex # goes to second #

  • Easy to understand and confirm edges

  • Best for high edge density

  • Space inefficient

  • Lots of time to fill matrix, n²

21
New cards

Adjacency List

Edges that dont exist arent in list at all.

Slot # is Vertex, then following link #s are the edges to the vertex # that exist from such orginal slot # vertex

  • Best for sparse graphs

  • Memory Efficient

  • Checking if edge exists means traversing Linked List, time consuming