COP3530 Final Exam Study Guide

Lakukan tugas rumah & ujian kamu dengan baik sekarang menggunakan Quizwiz!

Hash Table Worst Search

O(n)

Level Order Tree Traversal complexity

O(n)

Postorder traversal time complexity

O(n)

inorder traversal time complexity

O(n)

preorder traversal complexity

O(n)

Bubble Sort Worst Case

O(n^2)

Insertion Sort Worst Case

O(n^2)

Quick Sort Worst Case

O(n^2)

Selection Sort Worst Case

O(n^2)

Merge Sort Worst Case

O(nlogn)

Quick sort avg case

O(nlogn)

Heap

Ordered Binary Tree

level order traversal

Process all nodes of a tree by depth: first the root, then the children of the root, etc.

Set = red black tree

Same structure as red black tree

Binary Search Tree: search, insert, delete

Search: O(h) / balanced, O(lg n) Insert: O(h) / balanced, O(lg n) Delete: O(h) / balanced, O(lg n)

B-tree

Binary Tree- Structure for storing database indexes, each node in the tree contains a stored list of key values and links that correspond to ranges of key values between the listed values. The point is to allow SQL to make a yes/no decision for each phase of search

Divide and Conquer

Binary search, Quick Sort, Merge Sort

Hash table property

Each key = unique hash, unique keys, hash = key

Knapsack Problem

Given a set of items, each with a weight and a value, determine the number of each item to include in a collection so that the total weight is <= a given limit and the total value is as large as possible -using dynamic programming - Ford Fulkerson Alg.

Map avg time complexity

O log(n)

Hash Table Average Search

O(1)

AVL Tree - Insert

O(log n)

Binary Search Worst Case

O(log n)

Greedy Algorithim examples

The greedy algorithm for the fractional knapsack problem takes a fractional amount of at most one item. Huffman Coding trees Dijikstra's shortest path traveling salesman problem

Separate Chaining

Uses a linked list to handle collisions at a specific point.

Load Factor

in a hash table, the fraction of the table's capacity that is filled.

Postorder Traversal

left subtree, right subtree, root

inorder traversal

left subtree, root, right subtree

Edge List for weighted graph

list of pairs, neighbor name and weight

B+ Tree

1) Maintain a copy of all keys in the leaves of the tree. 2) Create a linked-list out of the leaf nodes of the tree.

AVL Tree

a self-balancing sorted binary tree, in which the heights of subtrees differ by at most 1.

Heap Sort

Non-stable, in place sort which has an order of growth of O(NlogN). Requires only one spot of extra space. Works like an improved version of selection sort. It divides its input into a sorted and unsorted region, and iteratively shrinks the unsorted region by extracting the smallest element and moving it into the sorted region. It will make use of a heap structure instead of a linear time search to find the minimum.

Prim's Algorithm

(Minimum Spanning Trees, O(m + nlogn), where m is number of edges and n is the number of vertices) Starting from a vertex, grow the rest of the tree one edge at a time until all vertices are included. Greedily select the best local option from all available choices without regard to the global structure.

Kruskal's Algorithm

(Minimum Spanning Trees, O(mlogm) with a union find, which is fast for sparse graphs) Builds up connected components of vertices, repeatedly considering the lightest remaining edge and tests whether its two endpoints lie within the same connected component. If not, insert the edge and merge the two components into one.

preorder traversal

root, left subtree, right subtree

Binary Search Tree

A binary tree with the property that for all parent nodes, the left subtree contains only values less than the parent, and the right subtree contains only values greater than the parent.

maxheap

A binary tree with two added properties: It is a complete tree and for each node, the node is greater than or equal to both the left child and the right child.

minheap

A binary tree with two added properties: It is a complete tree, and for each node, the node is less than or equal to both the left child and the right child.

Binary Tree

A data structure that consists of nodes, with one root node at the base of the tree, and two nodes (left child and right child) extending from the root, and from each child node.

Hash Table

A data structure where the calculated value is used to mark the position in the table where the data item should be stored, enabling it to be accessed directly, rather than forcing a sequential search.

adjacency list

A linked list that identifies all the vertices to which a particular vertex is connected; each vertex has its own adjacency list.

Merge Sort

A list is split into individual lists, these are then combined (2 lists at a time).

Brute Force

A method for determining a solution to a problem by sequentially testing all possible solutions.

Collision Resolution Techniques

A method for handling collisions in a hash table, e.g. open addressing with linear probing, open addressing with double hashing, chaining, and buckets.

Selection Sort

A sort algorithm that repeatedly scans for the smallest item in the list and swaps it with the element at the current index. The index is then incremented, and the process repeats until the last two elements are sorted.

Huffman tree

A tree having the nodes representing symbols as the leaves, with more frequent symbols having nodes progressively closer to the root. The most frequent symbols are the closest to the root node. Note that internal nodes cannot represent symbols. The edges connecting children to parents are either 0 or 1. Convention must be established (e.g., left children have 0s, right children have 1s). The code for a symbol is built from 0s and 1s along the path from the root down to the desired symbol. Codes must be prefix free. abc:7 / \ ab:3 c:4 / \ a:1 b:2

Priority Queue: advantage, disadvantage

Advantage: cheap way to sort priorities, sometimes you want to do things first Disadvantage: worse at inserting and searching than BST

Binary Search

An ordered list is divided in 2 with each comparison.

Open Addressing

Any collision resolution scheme that places all the data in the hash table rather than relying on some way of storing some of the data outside the table.

Coin Change Problem

Dynamic Programming Problem, hint: a coin can either be used or not used to make the sum. Consider the scenarios for using it and not using it solution[i][j] = 0 if i=0 = 1 if j=0 = solution[i — 1][j] + solution[i][j — v[i — 1]] if(coin[i]<=j) = solution[i — 1][j]; if(coin[i]>j)

Insertion Sort

Each items is take in turn, compare to the items in a sorted list and placed in the correct position.

Depth First Search

Explore newest unexplored vertices first. Placed discovered vertices in a stack (or used recursion). Partitions edges into two classes: tree edges and back edges. Tree edges discover new vertices; back edges are ancestors.

unordered map

Implemented using hash table, avg cost O(1)

Complete Binary Tree

In a complete binary tree every level, except possibly the last, is completely filled, and all nodes in the last level are as far left as possible.

Perfect Binary Tree

It is both full and complete. 2k - 1 nodes where k is the height

Quick Sort Pivot

Place at end, compare larger element than pivot on left half with smaller than pivot on right half, then swap, if left half < right half, swap with pivot

Suppose A is an array containing numbers in increasing order but some numbers occur more than once. When using binary search for the value, what happens

Sometimes it finds first, sometimes last value

Shell Sort

Starts by sorting pairs of elements far apart from each other, then progressively reducing the gap between elements to be compared. Starting with far apart elements can move some out-of-place elements into position faster than a simple nearest neighbor exchange.

Huffman Codes

Used for text compression, or any compression where the input data frequencies are imbalanced, e.g. in english the vowels, r,s, and t are much more common than q and z.

Map tree similarity

Uses bst tree structure

Breadth First Search

Visits the neighbor vertices before visiting the child vertices Often used to find the shortest path from one vertex to another. A queue is usually implemented

Collision Resolution

Ways of handling hashing collisions

Red-Black Tree cases

Worst case height of 2log(n+1). The nodes are either red or black. The root is black. If a node is red, its children MUST BE BLACK. Every path from a node to a leaf must contain the same number of black nodes. New insertions will always be red and always left leaning. Insertions must satisfy the conditions that red nodes have black children and that they have the same number of black nodes in all paths. Time complexity on its operations are O(logN).

Full Binary Tree

a binary tree in which all of the leaves are on the same level and every nonleaf node has two children

Linear Search

a method for finding a target value within a list. It sequentially checks each element of the list for the target value until a match is found or until all the elements have been searched.

Priority Queue

a queue in which the highest-priority elements are removed first; within a priority value, the earliest arrival is removed first.

Adjacency Matrix

a representation of a graph in which a boolean matrix contains a 1 at position (i,j) iff there is an arc from node i to node j.

Red-Black Tree

a self-balancing binary tree in which nodes are "colored" red or black. The longest path from the root to a leaf is no more than twice the length of the shortest path.

Dynamic Programming

an algorithmic paradigm that finds the solution to an optimization problem by recursively breaking down the problem into overlapping subproblems and combining their solutions with the help of a recurrence relation

Iterator

an object containing data and methods to iterate through a collection of data, allowing processing of one data item at a time.

Heapify

assumes part of array is already sorted, similar to create max heap

Create max heap

parent > child, root is largest element in tree, creates max heap in unsorted array, O(n)

disjoint sets

sets that do not have any elements in common


Set pelajaran terkait

Anatomy and Physiology Chapter 9: Joints

View Set

Life Insurance Ownership and Beneficiary Designations

View Set

NUR 370 Exam 2 Review (The Point)

View Set

US Government (2020) unit 1 workbooks

View Set

CFA Level 3 - Institutional Investors (thank you mtbrennan7)

View Set

Ch. 19: Comparative Advantage and the Gains from International Trade DSM

View Set

METEO 122 Final Exam Concept Questions

View Set