Data Structures

अब Quizwiz के साथ अपने होमवर्क और परीक्षाओं को एस करें!

auxiliary structure is used for a breadth-first traversal of a graph?

FIFO Queue

Quick Sort

If arrays evenly split O(N log N)... aren't split evenly it approaches O(n^2) it is inefficient if most of the data is already sorted. O(log N) to O(n) additional memory needed

A complete directed graph with N nodes has how many edges?

N*(N-1) edges

A complete undireceted graph with N nodes has how many edges

N*(N-1)/2

Adjacenct matrix: finding if two nodes are connected (time complexity)

O(1)

Merge Sort

O(N Log N) requires an additional O(n) memory

Heap Enqueue (time complexity)

O(log N)

Inserting in the heap (time complexity)

O(log N)

Binary Search

O(log N) requires an array-based list that is sorted

Linear Search

O(n), performs N/2 on average

Insertion Sort (time complexity)

O(n^2)

Selection Sort (time complexity)

O(n^2)

Bubble Sort (time complexity)

O(n^2)...best case: O(n)

Adjacency matrix: finding adjacent nodes (time complexity)

O(v)

auxiliary structure is used for a depth-first traversal of a graph

Stack

Downside of adjacency matrix for a graph

if the graph is sparse then it wastes a lot of memory O(v^2) v is the # of vertices

advantage of adjacency list over adjacency matrix

if the graph is sparse then the list doesn't waste any memory

How to search for a value in a heap

linear search of the array holding the heap

Dense graph

number of edges is close to the maximum

Sparse graph

number of edges is far from the maximum

Heap Sort

overall O(N log N) avoid if using for small arrays no additional memory is needed

Inserting in a heap (time complexity)

overall: O(log N)

Strongly connected graph

there exists a path from any vertex to any other vertex


संबंधित स्टडी सेट्स

Chapter 7: Social Class: The Structure of Inequality

View Set

COP3363 - Ch. 9, 10 and (section 5.11), 11, 13 Quizzes

View Set

Conversación Avanzada. Unidad: España.

View Set