```import numpy as np

def pagerank(M, num_iterations=100, d=0.85):
N = M.shape
v = np.random.rand(N, 1)
v = v / np.linalg.norm(v, 1)
iteration = 0
while iteration < num_iterations:
iteration += 1
v = d * np.matmul(M, v) + (1 - d) / N
return v```
```import java.util.Stack;

/**
* Java Program to implement a binary search tree. A binary search tree is a
* sorted binary tree, where value of a node is greater than or equal to its
* left the child and less than or equal to its right child.
*
* @author WINDOWS 8
*
*/
public class BST {

private static class Node {
private int data;
private Node left, right;

public Node(int value) {
data = value;
left = right = null;
}
}

private Node root;

public BST() {
root = null;
}

public Node getRoot() {
return root;
}

/**
* Java function to check if binary tree is empty or not
* Time Complexity of this solution is constant O(1) for
* best, average and worst case.
*
* @return true if binary search tree is empty
*/
public boolean isEmpty() {
return null == root;
}

/**
* Java function to return number of nodes in this binary search tree.
* Time complexity of this method is O(n)
* @return size of this binary search tree
*/
public int size() {
Node current = root;
int size = 0;
Stack<Node> stack = new Stack<Node>();
while (!stack.isEmpty() || current != null) {
if (current != null) {
stack.push(current);
current = current.left;
} else {
size++;
current = stack.pop();
current = current.right;
}
}
return size;
}

/**
* Java function to clear the binary search tree.
* Time complexity of this method is O(1)
*/
public void clear() {
root = null;
}

}
```
bookmark
dashboard

Thu Jan 02 2020 19:00:00 GMT+0000 (UTC) https://en.wikipedia.org/wiki/PageRank

#javascript #python #search #historicalcode #google #algorithms
bookmark
dashboard

Sun Dec 29 2019 20:06:50 GMT+0000 (UTC) https://javarevisited.blogspot.com/2015/10/how-to-implement-binary-search-tree-in-java-example.html#axzz4wnEtnNB3

#java #interviewquestions #search

#### Save snippets that work with our extensions   