Skip to content

Instantly share code, notes, and snippets.

View john-nash-rs's full-sized avatar
🎯
Focusing

Harsh Vardhan john-nash-rs

🎯
Focusing
View GitHub Profile
@john-nash-rs
john-nash-rs / Huffman.java
Last active November 13, 2017 15:21
Huffman code, Huffman Tree, Huffman encoading
package com.tutorial.protobuf;
import java.util.HashMap;
import java.util.Map;
import java.util.PriorityQueue;
public class Huffman {
@john-nash-rs
john-nash-rs / melbourne_housing_price_prediction.py
Last active November 18, 2017 21:47
A decision tree model based on Melbourne Housing Dataset.
# 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]:
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
for i=n/2 downto 1
do max_heapify(A, i)
@john-nash-rs
john-nash-rs / graph_dict.py
Created July 7, 2018 19:00
Graph Representation In Python. Key is vertice name and value is set of neighbouring vertices.
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
@john-nash-rs
john-nash-rs / depth_first_search.py
Created July 7, 2018 19:30
Depth First Search Python Implementation : Prints all the nodes of the graph
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
@john-nash-rs
john-nash-rs / pom.xml
Created July 12, 2018 10:13
POM with dropwizard core dependency
<?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>
@john-nash-rs
john-nash-rs / MyConfiguration.java
Created July 12, 2018 11:58
Configuration file for dropwizard application
import io.dropwizard.Configuration;
/**
* Created by harshvardhan on 12/07/18.
*/
public class MyConfiguration extends Configuration {
private String url;
public String getUrl() {
url: https://nullpointerexception1.wordpress.com/
url: https://nullpointerexception1.wordpress.com/