Skip to content

Instantly share code, notes, and snippets.

View rishi93's full-sized avatar

Rajarishi Devarajan rishi93

View GitHub Profile
@rishi93
rishi93 / test3.py
Last active November 6, 2018 08:43
Animated 2D plot in Matplotlib
import numpy as np
import matplotlib.pyplot as plt
from matplotlib.animation import FuncAnimation
# Create the figure and the axes
fig = plt.figure()
ax = fig.add_subplot(111, title = 'Sine wave animation')
# Initialize the axes
ax.set_xlim(0, 2*np.pi)
@rishi93
rishi93 / test2.py
Last active November 6, 2018 08:42
Simple 3D plot in Matplotlib
import numpy as np
import matplotlib.pyplot as plt
from mpl_toolkits import mplot3d
# Create the figure and the axes
fig = plt.figure()
ax = fig.add_subplot(111, projection = '3d', title = 'A 3D curve')
# Prepare the data points
z = np.linspace(-4*np.pi, 4*np.pi, 100)
@rishi93
rishi93 / test1.py
Last active November 6, 2018 08:41
Simple 2D plot in Matplotlib
import numpy as np
import matplotlib.pyplot as plt
# Create the figure and the axes
fig = plt.figure()
ax = fig.add_subplot(111, title = 'Sine wave')
# Prepare the datapoints
x = np.linspace(0, 2*np.pi, 100)
y = np.sin(x)
@rishi93
rishi93 / Test.java
Created December 18, 2017 16:45
Binary search tree (Implementation in Java)
import java.util.Queue;
import java.util.LinkedList;
class Node{
int data;
Node left, right;
Node(int data){
this.data = data;
this.left = null;
@rishi93
rishi93 / Test.java
Created December 18, 2017 10:23
Linked List reversal
class Node{
int data;
Node next;
Node(int data){
this.data = data;
this.next = null;
}
}
@rishi93
rishi93 / Test.java
Last active December 18, 2017 07:40
Linked List (Java implementation)
class Node{
int data;
Node next;
Node(int data){
this.data = data;
this.next = null;
}
}
@rishi93
rishi93 / Test.java
Last active July 23, 2022 13:04
Segment Tree (Implementation in Java)
class SegmentTree{
int[] tree;
SegmentTree(int n){
tree = new int[n];
}
void build(int[] arr, int node, int start, int end){
if(start == end){
tree[node] = arr[start];
@rishi93
rishi93 / binarytree.py
Created December 16, 2017 17:00
Inorder, Preorder, Postorder traversals
class Node:
def __init__(self, data):
self.data = data
self.left = None
self.right = None
class BinaryTree:
def __init__(self):
self.root = None
@rishi93
rishi93 / binarytree.py
Created December 16, 2017 16:33
Binary Tree Level order traversal
class Node:
def __init__(self, data):
self.data = data
self.left = None
self.right = None
class BinaryTree:
def __init__(self):
@rishi93
rishi93 / Test.java
Created December 16, 2017 08:34
Inorder, Preorder, Postorder traversals
class Node{
int data;
Node left, right;
Node(int data){
this.data = data;
this.left = null;
this.right = null;
}
}