Skip to content

Instantly share code, notes, and snippets.

@rohitsingh20122992
rohitsingh20122992 / Huffman.java
Last active Nov 13, 2017
Huffman code, Huffman Tree, Huffman encoading
View Huffman.java
package com.tutorial.protobuf;
import java.util.HashMap;
import java.util.Map;
import java.util.PriorityQueue;
public class Huffman {
@rohitsingh20122992
rohitsingh20122992 / melbourne_housing_price_prediction.py
Last active Nov 18, 2017
A decision tree model based on Melbourne Housing Dataset.
View melbourne_housing_price_prediction.py
# coding: utf-8
# In[1]:
#Pandas is the primary tool that modern data scientists use for exploring and manipulating data. Let's import it.
import pandas as pd
# In[6]:
View max_heapify_pseudocode.txt
max-heapify(A,i){
index_of_left_child = left(i);
index_of_right_child = right(i);
heap_size = number_of_elements_in_heap(A)
if((index_of_left_child <= heap_size) && (A[index_of_left_child] > A[i]))
largest = index_of_left_child
else
largest = i
@rohitsingh20122992
rohitsingh20122992 / graph_dict.py
Created Jul 7, 2018
Graph Representation In Python. Key is vertice name and value is set of neighbouring vertices.
View graph_dict.py
graph = {'A' : set(['G','B']),
'B' : set(['C','D','A']),
'C' : set(['F','D','B']),
'D' : set(['B','C']),
'E' : set(['F']),
'F' : set(['E','C']),
'G' : set(['A']),
}
print graph
@rohitsingh20122992
rohitsingh20122992 / depth_first_search.py
Created Jul 7, 2018
Depth First Search Python Implementation : Prints all the nodes of the graph
View depth_first_search.py
def depth_first_search(graph, start_node):
visited_neighbours = set() #Keep track of the node we have visited like breadcrumbs to know the path
neighbours = [start_node] #list to store the neighbors. We will start with neigbors of void, the start node
while (len(neighbours) != 0): #All the elements will be transversed by the time we have this list size as zero
neighbour = neighbours.pop() #pop will take out randomly any one element and deletes from the list
if neighbour not in visited_neighbours:
visited_neighbours.add(neighbour)
new_prospected_neighbours = graph[neighbour]
#Need to remove neighbours which are already visted
@rohitsingh20122992
rohitsingh20122992 / pom.xml
Created Jul 12, 2018
POM with dropwizard core dependency
View pom.xml
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.wordpress.nullpointerexception1</groupId>
<artifactId>myRestProject</artifactId>
<version>1.0-SNAPSHOT</version>
@rohitsingh20122992
rohitsingh20122992 / MyConfiguration.java
Created Jul 12, 2018
Configuration file for dropwizard application
View MyConfiguration.java
import io.dropwizard.Configuration;
/**
* Created by harshvardhan on 12/07/18.
*/
public class MyConfiguration extends Configuration {
private String url;
public String getUrl() {
View dev.yml
url: https://nullpointerexception1.wordpress.com/
View dev.yml
url: https://nullpointerexception1.wordpress.com/