Skip to content

Instantly share code, notes, and snippets.

View tgvdinesh's full-sized avatar

Dinesh V tgvdinesh

View GitHub Profile
@tgvdinesh
tgvdinesh / BinarySearchTree.java
Last active November 15, 2016 15:46
Binary search Tree data structure implementation in Java
package com.oracle.java;
public class BinarySearchTree {
private int treeHeight(Node root) {
if (root == null) return 0;
return (1 + Math.max(treeHeight(root.left), treeHeight(root.right)));
}
private boolean isBalancedNaive(Node node) {
@tgvdinesh
tgvdinesh / Android API connection using HttpURLConnection
Last active August 29, 2015 14:15 — forked from anonymous/gist:1c04bf2423579e9d2dcd
The sample code provided is used to get data from any API in Android
// These two need to be declared outside the try/catch
// so that they can be closed in the finally block.
HttpURLConnection urlConnection = null;
BufferedReader reader = null;
// Will contain the raw JSON response as a string.
String forecastJsonStr = null;
try {
// Construct the URL for the OpenWeatherMap query