(by @andrestaltz)
If you prefer to watch video tutorials with live-coding, then check out this series I recorded with the same contents as in this article: Egghead.io - Introduction to Reactive Programming.
package com.datastructures; | |
public class BinarySearchTreeDS<Key extends Comparable<Key>, Value> { | |
//My node of a BST | |
private class Node | |
{ | |
Key key; | |
Value value; | |
Node left, right; | |
public Node(Key key, Value value) { |
package com.datastructures; | |
public class BinaryHeap { | |
//This is an implementation of Binary Heap using an array. | |
//The Binary Heap is represented as a Tree. The Root of the tree is the 1st index in the array. Lets call that 'k'. | |
//The left and right child of the tree are computed using the formula 2k and 2k+1 | |
//If you want to find the index of the parent from, from the node you're currently in, then you can use the formula k/2. | |
//This is how we shall be traversing the tree and also this is the reason we keep the root of the tree at the 1st index of the array and not the 0th. | |
//Property of the Binary Heap Tree: The element in the root always has to be greater than both its children/child elements | |
package com.algorithms; | |
import java.util.Random; | |
/** | |
* Quicksort is popular because it is not difficult to implement, works well for | |
* a variety of different kinds of input data, and is substantially faster than | |
* any other sorting method in typical applications. It is in-place (uses only a | |
* small auxiliary stack), requires time proportional to N log N on the average | |
* to sort N items, and has an extremely short inner loop. The basic algorithm: |
package com.algorithms; | |
import java.util.Arrays; | |
import java.util.Scanner; | |
public class BinarySearch { | |
public boolean search(int low, int hi, int[] a, int searchFor) | |
{ | |
int mid = (hi + low)/2; | |
if(a[mid] == searchFor) return true; |
package com.gplus; | |
import java.io.File; | |
import java.io.FileOutputStream; | |
import java.io.InputStream; | |
import java.util.Enumeration; | |
import java.util.Scanner; | |
import java.util.zip.ZipEntry; | |
import java.util.zip.ZipFile; |
package com.interview.coding.crack; | |
public class RotateMatrixByOneEightyDegree { | |
public void rotateByOneEightyDegree(int[][] array, int m, int n) | |
{ | |
for(int i = 0; i < ((m/2) + (m%2)); i++) | |
{ | |
int first = i; | |
int last = n - 1; |
package com.interview.coding.crack; | |
public class FindingIfSubstring { | |
public boolean isSubstring(char a[], char b[]) | |
{ | |
int joint = 0; | |
int indexer = 0; | |
boolean flag = false; | |
if(a.length != b.length) |
import java.util.Arrays; | |
import java.util.Scanner; | |
public class RailwayTickets { | |
int numOfTickets, ticketsToSell; | |
int[] ticketsPerBooth; | |
public RailwayTickets(int numOfTickets, int ticketsToSell, int[] ticketsPerBooth) | |
{ | |
this.numOfTickets = numOfTickets; |
import java.util.ArrayList; | |
import java.util.Collections; | |
import java.util.List; | |
import java.util.Scanner; | |
/* | |
* HACKERRANK INTERVIEW QUESTION | |
* | |
* You are given a list of size N, initialized with zeroes. You have to perform M queries on the list and output the | |
* maximum of final values of all the N elements in the list. For every query, you are given three integers a, b and k and |
(by @andrestaltz)
If you prefer to watch video tutorials with live-coding, then check out this series I recorded with the same contents as in this article: Egghead.io - Introduction to Reactive Programming.