Algorithms and data Strucuters

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

• Need balanced search tree so that insert and search operations have O(lgN) running time in the worst-case • 2-3 Search Tree - Is a tree that is either empty or - A 2-node, with one key (and associated value) and two links • a left link to a 2-3 search tree with smaller keys • a right link to a 2-3 search tree with larger keys - A 3-node, with two keys (and associated values) and three links • a left link to a 2-3 search tree with smaller keys • a middle link to a 2-3 search tree with keys between the node's keys • and a right link to a 2-3 search tree with larger keys • 2-3 Tree - A perfectly balanced 2-3 search tree, whose null links are all the same distance from the root - Height is between floor(log3N) and floor(log2N)

2-3 Search Tree

1. Let current node to be the search miss node and key to be the new key 2. If current node is a 2-node a) replace the node with a 3-node containing its original key and the new key, return 3. else (current node is a 3-node) a) replace the node with a temporary 4-node containing its original keys and the new key b) if it has parent a) split the temporary 4-node, let key to be the middle key and current node to be the parent, go to step 2 c) else a) split the temporary 4-node into three 2-nodes, increasing the height of the tree by 1, return

2-3 Tree Insertion Summary

• Does the 2-3 tree contains a key? • Algorithm 1. start with current node as root 2. if current node is null return false 3. else a) if the search key equals to any of the keys at the current node return true b) else if the search key is less than the smallest key at the current node, set current node to its left child, go to Step 2 c) else if search key is between the two keys at current node, set current node to its middle child, , go to Step 2 d) else (search key must be greater than the largest key at the current node), set current node to its right child, go to Step 2

2-3 Tree Search

False per definition of strongly connected.

A strongly connected digraph might not have directed cycles.

• a vertex-indexed array of lists of the vertices adjacent to each vertex • Each edge appears twice for undirected graph • Parallel edges and self-loops are allowed • Good for sparse graph

Adjacency Lists Representation

• VxV boolean array, 1 -> true, 0 -> false • a[v][w] is true means there is a edge between v and w • Does not support parallel edges • Not good for sparse graph

Adjacency Matrix Representation

• Depends on the shape of the BST , which in turn depends on the order in which keys are inserted • Search running time - Best case: O(1) - Average case: O(lgN) - Worst case: O(N) • Insertion running time - Best case: O(1) - Average case: O(lgN) - Worst case: O(N)

Analysis of BST Algorithms

- Abinarytree - Each node has a Comparable key (and an associated value) - The key in any node is larger than the keys in all nodes in that node's left sub-tree and smaller than the keys in all nodes in that node's right sub-tree • Used for symbol table implementation that does not allow duplicate keys

Binary Search Tree

Yes

Can any recursive method can be implemented iteratively?

Symbol Table Implementation Worst-Case Average-Case Search Insert Search Insert Unordered Linked List N N N /2 N Ordered Array lgN 2N lgN N Binary Search Tree N N 1.39lgN 1.39lgN Red-Black BST 2lgN 2lgN lgN lgN

Cost Summary for Symbol Table Implementations

• Solves single-source search problem • Algorithm - Set vertex to the starting point - Mark it as having been visited - Visit (recursively) all the vertices that are adjacent to it and that have not yet been marked

Depth-First Search (DFS)

The algorithm exists in many variants; Dijkstra's original variant found the shortest path between two nodes, but a more common variant fixes a single node as the "source" node and finds shortest paths from the source to all other nodes in the graph, producing a shortest path tree.

Dijkstra's Shortest Path Algorithm

• Input - A sequence of integer pairs - Pair p and q means "p is connected to q" - "is connected to" is an equivalence relation, which means that it is • Reflexive : p is connected to p. • Symmetric : If p is connected to q, then q is connected to p. • Transitive : If p is connected to q and q is connected to r, then p is connected to r. • Example equivalence relation - Network connection between two sites, friendship between two people, etc. • Problem - For each pair of input integers • Find out if they are connected (Find) • If they are not connected, add connection between them (Union) • Example - For network sites from 0 to 9, which of the following direct connections between sites are not needed? - 4 3; 3 8; 6 5; 9 4; 2 1; 8 9; 5 0; 7 2; 6 1; 1 0; 6 7

Dynamic Connectivity

It will get full and go into infinite loop.

Explain why resizing is a must for hashing with linear probing.

1. Visit the root. 2. Traverse the left subtree, i.e., call Preorder(left-subtree) 3. Traverse the right subtree, i.e., call Preorder(right-subtree)

Give a Preorder Traversal of a BST

1. Traverse the left subtree, i.e., call Inorder(left-subtree) 2. Visit the root. 3. Traverse the right subtree, i.e., call Inorder(right-subtree)

Give a inorder Traversal of a BST

application vertex edge map place road web page link circuit device wire social network person friendship

Graph Applications

• For an array that can hold M key-value pairs, we need a hash function that can transform any given key into an integer in the range [0, M - 1] • Requirements - Efficient to compute - Uniformly distributes the keys • Each key has the same probability to be mapped to any integer between 0 and M-1 • One way to ensure uniformity is to make sure that all the bits of the key play an equal role in computing every hash value • Depends on the key type - e.g. int, String, Point2D, ...

Hash Function

• An application needs to process a few hundreds SSN • SSN: xxx-yy-zzzz - xxx defines geographical area - yy-zzzz identifies an individual • Allocate an array that can hold 1000 key value pairs, provide a hash function that maps any SSN to an array index 1. Using f(xxx-yy-zzzz) = xxx, not uniformly distributed 2. Using f(xxx-yy-zzzz) = zzz is better 3. Using a function that consider all 9 digits is even better

Hash Function Examples

• Keys are positive integers - key % M - M is prime • Keys are Strings - (s[0]*31(n-1) + s[1]*31(n-2) + ... + s[n-1]) - s[i] is the ith character of the string, n is the length of the string - Hash value of the empty string is zero - This is JDK String.hashcode() implementation, can cause integer overflow • "polygenelubricants".hashcode() is -231

Hash Function Examples

• Three primary requirements in implementing a good hash function for a given Java class - It should be consistent, equal keys must produce the same hash value - It should be efficient to compute - It should uniformly distribute the keys

Hash Function Summary

• Search algorithms that use hashing consist of two parts - compute a hash function, which maps a key into an array index - collision-resolution process, which handles the situation when different keys are mapped to the same array index • separate chaining • linear probing

Hashing

• For each of the M array indices, build a linked list of the key-value pairs whose keys hash to that index • Search for a key - Hash to find the list that could contain the key - Sequentially search that list for the key • Choose M to be sufficiently large so that the lists are sufficiently short to enable efficient search

Hashing with Separate Chaining

• Open-addressing hashing - Store N key-value pairs in a hash table of size M > N - Use empty table entries to help with collision resolution • Linear probing - Two arrays of size M • private Key[] keys; // the keys • private Value[] vals; // the values - index = hash(key) • (key.hashCode() & 0x7fffffff) % M - while (keys[index]!=null) • Keys[index].equals(search key): search hit, do something, return • !Keys[index].equals(search key): index = (index + 1)%M - search miss, do something, return

Hashing with linear Probing

Stack<String> stack1 = new Stack<String>(); stack1.push("Test"); String next = stack1.pop();

How do you create a stack?

https://www.youtube.com/watch?v=IzHdFo9Hm6E

How do you do Rotation on a Red Black Tree?

We say that two vertices v and w are strongly connected if they are mutually reachable: there is a directed path from v to w and a directed path from w to v.

In a digraph how are two vertexes strongly connected?

Dijkstra's Shortest Path Algorithm

Indexed Priority Queue

No

Is a 2-3 search tree balanced?

Before inserting new key and value pair, check if the table is half full. If so, resize the table and then do the insertion. Resizing inserts all existing key value pairs from the old table to the new table via put(...) method.

LinearProbingHashST

• Running time depends on cluster length - Cluster : Contiguous groups of occupied table entries • Load factor - α = N/M <1 • Assuming hash function distributes keys uniformly - Average # probes for search hit is ~ 1 1 + 1 • about 1.5 when α = 1/2 - Average # probes for search miss is ~ 1 (1 + 1 ) 2 1−α 2 • about 2.5 when α = 1/2

LinearProbingST Analysis

Stable? Yes Time Complexity: Best-Case O(NlgN) Worst-Case O(NlgN) Average-Case O(NlgN) Space Complexity Best-Case O(N) Worst-Case O(N) Average-Case O(N)

Merge Sort

Worst-Case Average-Case Memory Search Insert Search Insert Symbol Table N N N/2 N 48N Ordered Array lgN 2N lgN N 16N BST N N 1.39lgN 1.39lgN 64N Red-Boack BST 2lgN 2lgN lgN LgN 64N Sep Chaining <lgN <lbN N/(2M) N/M 48N + 64M Linear Probing ClgN ClgN <1.5 <1.5 32N~128N Linear probing assume N/M<1/2

Performance Comparison

Heap

Priority Queue

Applications - Items need to be processed in order, but not necessarily in full sorted order, such as • Events shall be processed in chronological order • Job with the highest priority shall be processed first Two types - MinPQ • insert, size, isEmpty, delMin, min - MaxPQ • insert, size, isEmpty, delMax, max

Priority Queues

FIFO Multitasking operating system Print server Breadth-First Search

Queue

Stable? No Time Complexity: Best-Case O(NlgN) Worst-Case O(N^2) Average-Case O(NlgN) Space Complexity Best-Case O(lgN) Worst-Case O(N) Average-Case O(lgN)

Quick Sort

• BST having red and black links - Redlink • binds together two 2-nodes to represent a 3-node • leans left, one of the 2-nodes is the left child of the other - Black link • binds 2-3 tree - No node has two red links connected to it - Has perfect black balance : every path from the root to a null link has the same number of black links. • There is 1-1 mapping between a red-black tree and a 2-3 tree

Red-Black BST

• The height of a red-black BST with N nodes is no more than 2 lg N. • The average length of a path from the root to a node in a red-black • BST with N nodes is ~1.00 lg N. • O(log N) time in the worst case - search,insertion - findingtheminimum/maximum - floor, ceiling, rank, select - deletetheminimum/maximum,delete - rangecount • JDK TreeMap - A Red-Black BST based implementation

Red-Black BST Analysis

• New node is always inserted with red link • Insert into a 2-node - rotate left if the new node is inserted as a right child • Insert into a 3-node - split the node by doing necessary left rotation, right rotation, or color flipping - pass the red link and the middle key up to its parent - continue the same process until reaches a 2-node or the root

Red-Black BST Insertion Summary

False, never has O(N) search time.

Search and insertion to a 2-3 tree with N nodes have the worst-case O(N) running time.

• N keys, M buckets (lists) - Average length of the lists is N / M - choose M to be sufficiently small that we do not waste memory with empty chains but sufficiently large that we do not waste time searching through long chains • If the hash function is uniform and independent - Constant time search and insertion • If the hash function is not uniform and independent - Search and insertion time could be linear • Probably the fastest and most widely used symbol- table implementation for applications where key order is not important

Separate Chaining Analysis

• A collection that contains no duplicate elements - Unordered & ordered • Turn any symbol-table implementation into a Set by ignoring values • Example usage - Remove duplicates, White Filter, Black Filter

Set

Dictionary client - Phone book - Dictionary - Account information - Compilers • Using symbols to represent variables, functions, etc. - File system • file name (key), file location (value) - Internet DNS (Domain Name System) • URL (Key), IP address (Value) • Indexing - Use key to find associated values, e.g. use movie name to find all the performers - Use value to find associated keys (Inverted index), e.g. use performer name to find all the movies he/she played in - Can use a Collection (e.g. Queue, List, etc.) object to represent value

Set Applications

The ability of a sorting algorithm to preserve the relative order of equal keys

Stability

Can be used to support phonebook operations efficiently

Symbol Table

Worst-Case Average-Case Search Insert Search Insert U/O Linked List N N N/2 N Ordered Array lgn 2N lgn N Binary Search Tree N N 1.39lgN 1.39lgN

Symbol Table Implementation Performance Comparison

• A graph — A set of vertices - A set of edges that each connect a pair of vertices • A self-loop is an edge that connects a vertex to itself • Two edges that connect the same pair of vertices are parallel • Conventions - V: number of vertices - E: number of edges - Use 0 through V-1 for the vertices - Use v-w to refer to an edge that connects v and w

Undirected Graph

...

What is P, what is NP, what NP-complete?

A graph is connected when there is a path between every pair of vertices. In a connected graph, there are no unreachable vertices. A graph that is not connected is disconnected. A graph with just one vertex is connected.

What is a connected graph?

A cycle is a path (with at least one edge) whose first and last vertices are the same. A simple cycle is a cycle with no repeated edges or vertices (except the requisite repetition of the first and last vertices).

What is a cycle in a path?

A directed acyclic graph (or DAG) is a digraph with no directed cycles.

What is a directed acyclic graph?

A directed cycle is a directed path (with at least one edge) whose first and last vertices are the same. A simple cycle is a cycle with no repeated edges or vertices (except the requisite repetition of the first and last vertices).

What is a directed cycle?

A forest is a disjoint set of trees.

What is a forest?

A bipartite graph is a graph whose vertices we can divide into two sets such that all edges connect a vertex in one set with a vertex in the other set

bipartite graph

A dense graph has relatively few of the possible edges missing

dense graph

A sparse graph has relatively few of the possible edges present

sparse graph

8 Bytes

What is the space requirement for an double in Java?

4 Bytes

What is the space requirement for an float in Java?

4 Bytes

What is the space requirement for an int in Java?

Selection and Insertion

Which sort algorithms has (have) the average-case running time as O(N2)?

Selection and Insertion

Which sort algorithms has (have) the average-case running time as O(N^2)?

Merge and Quick

Which sort algorithms has (have) the average-case running time as O(NlogN)?

LIFO Expression evaluation "Undo" in editors Function call implementation Depth-First Search(DFS)

Stack

Adjacency list

Which one supports parallel edges?

Divide-and-Conquer algorithm - Top-Down • Breaks big problem into smaller problems - Bottom-UP • Builds small solutions into larger ones • Uses less space Time Complexity - Best-case, worst-case, average-case: O(NlgN) • Space Complexity - O(N)auxiliary • Stable • Can be adapted to sort data too big to fit in the memory

Merge Sort Analysis

Merge and Insertion

Which ones are stable sorting algorithms?

Merge Sort

Which sort algorithm uses the most auxiliary space in average-case?

• A complete binary tree that is max heap-ordered , key in each node is larger than or equal to the keys in that node's two children (if any).

Binary Max Heap

Each node can have at most two children

Binary Tree

An ordered collection, allow getting, adding, or removing element at

List

Data Structure Worst-Case insert Worst-Case delMax unordered array 1 N ordered array N 1 heap log log N Impossible 1 1

Priority Queues

- A collections of nodes - Each node has at most two children - Each node has one parent, except root, which does not have parent

Binary Tree

— A collection of nodes - Each node has at most two children, which are referred to as the left child and the right child - Each node has one parent, except root, which does not have parent - Nodes with no children are leaves - Nodes with the same parent are siblings - The depth of a node is the length of path from root to the node - The height of a binary tree is length of the longest path from root to a leaf • One node tree has height 0

Binary Tree

- Every level, except the last, is completely filled, and all nodes in the last level are as far left as possible - The height of a complete binary tree of size N is floor(lg N)

Complete binary tree

When an edge connects two vertices, we say that the vertices are adjacent to one another and that the edge is incident on both vertices.

Define Adjacent:

Two edges are parallel if they connect the same pair of vertices.

Define Parallel:

self-loop is an edge that connects a vertex to itself.

Define self-loop:

False

For edge-weighted digraph, adding a constant to every edge weight does not change the solution to the single-source shortest-paths problem.

Can be used to model social network

Graph

- Heap construction • Reorganize the original array into a max-oriented heap • Option 1 - add key one by one to the heap by swim(...) • Option 2 - from key at index n/2 to 1, use sink(...) to put sub-heap in order - Sort • repeat until heap has only one element - remove the maximum from the heap - put it after the end of the heap

Heap Sort

Stable? No Time Complexity: Best-Case O(NlgN) Worst-Case O(NlgN) Average-Case O(NlgN) Space Complexity Best-Case 1 Worst-Case 1 Average-Case 1

Heap Sort

• Timecomplexity - Heap construction uses fewer than 2N compares and fewer than N exchanges to construct a heap from N items - Heap sort uses fewer than 2N lg N + 2N compares and half that many exchanges to sort N items - O(N lg N) • SpaceComplexity - O(1) • It is rarely used in typical applications because it has poor cache performance

Heap Sort Analysis

One way to find the degree is to count the number of edges which has that vertx as an endpoint.

How do you determine the degree of a vertex?

...

How do you do insertion on a Red Black Tree?

Depth-first search finds some path from a source vertex s to a target vertex v. We are often interested in finding the shortest such path (one with a minimal number of edges). Breadth-first search is a classic method based on this goal. To find a shortest path from s to v, we start at s and check for v among all the vertices that we can reach by following one edge, then we check for v among all the vertices that we can reach from s by following two edges, and so forth. To implement this strategy, we maintain a queue of all vertices that have been marked but whose adjacency lists have not been checked. We put the source vertex on the queue, then perform the following steps until the queue is empty: Remove the next vertex v from the queue. Put onto the queue all unmarked vertices that are adjacent to v and mark them.

How do you do the algorithm for Breadth first search? Include code.

Depth-first search is a classic recursive method for systematically examining each of the vertices and edges in a graph. To visit a vertex. Mark it as having been visited. Visit (recursively) all the vertices that are adjacent to it and that have not yet been marked.

How do you do the algorithm for depth first Search? Include code.

In topological sorting, we use a temporary stack. We don't print the vertex immediately, we first recursively call topological sorting for all its adjacent vertices, then push it to a stack. Finally, print contents of stack. Note that a vertex is pushed to stack only when all of its adjacent vertices (and their adjacent vertices and so on) are already in stack. Topological Sorting for a graph is not possible if the graph is not a Directed Acyclic Graph. // A recursive function used by topologicalSort void Graph::topologicalSortUtil(int v, bool visited[], stack<int> &Stack) { // Mark the current node as visited. visited[v] = true; // Recur for all the vertices adjacent to this vertex list<int>::iterator i; for (i = adj[v].begin(); i != adj[v].end(); ++i) if (!visited[*i]) topologicalSortUtil(*i, visited, Stack); // Push current vertex to stack which stores result Stack.push(v); } // The function to do Topological Sort. It uses recursive // topologicalSortUtil() void Graph::topologicalSort() { stack<int> Stack; // Mark all the vertices as not visited bool *visited = new bool[V]; for (int i = 0; i < V; i++) visited[i] = false; // Call the recursive helper function to store Topological // Sort starting from all vertices one by one for (int i = 0; i < V; i++) if (visited[i] == false) topologicalSortUtil(i, visited, Stack); // Print contents of stack while (Stack.empty() == false) { cout << Stack.top() << " "; Stack.pop(); } }

How do you find the topological order of a graph?

A digraph is strongly connected if there is a directed path from every vertex to every other vertex.

How is a digraph strongly connected?

fill in

Insert 76, 93, 40, 47, 10, 55 into an empty hash table with M = 7 1. using linear chaining. 2. linear probing

Stable? yes Time Complexity: Best-Case O(N) Worst-Case O(N^2) Average-Case O(N^2) Space Complexity Best-Case 1 Worst-Case 1 Average-Case 1

Insertion Sort

Insert a new key • add the new key at the end of the array • increment the size of the heap • swim the key up through the heap to restore the heap condition Delete the max key • take the max key off the top • put the item from the end of the heap at the top • decrement the size of the heap • sink the key down through the heap to restore the heap condition

MaxPQ Array Implementation

Time complexity - Best-case • Each partitioning stage divides the array in half, T(N) = 2* T(N/2) + CN • O(N*logN) - Average-case • Partition falls in the middle on average • O(N*logN) - Worst-case • Each partition divides the array into an sub-array with 0 elements and a sub-array with n-1 elements • O(N2) • Space complexity - Best-case: O(logN) auxiliary - Average-case: O(logN) auxiliary - Worst-case: O(N) auxiliary

Quick Sort Analysis

Stable? no Time Complexity: Best-Case O(N^2) Worst-Case O(N^2) Average-Case O(N^2) Space Complexity Best-Case 1 Worst-Case 1 Average-Case 1

Selection Sort

A collection without duplicate values

Set

Stable? no Time Complexity: Best-Case O(nlog^2n) Worst-Case O(N^2) Average-Case N/A Space Complexity Best-Case 1 Worst-Case 1 Average-Case 1

Shell Sort

• A symbol table is a data structure for key-value pairs that supports two operations - insert (put) a new pair into the table - search for (get) the value associated with a given key • A.K.A. - Associative Array, Dictionary, Map • Applications examples - Dictionary: find definition of a word - Web search: find a list of web pages from a keyword search - Compiler: find type and value of a variable • Assumptions - Keys must not be null - Values must not be null - No duplicate keys allowed • When a client puts a key-value pair into a table already containing that key, the new value replaces the old one

Symbol Table

False

The worst-case running time for binary search is O(N), given an array with N elements.

matrix and adjacency list

What are the two graph representations?

We say that one vertex is connected to another if there exists a path that contains both of them.

What does connected mean in reference to a vertex?

We say that a vertex w is reachable from a vertex v if there exists a directed path from v to w.

What does reachable mean?

Kruskal's algorithm processes the edges in order of their weight values (smallest to largest), taking for the MST each edge that does not form a cycle with edges previously added, stopping after adding V-1 edges. To implement Kruskal's algorithm, we use a priority queue to consider the edges in order by weight, a union-find data structure to identify those that cause cycles, and a queue to collect the MST edges.

What is Kruskal's algorithm, is it used to find the minimum spanning tree?

Prim's algorithm works by attaching a new edge to a single growing tree at each step: Start with any vertex as a single-vertex tree; then add V-1 edges to it, always taking next the minimum-weight edge that connects a vertex on the tree to a vertex not yet on the tree (a crossing edge for the cut defined by tree vertices).

What is Prim's algorithm, is it used to find the minimum spanning tree?

A directed graph is graph that are connected together, where all the edges are directed from one vertex to another. A directed graph is sometimes called a digraph or a directed network.

What is a Directed graph?

A bipartite graph is a graph whose vertices we can divide into two sets such that all edges connect a vertex in one set with a vertex in the other set.

What is a bipartite graph?

A bipartite graph, also called a bigraph, is a set of graph vertices decomposed into two disjoint sets such that no two graph vertices within the same set are adjacent.

What is a bipartite graph?

A graph is connected if there is a path from every vertex to every other vertex.

What is a connect graph?

Matrix

Which one is good for dense graph?

Matrix

Which one is quicker in answering "is w adjacent to v"?

A directed path in a digraph is a sequence of vertices in which there is a (directed) edge pointing from each vertex in the sequence to its successor in the sequence. A simple path is one with no repeated vertices.

What is a directed path?

A path in a graph is a sequence of vertices connected by edges. A simple path is one with no repeated vertices.

What is a path in a Graph?

A spanning tree of a connected graph is a subgraph that contains all of that graph's vertices and is a single tree. A spanning forest of a graph is the union of the spanning trees of its connected components.

What is a spanning tree?

A subgraph is a subset of a graph's edges (and associated vertices) that constitutes a graph.

What is a sub-graph?

A tree is an acyclic connected graph.

What is a tree?

An undirected graph is graph that are connected together, where all the edges are bidirectional. An undirected graph is sometimes called an undirected network. In contrast, a graph where the edges point in a direction is called a directed graph.

What is an Undirected graph?

An acyclic graph is a graph with no cycles.

What is an acyclic graph?

- A finite, deterministic, and effective problem-solving method suitable for implementation as a computer program [1] - A effective way to solve a set of common problems • Sorting, searching, shortest path

What is the Definition of Algorithm?

- A way to store and organize data in order to facilitate access and modifications [2] - Data structures exist as the byproducts or end products of algorithms[1] - Lists, stacks, queues, trees, sets, graphs, etc.

What is the Definition of Data Structure?

...

What is the algorithm for a 2-3 search tree?

...

What is the algorithm for a 2-3 tree?

The degree of a graph vertex of a graph is the number of graph edges which touch

What is the degree of a vertex?

The indegree of a vertex is the number of edges pointing to it.

What is the indegree of a vertex?

The length of a path or a cycle is its number of edges.

What is the length of a path cycle?

The outdegree of a vertex is the number of edges pointing from it.

What is the outdegree of a vertex?

Go left sub-tree and print, right sub-tree and print, then root and print.

What is the post-order traversal sequence?

2 Bytes

What is the space requirement for an char in Java?

An edge-weighted graph is a graph where we associate weights or costs with each edge.

Whats an edge weighted graphs?

Breadth first search.

Which algorithm can be used to find the shortest path between two vertices in an undirected graph? Write the algorithm in Java, and provide the algorithm analysis for worst-case running time and extra space usage. The input to your algorithm is a Graph object and source vertex.

Hashing with linear probing, Red Black BTS

Which data structure(s) can have constant running time for search and insertion in average-case?

Red-Black Tree, Ordered Array and Binary Search Tree.

Which data structure(s) can support order symbol table efficiently?

Ordered Array, BST and Orderd linked list.

Which data structure(s) has (have) O(N) running time for insertion in worst-case?

BST and unordered linked list.

Which data structure(s) has (have) O(N) running time for search in worst-case?

Binary Search Tree and Red-Black BST

Which data structure(s) has (have) O(logN) running time for insertion in average-case?


Set pelajaran terkait

Module 13 - Artificial Intelligence and Automation

View Set

Combustion and Corrosion Reactions

View Set

Forensics- Chapter 6: Fingerprints

View Set

2.07: Alegbra Complex Numbers and 3.02: Work with Polynomials & 3.04 , 4.04

View Set

Marketing an Introduction - Chapter 9, mkt 327 for exam 3 quiz 13, 14, 15, 16, Marketing Chp. 15, 16, 21, Marketing Ch 9 10 12, MKTG 3433 Exam 2 UARK, MGMT 3433 UARK Exam 2, Marketing 3433 Lezon Test 2, MKTG 3433 UARK Test 2, MKTG 3433 Chapters 9,10,...

View Set

Chapters 8 and 9 Mastering Biology

View Set

Cisco Project/Based Learning/ Access WAN Chapter 19,20,21

View Set