Podcast
Questions and Answers
Remember that this final will be fully comprehensive of the entire course. Fill it out and familiarize yourself with all ______.
Remember that this final will be fully comprehensive of the entire course. Fill it out and familiarize yourself with all ______.
concepts
Fill in the table with the worst case and best case (if any) Big O time complexities for each ______.
Fill in the table with the worst case and best case (if any) Big O time complexities for each ______.
algorithm
O(h) is actually O(logn)
O(h) is actually O(logn)
True
Which of these algorithms utilize the divide and conquer paradigm? (Select all that apply)
Which of these algorithms utilize the divide and conquer paradigm? (Select all that apply)
Signup and view all the answers
What is in-place sorting? Provide an example of a sorting algorithm that utilizes in-place sorting.
What is in-place sorting? Provide an example of a sorting algorithm that utilizes in-place sorting.
Signup and view all the answers
What is not in-place sorting? Provide an example of a sorting algorithm that utilizes not in-place sorting.
What is not in-place sorting? Provide an example of a sorting algorithm that utilizes not in-place sorting.
Signup and view all the answers
Explain the difference between stable and unstable sorting, provide examples for both based on what we have learned.
Explain the difference between stable and unstable sorting, provide examples for both based on what we have learned.
Signup and view all the answers
What property does a max-heap have to satisfy?
What property does a max-heap have to satisfy?
Signup and view all the answers
Explain how we can achieve the best case time complexity for Quicksort.
Explain how we can achieve the best case time complexity for Quicksort.
Signup and view all the answers
What are the three arrays we use for Counting-Sort, what do they do? (Select all that apply)
What are the three arrays we use for Counting-Sort, what do they do? (Select all that apply)
Signup and view all the answers
What policy does a Stack use, and why?
What policy does a Stack use, and why?
Signup and view all the answers
What policy does a Queue use, and why?
What policy does a Queue use, and why?
Signup and view all the answers
Here is an input sequence 123+45**+ use a stack to compute the sum, show all steps.
Here is an input sequence 123+45**+ use a stack to compute the sum, show all steps.
Signup and view all the answers
What are the two functions that add and remove from a Stack? (Select all that apply)
What are the two functions that add and remove from a Stack? (Select all that apply)
Signup and view all the answers
What attribute of a stack keeps track of the most recent element pushed into the stack?
What attribute of a stack keeps track of the most recent element pushed into the stack?
Signup and view all the answers
What two functions add and remove from a Queue? (Select all that apply)
What two functions add and remove from a Queue? (Select all that apply)
Signup and view all the answers
What are the two attributes that keep track of the index of the first element, and the index of the next location a new element can be inserted? (Select all that apply)
What are the two attributes that keep track of the index of the first element, and the index of the next location a new element can be inserted? (Select all that apply)
Signup and view all the answers
Define all the attributes that make up a tree structure.
Define all the attributes that make up a tree structure.
Signup and view all the answers
What is the binary search tree property?
What is the binary search tree property?
Signup and view all the answers
Given this Binary Search Tree, please list the order of the nodes following Inorder traversal, preorder traversal, and post order traversal. (Select all that apply)
Given this Binary Search Tree, please list the order of the nodes following Inorder traversal, preorder traversal, and post order traversal. (Select all that apply)
Signup and view all the answers
What is the max height and depth of the tree in question 22? (Select all that apply)
What is the max height and depth of the tree in question 22? (Select all that apply)
Signup and view all the answers
What are the 5 properties that satisfy a red black tree? (Select all that apply)
What are the 5 properties that satisfy a red black tree? (Select all that apply)
Signup and view all the answers
What is a sentinel for merge sort and red black tree?
What is a sentinel for merge sort and red black tree?
Signup and view all the answers
What is chaining in hash tables?
What is chaining in hash tables?
Signup and view all the answers
Why do we use dynamic programming? (Select all that apply)
Why do we use dynamic programming? (Select all that apply)
Signup and view all the answers
What type of trade off does dynamic programming incur?
What type of trade off does dynamic programming incur?
Signup and view all the answers
What algorithm do we use to calculate the minimum number of scalar products?
What algorithm do we use to calculate the minimum number of scalar products?
Signup and view all the answers
What are the two methods in finding the longest common subsequence?
What are the two methods in finding the longest common subsequence?
Signup and view all the answers
What is the output we want from the LCS algorithm?
What is the output we want from the LCS algorithm?
Signup and view all the answers
What is stored in the C and B table?
What is stored in the C and B table?
Signup and view all the answers
What does each arrow mean? Left, right, diagonal?
What does each arrow mean? Left, right, diagonal?
Signup and view all the answers
What are B-Trees?
What are B-Trees?
Signup and view all the answers
B-Trees copy pages from where? What does it then do?
B-Trees copy pages from where? What does it then do?
Signup and view all the answers
Every node other than the root must have how many keys?
Every node other than the root must have how many keys?
Signup and view all the answers
Every node may contain at most how many keys?
Every node may contain at most how many keys?
Signup and view all the answers
What are disjoint sets? What does Make-Set(x) do?
What are disjoint sets? What does Make-Set(x) do?
Signup and view all the answers
What are the two types of graphs? (Select all that apply)
What are the two types of graphs? (Select all that apply)
Signup and view all the answers
How can we calculate the maximum number of edges that can connect a set of nodes (vertices)?
How can we calculate the maximum number of edges that can connect a set of nodes (vertices)?
Signup and view all the answers
What are two standard ways to represent graph G=(V,E)? (Select all that apply)
What are two standard ways to represent graph G=(V,E)? (Select all that apply)
Signup and view all the answers
How do we traverse a graph using depth first search?
How do we traverse a graph using depth first search?
Signup and view all the answers
What makes a strongly connected component of a graph?
What makes a strongly connected component of a graph?
Signup and view all the answers
When we transpose a graph, what does that do?
When we transpose a graph, what does that do?
Signup and view all the answers
What is the goal of a minimum spanning tree?
What is the goal of a minimum spanning tree?
Signup and view all the answers
What 3 algorithms are considered greedy algorithms? (Select all that apply)
What 3 algorithms are considered greedy algorithms? (Select all that apply)
Signup and view all the answers
How does MST-Kruskals work? What about MST-Prims?
How does MST-Kruskals work? What about MST-Prims?
Signup and view all the answers
Know how to read and implement the Kruskals algorithm
Know how to read and implement the Kruskals algorithm
Signup and view all the answers
Know how to read and implement MST-Prims
Know how to read and implement MST-Prims
Signup and view all the answers
What solutions do we have to traverse every node in a graph, please list them all? (Select all that apply)
What solutions do we have to traverse every node in a graph, please list them all? (Select all that apply)
Signup and view all the answers
What solutions do we have to traverse every node in a graph, and find the shortest path (lowest cost) to connect all nodes together? Please list them all? (Select all that apply)
What solutions do we have to traverse every node in a graph, and find the shortest path (lowest cost) to connect all nodes together? Please list them all? (Select all that apply)
Signup and view all the answers
Please know how to read and implement, initialize single source, relax, and Bellman-ford algorithm
Please know how to read and implement, initialize single source, relax, and Bellman-ford algorithm
Signup and view all the answers
What do we want to avoid in the bellman-ford algorithm?
What do we want to avoid in the bellman-ford algorithm?
Signup and view all the answers
Does dijkstras algorithm allow you to have negative edge weight?
Does dijkstras algorithm allow you to have negative edge weight?
Signup and view all the answers
What is our goal with dijstraks algorithm? How does it work?
What is our goal with dijstraks algorithm? How does it work?
Signup and view all the answers
Study Notes
Algorithm Time Complexities
- Insertion Sort: Worst case time complexity is O(n²).
- Merge Sort: Worst case time complexity is O(n log n).
- Heap Sort: Worst case time complexity is O(n log n).
- Quick Sort: Worst case time complexity is O(n²).
- Counting Sort: Worst case time complexity is O(k + n).
- Searching Hash Table: Worst case time complexity is O(n).
- Balanced Binary Search Tree: Worst case time complexity is O(log n) or O(h).
- Unbalanced Binary Search Tree: Worst case time complexity is O(n).
- Inorder, Postorder, Preorder search: Worst case time complexity is O(n).
- Cut-Rod: Worst case time complexity is O(2ⁿ).
- Longest Common Subsequence: Worst case time complexity is O(m + n).
- Breadth-first search: Worst case time complexity is O(|V| + |E|).
- Depth-first search: Worst case time complexity is O(|V| + |E|).
- Dijkstra's algorithm: Worst case time complexity is O(V log V + E).
Data Structures
-
Linear:
- Array
- Stack
- Queue
- Linked List
-
Non-linear:
- Tree
- Graph
- Hash Table
Divide and Conquer Algorithms
- Quicksort
- Merge Sort
- Binary Search
In-place Sorting
- Insertion Sort
- Characteristics: Does not require additional space (memory) for processing data, and does not rely on extra data structures.
Not In-place Sorting
- Merge Sort
- Characteristics: Requires additional space, usually equal to or greater than the original input data size, to manipulate the data during sorting. Also, more computationally efficient than in-place sorting in some cases.
Stable vs. Unstable Sorting
-
Stable Sorting: Retains the original order of elements with equal values when sorting.
- Example: Merge Sort
-
Unstable Sorting: Does not maintain the original order of equal elements.
- Example: Quicksort
Max-Heap Property
- A[Parent(i)] ≥ A[i]
Best Case Time Complexity of Quicksort
- Occurs when the pivot divides the array nearly in half during partitioning.
Counting Sort Arrays
- Input Array (A): The array containing the elements to be sorted.
- Output Array (B): The array where the sorted elements will be stored.
- Auxiliary Array (C): An extra array used to store the counts of each element in the input array.
Stack
- Policy: Last-In-First-Out (LIFO)
Queue
- Policy: First-In-First-Out (FIFO)
Sorting Algorithm Comparison
Binary Search Tree Property
- If y is a left subtree node of x, then y.key ≤ x.key.
- If y is a right subtree node of x, then y.key ≥ x.key.
Binary Search Tree Traversal Orders
- Inorder: 25, 30, 35, 40, 45, 50, 60
- Postorder: 25, 35, 30, 45, 60, 50, 40
- Preorder: 40, 30, 25, 35, 50, 45, 60
Red-Black Tree Properties
- Every node is either red or black.
- The root is black.
- Every leaf (NIL) is black.
- If a node is red, then both its children are black.
- All paths from a given node to the descendant leaves contain the same number of black nodes.
Sentinel
- A sentinel is a special value or element used in a data structure as a boundary marker.
Chaining in Hash Tables
- When multiple keys hash to the same index, these entries are linked together in a chain/linked list.
Dynamic Programming
- Breaks down a problem into smaller overlapping subproblems and saves the solutions.
- Avoids redundant calculations.
- Used for optimization problems.
Time-Memory Trade-Off
- Dynamic programming's use of extra memory can speed up calculations for optimization problems.
Matrix Chain Multiplication
- An algorithm for calculating the minimum number of scalar products for multiplying matrices.
Length of Longest Common Subsequence Algorithm Implementation
- The problem involves finding the length of a longest common subsequence using algorithms that solve sub-problems and store their results, and then combine them to solve more complex problems. Tables are used to store the results of sub-problems, and the values are retrieved as needed.
B-Trees
- Balanced search trees optimized for disk access.
Graph Traversal
- Depth-First Search (DFS): Explore as deeply as possible along a branch before backtracking.
- Breadth-First Search (BFS): Explore all vertices at a given distance from the source before moving to the next level.
Strongly Connected Components
- In a directed graph, a strongly connected component (SCC) is a maximal set of vertices where each vertex in the set is reachable from every other vertex.
Transposing a Graph
- Swapping the direction of all edges in a directed graph results in a new graph. This change in direction of edges is a common step in some graph algorithms to analyze specific properties.
Disjoint Sets
- A data structure for managing a collection of disjoint sets (collections of elements that are not in any other sets).
Studying That Suits You
Use AI to generate personalized quizzes and flashcards to suit your learning preferences.
Related Documents
Description
Test your knowledge of algorithm time complexities, including sorting and search algorithms. This quiz covers various data structures and their associated performance metrics. Challenge yourself to understand the worst-case scenarios for each algorithm discussed.