Dataset Viewer
Auto-converted to Parquet Duplicate
instruction
stringlengths
38
903
input
stringlengths
0
433
output
stringlengths
556
14.3k
prompt
stringlengths
357
1.1k
⌀
Create Manim code to visualize the Binary Search algorithm. The visualization should clearly show the process of dividing the search interval in half and finding the target element.
An array represented by [1, 3, 5, 7, 9, 11, 13, 15, 17, 19]. Visualize the Binary Search process starting with the array and targeting the element 11.
```python from manim import * class BinarySearch(Scene): def construct(self): self.camera.background_color = WHITE title = Text('Binary Search Algorithm', font_size=36).set_color(BLACK).to_edge(UP) self.play(Write(title)) self.wait(2) # Display the array array = [1,...
null
Create Manim code to visualize the Quick Search algorithm. The visualization should clearly show the process of dividing the search interval in half and finding the target element.
An array represented by [1, 3, 5, 7, 9, 11, 13, 15, 17, 19]. Visualize the Quick Search process starting with the array and targeting the element 11.
```python from manim import * class QuickSearch(Scene): def construct(self): self.camera.background_color = WHITE title = Text('Quick Search Algorithm', font_size=36).set_color(BLACK).to_edge(UP) self.play(Write(title)) self.wait(2) # Display the array array = [1, 3...
null
Create Manim code to visualize the Depth-First Search (DFS) algorithm. The visualization should clearly show the process of exploring as far as possible along each branch before backtracking.
A graph represented by vertices: ['A', 'B', 'C', 'D', 'E'] and edges: [('A', 'B'), ('A', 'C'), ('B', 'D'), ('C', 'E')]. Visualize the DFS process starting from vertex 'A'.
```python from manim import * class DFS(Scene): def construct(self): self.camera.background_color = WHITE title = Text('Depth-First Search Algorithm', font_size=36).set_color(BLACK).to_edge(UP) self.play(Write(title)) self.wait(2) # Display graph (example graph used) ...
null
Create Manim code to visualize the Bubble Sort algorithm. The visualization should clearly show the process of comparing adjacent elements and swapping them if they are in the wrong order.
An array represented by [64, 34, 25, 12, 22, 11, 90]. Visualize the Bubble Sort process starting with the array.
```python from manim import * class BubbleSort(Scene): def construct(self): self.camera.background_color = WHITE title = Text('Bubble Sort Algorithm', font_size=36).set_color(BLACK).to_edge(UP) self.play(Write(title)) self.wait(2) # Display array array = [64, 34, 25...
null
Create Manim code to visualize the Selection Sort algorithm. The visualization should clearly show the process of finding the minimum element and swapping it with the first unsorted element.
An array represented by [29, 10, 14, 37, 14]. Visualize the Selection Sort process starting with the array.
```python from manim import * class SelectionSort(Scene): def construct(self): self.camera.background_color = WHITE title = Text('Selection Sort Algorithm', font_size=36).set_color(BLACK).to_edge(UP) self.play(Write(title)) self.wait(2) # Display array array = [29, ...
null
Create Manim code to visualize the Quick Sort algorithm. The visualization should clearly show the selection of the pivot, partitioning of the array, and the recursive sorting process.
An array represented by [3, 6, 8, 10, 1, 2, 1]. Visualize the Quick Sort process starting with the array.
```python from manim import * class QuickSort(Scene): def construct(self): self.camera.background_color = WHITE title = Text('Quick Sort Algorithm', font_size=36).set_color(BLACK).to_edge(UP) self.play(Write(title)) self.wait(2) # Display the array array = [3, 6, 8,...
null
Create Manim code to visualize the Heap Sort algorithm. The visualization should clearly show the process of building a max-heap, extracting the maximum element, and heapifying the array.
An array represented by [4, 10, 3, 5, 1]. Visualize the Heap Sort process starting with the array.
```python from manim import * class HeapSort(Scene): def construct(self): self.camera.background_color = WHITE title = Text('Heap Sort Algorithm', font_size=36).set_color(BLACK).to_edge(UP) self.play(Write(title)) self.wait(2) # Display the array array = [4, 10, 3, ...
null
Create Manim code to visualize Prim's Algorithm. The visualization should clearly show the selection of the starting vertex, adding the minimum weight edge, and the iterative process.
A graph represented by vertices ['A', 'B', 'C', 'D', 'E'] and edges {('A', 'B'): 1, ('B', 'C'): 2, ('B', 'E'): 6, ('C', 'D'): 1, ('C', 'E'): 7, ('D', 'E'): 3}. Visualize Prim's Algorithm process starting from vertex 'A'.
```python from manim import * class PrimAlgorithm(Scene): def construct(self): self.camera.background_color = WHITE title = Text('Prim's Algorithm', font_size=36).set_color(BLACK).to_edge(UP) self.play(Write(title)) self.wait(2) # Display the initial graph vertices ...
null
Create Manim code to visualize Kruskal's Algorithm. The visualization should clearly show the sorting of edges, selection of edges to avoid cycles, and the formation of the minimum spanning tree.
A graph represented by vertices ['A', 'B', 'C', 'D', 'E'] and edges [('A', 'B', 1), ('A', 'C', 4), ('B', 'C', 2), ('B', 'D', 5), ('C', 'D', 1), ('D', 'E', 3)]. Visualize Kruskal's Algorithm process starting from the sorted edges.
```python from manim import * class KruskalAlgorithm(Scene): def construct(self): self.camera.background_color = WHITE title = Text('Kruskal's Algorithm', font_size=36).set_color(BLACK).to_edge(UP) self.play(Write(title)) self.wait(2) # Display the initial graph ver...
null
Create Manim code to visualize Dijkstra's Algorithm. The visualization should clearly show the selection of the starting vertex, the updating of distances, and the formation of the shortest paths tree.
A graph represented by vertices ['A', 'B', 'C', 'D', 'E'] and edges {('A', 'B'): 1, ('A', 'C'): 4, ('B', 'C'): 2, ('B', 'D'): 5, ('C', 'D'): 1, ('D', 'E'): 3}. Visualize Dijkstra's Algorithm process starting from vertex 'A'.
```python from manim import * class DijkstraAlgorithm(Scene): def construct(self): self.camera.background_color = WHITE title = Text('Dijkstra's Algorithm', font_size=36).set_color(BLACK).to edge(UP) self.play(Write(title)) self.wait(2) # Display the initial graph v...
null
Create Manim code to visualize the QuickSort algorithm sorting an array. The animation should demonstrate the partitioning step, pivot selection, and recursive sorting of subarrays.
An array of integers: [5, 2, 8, 3, 1]. Visualize the steps of QuickSort with the last element as the pivot.
```python from manim import * class QuickSortAnimation(Scene): def construct(self): # Step 1: Title title = Text("QuickSort Animation", font_size=36) self.play(Write(title)) self.play(title.animate.to_edge(UP)) # Step 2: Initialize array arr = [5, 2, 8, 3, 1] ...
Below is an instruction that describes a task. Write a response that appropriately completes the request. ### Instruction: Create Manim code to visualize the QuickSort algorithm sorting an array. The animation should demonstrate the partitioning step, pivot selection, and recursive sorting of subarrays. ### Input: An...
Create Manim code to visualize the binary search algorithm on a sorted array. The animation should demonstrate the steps of dividing the search range, calculating the midpoint, and narrowing down to the target value.
A sorted array: [2, 5, 8, 12, 16, 23, 38, 45]. Visualize the steps of binary search to find the target value 16.
```python from manim import * class BinarySearchAnimation(Scene): def construct(self): # Step 1: Title title = Text("Binary Search Animation", font_size=36) self.play(Write(title)) self.play(title.animate.to_edge(UP)) # Step 2: Initialize array and target arr = [2, ...
Below is an instruction that describes a task. Write a response that appropriately completes the request. ### Instruction: Create Manim code to visualize the binary search algorithm on a sorted array. The animation should demonstrate the steps of dividing the search range, calculating the midpoint, and narrowing down ...
Create Manim code to visualize Prim's algorithm constructing a minimum spanning tree (MST) in a weighted graph. The animation should demonstrate node selection, edge weight comparisons, and incremental MST growth.
A weighted graph with nodes: {'A': [0, 2, 0], 'B': [-2, 0, 0], 'C': [2, 0, 0], 'D': [-3, -2, 0], 'E': [-1, -2, 0], 'F': [1, -2, 0]} and edges: [('A', 'B', 4), ('A', 'C', 3), ('B', 'D', 2), ('B', 'E', 5), ('C', 'F', 1), ('E', 'F', 6)]. Visualize Prim's algorithm starting from node 'A'.
```python from manim import * import heapq class PrimsAlgorithmVisualization(Scene): def construct(self): # Step 1: Define graph structure nodes = { 'A': np.array([0, 2, 0]), 'B': np.array([-2, 0, 0]), 'C': np.array([2, 0, 0]), 'D': np.array([-3, -2, ...
Below is an instruction that describes a task. Write a response that appropriately completes the request. ### Instruction: Create Manim code to visualize Prim's algorithm constructing a minimum spanning tree (MST) in a weighted graph. The animation should demonstrate node selection, edge weight comparisons, and increm...
Create Manim code to visualize the Fibonacci sequence calculation using dynamic programming. The animation should demonstrate the iterative computation of Fibonacci numbers, highlighting the addition of previous results to compute the next value.
Calculate Fibonacci(5) iteratively. Visualize the computation of each Fibonacci number and highlight the addition of previous results.
```python from manim import * class FibonacciAnimation(Scene): def construct(self): # Step 1: Title title = Text("Fibonacci Sequence (n = 5)", font_size=36) self.play(Write(title)) self.play(title.animate.to_edge(UP)) # Step 2: Initial setup n = 5 fib_values...
Below is an instruction that describes a task. Write a response that appropriately completes the request. ### Instruction: Create Manim code to visualize the Fibonacci sequence calculation using dynamic programming. The animation should demonstrate the iterative computation of Fibonacci numbers, highlighting the addit...
Create Manim code to visualize the greedy algorithm solving the activity selection problem. The animation should demonstrate sorting activities by end time, selecting non-overlapping activities, and highlighting the greedy choice property.
Activities with start/end times: [(1, 4), (3, 5), (0, 6), (5, 7), (8, 9), (5, 9)]. Visualize the greedy selection of maximum non-overlapping activities.
```python from manim import * class ActivitySelectionAnimation(Scene): def construct(self): # Step 1: Title title = Text("Activity Selection (Greedy)", font_size=36) self.play(Write(title)) self.play(title.animate.to_edge(UP)) # Step 2: Input activities activities =...
Below is an instruction that describes a task. Write a response that appropriately completes the request. ### Instruction: Create Manim code to visualize the greedy algorithm solving the activity selection problem. The animation should demonstrate sorting activities by end time, selecting non-overlapping activities, a...
Create Manim code to visualize a queue implemented using two stacks. The animation should demonstrate enqueue/dequeue operations and the transfer of elements between stacks while maintaining FIFO order.
Demonstrate enqueuing elements [1, 2, 3] followed by two dequeues.
```python from manim import * class QueueWithTwoStacks(Scene): def construct(self): # Step 1: Initialize stacks as VGroups enq_stack = VGroup() deq_stack = VGroup() # Step 2: Position stacks horizontally enq_stack.shift(LEFT * 3) deq_stack.shift(RIGHT * 3) ...
Below is an instruction that describes a task. Write a response that appropriately completes the request. ### Instruction: Create Manim code to visualize a queue implemented using two stacks. The animation should demonstrate enqueue/dequeue operations and the transfer of elements between stacks while maintaining FIFO ...
Create Manim code to visualize the Merge Sort algorithm. The animation should demonstrate the divide-and-conquer process: splitting arrays into halves, recursive sorting, and merging sorted subarrays with element comparisons.
An array of integers: [8, 3, 5, 1, 4, 7, 2, 6]. Visualize the full Merge Sort process including splitting and merging phases.
```python from manim import * class MergeSortAnimation(Scene): def construct(self): # Step 1: Title title = Text("Merge Sort", font_size=36) self.play(Write(title)) self.play(title.animate.to_edge(UP)) # Step 2: Initial array arr = [8, 3, 5, 1, 4, 7, 2, 6] a...
Below is an instruction that describes a task. Write a response that appropriately completes the request. ### Instruction: Create Manim code to visualize the Merge Sort algorithm. The animation should demonstrate the divide-and-conquer process: splitting arrays into halves, recursive sorting, and merging sorted subarr...
Create Manim code to visualize the backtracking algorithm solving the n-queens problem. The animation should demonstrate queen placement, conflict detection, and backtracking steps for a 6x6 chessboard.
Solve the 6-queens problem. Visualize the backtracking process with conflict highlighting and state-space exploration.
```python from manim import * import numpy as np class NQueensBacktracking(Scene): def construct(self): # Step 1: Title title = Text("N-Queens (n=6)", font_size=36) self.play(Write(title)) self.wait(1) self.play(title.animate.to_edge(UP)) # Step 2: Initializ...
Below is an instruction that describes a task. Write a response that appropriately completes the request. ### Instruction: Create Manim code to visualize the backtracking algorithm solving the n-queens problem. The animation should demonstrate queen placement, conflict detection, and backtracking steps for a 6x6 chess...
Create Manim code to visualize the growth rates of common Big O complexities (O(1), O(n), O(n²), O(log n)). The animation should compare their behavior as input size increases using graphical plots and real-world algorithmic examples.
Plot time complexity curves for O(1), O(n), O(n²), and O(log n) over an input range of n = 1 to 10.
```python from manim import * import numpy as np class BigOComplexityAnimation(Scene): def construct(self): # Step 1: Title title = Text("Big O Complexity Growth Rates", font_size=36) self.play(Write(title)) self.play(title.animate.to_edge(UP)) # Step 2: Axes setup ...
Below is an instruction that describes a task. Write a response that appropriately completes the request. ### Instruction: Create Manim code to visualize the growth rates of common Big O complexities (O(1), O(n), O(n²), O(log n)). The animation should compare their behavior as input size increases using graphical plot...
Create Manim code to compare recursive and iterative implementations of factorial calculation. The animation should visualize the call stack for recursion, variable updates for iteration, and highlight space complexity differences.
Calculate factorial(5) using recursion and iteration. Visualize the call stack growth vs. constant memory usage.
```python from manim import * class FactorialComparisonAnimation(Scene): def construct(self): # Step 1: Title title = Text("Factorial: Recursive vs Iterative (n=5)", font_size=36) self.play(Write(title)) self.play(title.animate.to_edge(UP)) # Step 2: Labels for sections ...
Below is an instruction that describes a task. Write a response that appropriately completes the request. ### Instruction: Create Manim code to compare recursive and iterative implementations of factorial calculation. The animation should visualize the call stack for recursion, variable updates for iteration, and high...
Create a graph showing the time complexity of various algorithms.
from manim import * class TimeComplexityPlot(Scene): def construct(self): axes = Axes(x_range=[0, 10], y_range=[0, 100], axis_config={"color": BLUE}) axes_labels = VGroup(Text("n", font_size=24).next_to(axes.x_axis, DOWN), Text("Time Complexity", font_size=24).next_to(axes.y_axis, LEFT)) f1 = axes.plot(lamb...
null
Create a visual representation of MergeSort.
array = [6, 3, 8, 5, 2, 7, 4, 1]
from manim import * import numpy as np class MergeSortVisualization(Scene): def construct(self): array = [6, 3, 8, 5, 2, 7, 4, 1] elements = self.create_array_visual(array) self.play(FadeIn(elements)) self.wait(1) self.merge_sort(array, elements, 0, len(array) - 1) self.wait(2) def create_arra...
null
Create a visual representation of QuickSort.
array = [6, 3, 8, 5, 2, 7, 4, 1]
from manim import * import numpy as np class QuickSortVisualization(Scene): def construct(self): array = [6, 3, 8, 5, 2, 7, 4, 1] elements = self.create_array_visual(array) self.play(FadeIn(elements)) self.wait(1) self.quick_sort(array, elements, 0, len(array) - 1) self.highlight_subarray(eleme...
null
Create a visual representation of Dynamic Programming.
weights = [2, 3, 4, 5], values = [3, 4, 5, 6], capacity = 5
from manim import * import numpy as np class KnapsackDPVisualization(Scene): def construct(self): weights = [2, 3, 4, 5] values = [3, 4, 5, 6] capacity = 5 n = len(weights) table = self.create_table(n, capacity) self.play(FadeIn(table)) self.wait(1) self.knapsack_dp(weights, values, cap...
null
Create a visual representation of Greedy Algorithm.
start_times = [1, 3, 0, 5, 8, 5], finish_times = [2, 4, 6, 7, 9, 9]
from manim import * import numpy as np class ActivitySelectionGreedyVisualization(Scene): def construct(self): start_times = [1, 3, 0, 5, 8, 5] finish_times = [2, 4, 6, 7, 9, 9] n = len(start_times) activities = self.create_activities(start_times, finish_times) self.play(FadeIn(activities)) sel...
null
Create a visual representation of BFS.
nodes = {'A': np.array([0, 2, 0]), 'B': np.array([-2, 0, 0]), 'C': np.array([2, 0, 0]), 'D': np.array([-3, -2, 0]), 'E': np.array([-1, -2, 0]), 'F': np.array([1, -2, 0]), edges = [('A', 'B'), ('A', 'C'), ('B', 'D'), ('B', 'E'), ('C', 'F'), ('E', 'F')]
```python from manim import * import numpy as np class BFSVisualization(Scene): def construct(self): # Step 1: Define graph nodes and edges nodes = { 'A': np.array([0, 2, 0]), 'B': np.array([-2, 0, 0]), 'C': np.array([2, 0, 0]), 'D': np.array([-3, -2,...
null
Create a visual representation of DFS.
nodes = {'A': np.array([0, 2, 0]), 'B': np.array([-2, 0, 0]), 'C': np.array([2, 0, 0]), 'D': np.array([-3, -2, 0]), 'E': np.array([-1, -2, 0]), 'F': np.array([1, -2, 0]), edges = [('A', 'B'), ('A', 'C'), ('B', 'D'), ('B', 'E'), ('C', 'F'), ('E', 'F')
from manim import * import numpy as np class DFSVisualization(Scene): def construct(self): nodes = {'A': np.array([0, 2, 0]), 'B': np.array([-2, 0, 0]), 'C': np.array([2, 0, 0]), 'D': np.array([-3, -2, 0]), 'E': np.array([-1, -2, 0]), 'F': np.array([1, -2, 0])} edges = [('A', 'B'), ('A', 'C'), ('B', 'D'), ('B'...
null
Create a visual representation of Dijkstra.
'A': np.array([0, 2, 0]), 'B': np.array([-2, 0, 0]), 'C': np.array([2, 0, 0]), 'D': np.array([-3, -2, 0]), 'E': np.array([-1, -2, 0]), 'F': np.array([1, -2, 0]), edges = [('A', 'B'), ('A', 'C'), ('B', 'D'), ('B', 'E'), ('C', 'F'), ('E', 'F')
from manim import * import numpy as np import heapq class DijkstraVisualization(Scene): def construct(self): nodes = {'A': np.array([0, 2, 0]), 'B': np.array([-2, 0, 0]), 'C': np.array([2, 0, 0]), 'D': np.array([-3, -2, 0]), 'E': np.array([-1, -2, 0]), 'F': np.array([1, -2, 0])} edges = [('A', 'B', 4), ('A', '...
null
Create a visual representation of MST.
'A': np.array([0, 2, 0]), 'B': np.array([-2, 0, 0]), 'C': np.array([2, 0, 0]), 'D': np.array([-3, -2, 0]), 'E': np.array([-1, -2, 0]), 'F': np.array([1, -2, 0]), edges = [('A', 'B'), ('A', 'C'), ('B', 'D'), ('B', 'E'), ('C', 'F'), ('E', 'F')
from manim import * import numpy as np import heapq class MSTVisualization(Scene): def construct(self): nodes = {'A': np.array([0, 2, 0]), 'B': np.array([-2, 0, 0]), 'C': np.array([2, 0, 0]), 'D': np.array([-3, -2, 0]), 'E': np.array([-1, -2, 0]), 'F': np.array([1, -2, 0])} edges = [('A', 'B', 4), ('A', 'C', 2...
null
Create a visual representation of differences between P & NP problems.
p_problem = [1, 3, 2, 5, 4], np_problem = [(0, 1), (1, 2), (2, 3), (3, 4), (4, 0)]
from manim import * import numpy as np class PvsNPVisualization(Scene): def construct(self): p_problem = [1, 3, 2, 5, 4] np_problem = [(0, 1), (1, 2), (2, 3), (3, 4), (4, 0)] p_elements = self.create_array_visual(p_problem, label="P Problem (QuickSort)") self.play(FadeIn(p_elements)) self.wait(1) ...
null
Create Manim code to visualize the Fibonacci Sequence. The visualization should clearly show the first 10 terms of the Fibonacci sequence and their generation process.
Generate the Fibonacci sequence and visualize the first 10 terms: [0, 1, 1, 2, 3, 5, 8, 13, 21, 34]. Display each term as a node and visualize the process of generating the sequence.
```python from manim import * import numpy as np class FibonacciVisualization(Scene): def construct(self): fibonacci_numbers = [0, 1] for i in range(2, 10): fibonacci_numbers.append(fibonacci_numbers[-1] + fibonacci_numbers[-2]) fib_texts = [Text(str(num)).scale(0.6).shift(RIGH...
null
Create Manim code to visualize the Depth-First Search (DFS) algorithm for traversing a graph. The visualization should clearly show the DFS traversal process and highlight the visited nodes.
A graph represented by nodes: {'A': [0, 2, 0], 'B': [-2, 0, 0], 'C': [2, 0, 0], 'D': [-3, -2, 0], 'E': [-1, -2, 0], 'F': [1, -2, 0]} and edges: [('A', 'B'), ('A', 'C'), ('B', 'D'), ('B', 'E'), ('C', 'F'), ('E', 'F')]. Visualize DFS starting from node 'A' and traverse through the graph.
```python from manim import * import numpy as np class DFSVisualization(Scene): def construct(self): nodes = {'A': np.array([0, 2, 0]), 'B': np.array([-2, 0, 0]), 'C': np.array([2, 0, 0]), 'D': np.array([-3, -2, 0]), 'E': np.array([-1, -2, 0]), 'F': np.array([1, -2, 0])} edges = [('A', 'B'), ('A', ...
null
Create Manim code to visualize Dijkstra’s algorithm for finding the shortest path in a graph. The visualization should clearly show the Dijkstra traversal process and highlight the shortest path.
A graph represented by nodes: {'A': [0, 2, 0], 'B': [-2, 0, 0], 'C': [2, 0, 0], 'D': [-3, -2, 0], 'E': [-1, -2, 0], 'F': [1, -2, 0]} and edges: [('A', 'B', 4), ('A', 'C', 2), ('B', 'D', 5), ('B', 'E', 10), ('C', 'F', 3), ('E', 'F', 7)]. Visualize Dijkstra’s algorithm starting from node 'A' and find the shortest path to...
```python from manim import * import numpy as np class DijkstraVisualization(Scene): def construct(self): nodes = {'A': np.array([0, 2, 0]), 'B': np.array([-2, 0, 0]), 'C': np.array([2, 0, 0]), 'D': np.array([-3, -2, 0]), 'E': np.array([-1, -2, 0]), 'F': np.array([1, -2, 0])} edges = [('A', 'B', 4)...
null
Create Manim code to visualize the Merge Sort algorithm. The visualization should clearly show the process of splitting the list and then merging it back together in sorted order.
An unsorted list: [5, 2, 9, 1, 5, 6]. Visualize the process of Merge Sort, showing each split and merge step, and finally displaying the sorted list.
```python from manim import * import numpy as np class MergeSortVisualization(Scene): def construct(self): text = Text('Merge Sort Algorithm Visualization').scale(0.8) self.play(Write(text)) self.wait(2) elements = [5, 2, 9, 1, 5, 6] element_texts = [Text(str(i)).scale(0.6)...
null
Create Manim code to visualize the Bellman-Ford algorithm for finding the shortest paths from a single source in a graph. The visualization should clearly show how the distances are updated and highlight the shortest path.
A graph represented by nodes: {'A': [0, 2, 0], 'B': [-2, 0, 0], 'C': [2, 0, 0], 'D': [-3, -2, 0], 'E': [-1, -2, 0], 'F': [1, -2, 0]} and edges: [('A', 'B', -4), ('A', 'C', 2), ('B', 'D', 3), ('B', 'E', 1), ('C', 'F', 5), ('E', 'F', 1)]. Visualize Bellman-Ford starting from node 'A' and find the shortest path to node 'F...
```python from manim import * import numpy as np class BellmanFordVisualization(Scene): def construct(self): nodes = {'A': np.array([0, 2, 0]), 'B': np.array([-2, 0, 0]), 'C': np.array([2, 0, 0]), 'D': np.array([-3, -2, 0]), 'E': np.array([-1, -2, 0]), 'F': np.array([1, -2, 0])} edges = [('A', 'B',...
null
Create Manim code to visualize Huffman Coding algorithm for constructing an optimal binary tree. The visualization should clearly show how the tree is built and highlight the final result.
A set of characters with their frequencies: {'A': 5, 'B': 7, 'C': 10, 'D': 15, 'E': 20, 'F': 45}. Visualize the process of constructing the Huffman tree for these characters.
```python from manim import * import numpy as np class HuffmanCodingVisualization(Scene): def construct(self): text = Text('Huffman Coding Tree Visualization').scale(0.8) self.play(Write(text)) self.wait(2) # Example Huffman Tree tree = TreeNode('Root', [TreeNode('A', []), ...
null
Create Manim code to visualize Prim’s algorithm for finding the minimum spanning tree. The visualization should clearly show the steps of adding edges to the tree and highlight the final result.
A graph represented by nodes: {'A': [0, 2, 0], 'B': [-2, 0, 0], 'C': [2, 0, 0], 'D': [-3, -2, 0], 'E': [-1, -2, 0], 'F': [1, -2, 0]} and edges: [('A', 'B', 2), ('A', 'C', 3), ('B', 'D', 4), ('C', 'E', 5), ('E', 'F', 6), ('F', 'D', 7)]. Visualize Prim’s algorithm starting from node 'A' and find the minimum spanning tree...
```python from manim import * import numpy as np class PrimVisualization(Scene): def construct(self): text = Text('Prim’s Algorithm Visualization').scale(0.8) self.play(Write(text)) self.wait(2) nodes = {'A': np.array([0, 2, 0]), 'B': np.array([-2, 0, 0]), 'C': np.array([2, 0, 0]),...
null
Create Manim code to visualize the Floyd-Warshall algorithm for finding the shortest paths between all pairs of vertices in a graph. The visualization should clearly show the process of updating distances and highlight the shortest paths.
A graph represented by nodes: {'A': [0, 2, 0], 'B': [-2, 0, 0], 'C': [2, 0, 0], 'D': [-3, -2, 0], 'E': [-1, -2, 0], 'F': [1, -2, 0]} and edges: [('A', 'B', 4), ('A', 'C', 2), ('B', 'D', 3), ('B', 'E', 10), ('C', 'F', 5), ('E', 'F', 1)]. Visualize Floyd-Warshall to compute the shortest paths between all pairs of nodes.
```python from manim import * import numpy as np class FloydWarshallVisualization(Scene): def construct(self): text = Text('Floyd-Warshall Algorithm Visualization').scale(0.8) self.play(Write(text)) self.wait(2) nodes = {'A': np.array([0, 2, 0]), 'B': np.array([-2, 0, 0]), 'C': np....
null
Create Manim code to visualize the A* algorithm for finding the shortest path in a graph. The visualization should clearly show the A* traversal process and highlight the shortest path.
A graph represented by nodes: {'A': [0, 2, 0], 'B': [-2, 0, 0], 'C': [2, 0, 0], 'D': [-3, -2, 0], 'E': [-1, -2, 0], 'F': [1, -2, 0]} and edges: [('A', 'B', 4), ('A', 'C', 2), ('B', 'D', 5), ('B', 'E', 1), ('C', 'F', 3), ('E', 'F', 7)]. Visualize A* algorithm starting from node 'A' and find the shortest path to node 'F'...
```python from manim import * import numpy as np class AStarVisualization(Scene): def construct(self): text = Text('A* Algorithm Visualization').scale(0.8) self.play(Write(text)) self.wait(2) nodes = {'A': np.array([0, 2, 0]), 'B': np.array([-2, 0, 0]), 'C': np.array([2, 0, 0]), 'D...
null
Create Manim code to visualize the Bubble Sort algorithm.
Array: [5, 1, 4, 2, 8]. Visualize Bubble Sort in ascending order using a bar chart.
```python from manim import * class BubbleSortVisualization(Scene): def construct(self): array = [5, 1, 4, 2, 8] # Example array bars = VGroup() # Group to hold the bar chart labels = VGroup() # Group to hold numbers below bars # 1. Create Initial Bar Chart for i, val in...
null
Create Manim code to visualize the Binary Search algorithm.
Sorted Array: [2, 5, 7, 8, 11, 12]. Target value: 11. Visualize Binary Search finding the target in the sorted array.
```python from manim import * class BinarySearchVisualization(Scene): def construct(self): sorted_array = [2, 5, 7, 8, 11, 12] target = 11 array_mobjects = VGroup() indices_mobjects = VGroup() # 1. Create Sorted Array Representation for i, val in enumerate(sorted_ar...
null
Create Manim code to visualize Kruskal's algorithm for Minimum Spanning Tree.
Weighted Graph: Nodes A, B, C, D, E and edges (A,B,4), (A,C,3), (B,C,2), (B,D,5), (C,E,6), (D,E,1). Visualize Kruskal's algorithm finding the MST.
```python from manim import * class KruskalsMSTVisualization(Scene): def construct(self): # 1. Define Graph (Nodes and Edges with Weights) nodes = ['A', 'B', 'C', 'D', 'E'] edges_weighted = [ ('A', 'B', 4), ('A', 'C', 3), ('B', 'C', 2), ('B', 'D', 5), ('C', 'E', 6), ...
null
Create Manim code to visualize Dijkstra's algorithm for shortest paths.
Weighted Graph and source node 'A': Nodes A, B, C, D, E and edges (A,B,4), (A,C,3), (B,C,2), (B,D,5), (C,E,6), (D,E,1). Visualize Dijkstra's algorithm finding shortest paths from 'A'.
```python from manim import * class DijkstrasVisualization(Scene): def construct(self): # 1. Define Graph (Nodes and Weighted Edges) - Same as Kruskal's example graph nodes = ['A', 'B', 'C', 'D', 'E'] edges_weighted = [ ('A', 'B', 4), ('A', 'C', 3), ('B', 'C', 2), ('...
null
Create Manim code to visualize Dynamic Programming (Memoization) for Fibonacci sequence.
Calculate the 5th Fibonacci number using dynamic programming (memoization) and visualize the process using a table.
```python from manim import * class FibonacciDPVisualization(Scene): def construct(self): n = 5 memo = {} # Memoization dictionary # 1. Create Memoization Table Visualization (Grid) table = VGroup(*[Square() for _ in range(n + 1)]) table.arrange(RIGHT) table_labels...
null
Create Manim code to visualize Backtracking algorithm for N-Queens problem.
Solve the 4-Queens problem using backtracking and visualize the placement attempts on a 4x4 chessboard.
```python from manim import * class NQueensVisualization(Scene): def construct(self): n = 4 # 4-Queens problem board_size = n queens_group = VGroup() # Group to hold queen icons queen_cols = [] # List to track column index for each queen # 1. Create Chessboard Grid ...
null
Create Manim code to visualize Breadth-First Search (BFS) algorithm for graph traversal.
Graph: Nodes A, B, C, D, E, F and edges [('A', 'B'), ('A', 'C'), ('B', 'D'), ('C', 'E'), ('D', 'F'), ('E', 'F')]. Visualize BFS traversal starting from node 'A'.
```python from manim import * class BFSVisualization(Scene): def construct(self): # 1. Define Graph (Nodes and Edges) - Undirected graph nodes = ['A', 'B', 'C', 'D', 'E', 'F'] edges = [('A', 'B'), ('A', 'C'), ('B', 'D'), ('C', 'E'), ('D', 'F'), ('E', 'F')] start_node_name = 'A' ...
null
Create Manim code to visualize Line Intersections (Brute Force).
Line Segments: [([-2, 0], [0, 2]), ([-1, 1], [1, -1]), ([1, 0], [3, 2]), ([2, 1], [4, -1])]. Visualize intersections of these line segments using a brute-force approach.
```python from manim import * class LineIntersectionsVisualization(Scene): def construct(self): # 1. Define Line Segments (Example) line_segments_coords = [ ([-2, 0], [0, 2]), # Segment 1 ([-1, 1], [1, -1]), # Segment 2 ([1, 0], [3, 2]), # Segment 3 ...
null
Create Manim code to visualize 2-Approximation Algorithm for Vertex Cover.
Graph: Nodes 1, 2, 3, 4, 5, 6 and edges [('1', '2'), ('1', '3'), ('2', '4'), ('3', '4'), ('3', '5'), ('4', '6'), ('5', '6')]. Visualize the 2-approximation algorithm finding a vertex cover.
```python from manim import * class VertexCoverApproximationVisualization(Scene): def construct(self): # 1. Define Graph (Nodes and Edges) nodes = ['1', '2', '3', '4', '5', '6'] # Node labels as strings edges = [('1', '2'), ('1', '3'), ('2', '4'), ('3', '4'), ('3', '5'), ('4', '6'), ('5', ...
null
Write a Python script using Manim to visualize the Bubble Sort algorithm.
[5, 2, 9, 1, 5, 6]
from manim import * import numpy as np class BubbleSortVisualization(Scene): def construct(self): numbers = [5, 2, 9, 1, 5, 6] positions = np.linspace(-3, 3, len(numbers)) array_objs = {i: Text(str(num)).scale(1.2).move_to([pos, 0, 0]) for i, (num, pos) in enumerate(zip(numbers, positions))...
null
Create Manim code to visualize the Fractional Knapsack problem using the greedy algorithm.
A knapsack problem where items are defined as (weight, value): [(10, 60), (20, 100), (30, 120)] and the knapsack has a maximum capacity of 50.
from manim import * class FractionalKnapsack(Scene): def construct(self): items = [(10, 60), (20, 100), (30, 120)] capacity = 50 items = sorted(items, key=lambda x: x[1] / x[0], reverse=True) item_texts = [] knapsack_weight = 0 total_value = 0 for i, (weig...
null
Write a Python script using Manim to visualize the N-Queens problem.
from manim import * class NQueensVisualization(Scene): def construct(self): N = 8 squares = [] board_size = 1 for i in range(N): for j in range(N): color = WHITE if (i + j) % 2 == 0 else DARK_GRAY square = Square(side_length=board_size).mo...
null
Create Manim code to visualize the Minimum Spanning Tree (MST) using Kruskal's algorithm. The visualization should clearly show the graph structure and highlight the edges that form the MST.
A weighted graph represented by nodes: {'A': [-3, 2, 0], 'B': [-1, 2, 0], 'C': [2, 2, 0], 'D': [-3, 0, 0], 'E': [-1, 0, 0], 'F': [2, 0, 0], 'G': [-3, -2, 0], 'H': [-1, -2, 0], 'I': [2, -2, 0]} and weighted edges: [('A', 'B', 4), ('A', 'D', 7), ('B', 'C', 8), ('B', 'E', 2), ('C', 'F', 6), ('D', 'E', 3), ('D', 'G', 6), (...
```python from manim import * import networkx as nx import numpy as np class MSTVisualization(Scene): def construct(self): # Define graph nodes and edges with weights nodes = { 'A': np.array([-3, 2, 0]), 'B': np.array([-1, 2, 0]), 'C': np.array([2, 2, 0]), 'D': np.array([-3,...
Below is an instruction that describes a task. Write a response that appropriately completes the request. ### Instruction: Create Manim code to visualize the Minimum Spanning Tree (MST) using Kruskal's algorithm. The visualization should clearly show the graph structure and highlight the edges that form the MST. ### ...
Write a Python script using Manim to visualize Dijkstra's Algorithm.
A directed graph with weighted edges: [(0, 1, 4), (0, 2, 1), (1, 3, 1), (2, 1, 2), (2, 3, 5), (3, 4, 3)]. The starting node is 0.
from manim import * import networkx as nx import numpy as np class DijkstraVisualization(Scene): def construct(self): # Graph definition edges = [(0, 1, 4), (0, 2, 1), (1, 3, 1), (2, 1, 2), (2, 3, 5), (3, 4, 3)] graph = nx.DiGraph() graph.add_weighted_edges_from(edges) posit...
null
Create a Manim visualization to illustrate the Convex Hull algorithm using the Graham scan method.
A set of randomly generated points in a 2D plane.
from manim import * import numpy as np def cross(o, a, b): return (a[0]-o[0])*(b[1]-o[1]) - (a[1]-o[1])*(b[0]-o[0]) def compute_convex_hull(points): points = sorted(points, key=lambda p: (p[0], p[1])) lower = [] for p in points: while len(lower) >= 2 and cross(lower[-2], lower[-1], p) <= 0: ...
null
Generate a Manim animation demonstrating the Vertex Cover Problem using a greedy algorithm.
A simple undirected graph with five vertices and six edges.
from manim import * import numpy as np class VertexCoverScene(Scene): def construct(self): nodes = { 'A': np.array([-3,2,0]), 'B': np.array([0,2,0]), 'C': np.array([3,2,0]), 'D': np.array([-3,-2,0]), 'E': np.array([3,-2,0]) } edges...
null
Write a Manim animation to visualize the Randomized QuickSort algorithm.
An unsorted list of numbers: [50, 20, 70, 10, 40, 80, 30, 60].
from manim import * import random import numpy as np class RandomizedQuickSortScene(Scene): def construct(self): array = [50, 20, 70, 10, 40, 80, 30, 60] n = len(array) title = Text('Randomized QuickSort', font_size=36).to_edge(UP) self.play(Write(title)) self.wait(1) ...
null
Write a Manim script to visualize the Euclidean Algorithm for computing the greatest common divisor (GCD).
Find the GCD of 1071 and 462 using the Euclidean Algorithm.
from manim import * class EuclideanAlgorithmScene(Scene): def construct(self): a = 1071 b = 462 title = Text('Euclidean Algorithm for GCD', font_size=36).to_edge(UP) self.play(Write(title)) self.wait(1) expr = MathTex(r'\gcd(1071,462)').next_to(title, DOWN) s...
null
Create a Manim animation explaining the P vs. NP problem.
Visualize the relationship between P and NP complexity classes.
from manim import * class PvsNPScene(Scene): def construct(self): title = Text('P vs. NP Problem', font_size=36).to_edge(UP) self.play(Write(title)) self.wait(1) circle_p = Circle(radius=2, color=BLUE).shift(LEFT*3) circle_np = Circle(radius=2.5, color=GREEN).shift(RIGHT*3) ...
null
Create Manim code to visualize the Insertion Sort algorithm. The visualization should clearly demonstrate how each element is iteratively inserted into its correct position in the array. Include the following features: 1) Display the array as a sequence of labeled boxes or bars, 2) Highlight the current element being i...
A array: [5, 2, 4, 6, 1, 3].
from manim import * class InsertionSort(Scene): def construct(self): title = Text("Insertion Sort Visualization", font_size=36).to_edge(UP) self.play(Write(title)) self.wait(1) # Initial array to be sorted arr = [5, 2, 4, 6, 1, 3] n = len(arr) # Create labe...
Below is an instruction that describes a task. Write a response that appropriately completes the request. ### Instruction: Create Manim code to visualize the Insertion Sort algorithm. The visualization should clearly demonstrate how each element is iteratively inserted into its correct position in the array. Include t...
Create Manim code to visualize Prim's Algorithm for finding Minimum Spanning Trees (MST). The visualization should clearly demonstrate the step-by-step process of the algorithm, including: 1) Representing the graph with nodes and weighted edges, 2) Highlighting the starting node and the growing MST, 3) Showing the sele...
A graph with nodes: {'A': [-2, 1, 0], 'B': [0, 2, 0], 'C': [2, 1, 0], 'D': [0, 0, 0], 'E': [-2, -1, 0], 'F': [2, -1, 0]} and edges: [('A', 'B', 3), ('A', 'D', 1), ('B', 'C', 5), ('B', 'D', 4), ('C', 'D', 2), ('C', 'F', 1), ('D', 'E', 7), ('D', 'F', 8), ('E', 'F', 6)].
from manim import * # Define the graph nodes = { 'A': np.array([-2, 1, 0]), 'B': np.array([0, 2, 0]), 'C': np.array([2, 1, 0]), 'D': np.array([0, 0, 0]), 'E': np.array([-2, -1, 0]), 'F': np.array([2, -1, 0]) } edges = [ ('A', 'B', 3), ('A', 'D', 1), ('B', 'C', 5), ('B', 'D', 4), ('C', 'D', 2), ('C', '...
Below is an instruction that describes a task. Write a response that appropriately completes the request. ### Create Manim code to visualize Prim's Algorithm for finding Minimum Spanning Trees (MST). The visualization should clearly demonstrate the step-by-step process of the algorithm, including: 1) Representing the ...
Create Manim code to visualize the Fibonacci Sequence using Dynamic Programming (DP). The visualization should clearly demonstrate the step-by-step process of solving the Fibonacci problem, including: 1) Representing the recursive tree structure without DP to show overlapping subproblems, 2) Highlighting how memoizatio...
Compute Fibonacci numbers up to F(6)
from manim import * class FibonacciDPDetailedVisualization(Scene): def construct(self): # Step 1: Define the Fibonacci sequence using Dynamic Programming n = 6 # Compute Fibonacci numbers up to F(6) dp = self.fibonacci_dp(n) # Step 2: Create visual elements for the Fibonacci sequ...
Below is an instruction that describes a task. Write a response that appropriately completes the request. ### Create Manim code to visualize the Fibonacci Sequence using Dynamic Programming (DP). The visualization should clearly demonstrate the step-by-step process of solving the Fibonacci problem, including: 1) Repre...
Create Manim code to visualize the Travelling Salesman Problem (TSP). The visualization should clearly demonstrate the step-by-step process of solving the TSP, including: 1) Representing cities as nodes and distances as weighted edges on a 2D plane, 2) Highlighting the brute-force approach by showing all possible route...
A set of cities: A (-2, 1), B (0, 2), C (2, 1), D (0, 0).
from manim import * import numpy as np def distance(p1, p2): """Calculate the Euclidean distance between two points.""" return np.linalg.norm(p1 - p2) class TSPSolver(Scene): def construct(self): title = Text("TSP Problem Visualization", font_size=30).to_edge(UP) self.play(Write(title)) ...
Below is an instruction that describes a task. Write a response that appropriately completes the request. ### Create Manim code to visualize the Travelling Salesman Problem (TSP). The visualization should clearly demonstrate the step-by-step process of solving the TSP, including: 1) Representing cities as nodes and di...
End of preview. Expand in Data Studio
README.md exists but content is empty.
Downloads last month
5