This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#Newbie programmer | |
def factorial(x): | |
if x == 0: | |
return 1 | |
else: | |
return x * factorial(x - 1) | |
print factorial(6) | |
#First year programmer, studied Pascal |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import java.io.FileNotFoundException; | |
import java.io.UnsupportedEncodingException; | |
import java.util.Arrays; | |
import java.util.Collections; | |
import java.util.Formatter; | |
import java.util.List; | |
import java.util.Locale; | |
import java.util.Scanner; | |
import java.util.Stack; | |
import java.util.regex.Matcher; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class Secret { | |
private String secretCode = "It's a secret"; | |
private String getSecretCode(){ | |
return secretCode; | |
} | |
} | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Connects to the database | |
* | |
* Connects to the database and some other | |
* discription.... | |
* @param $type some variable | |
*/ | |
function connect($type = '') { | |
//some code | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <iostream> | |
#include <sstream> | |
#include <stdlib.h> | |
#include <string> | |
#include <map> | |
int getIntVal(std::string strConvert) { | |
int intReturn; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Initial: | |
x.x.x.x | |
x.x.x | |
x.x...x | |
x.x.x | |
x.x.x.x | |
1. | |
xOx.x.x | |
xOx.x |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Class Main { | |
public void bfs() | |
{ | |
// BFS uses Queue data structure | |
Queue queue = new LinkedList(); | |
queue.add(this.rootNode); | |
printNode(this.rootNode); | |
rootNode.visited = true; | |
while(!queue.isEmpty()) { | |
Node node = (Node)queue.remove(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import java.util.*; | |
public class Dijkstra { | |
// assumes Nodes are numbered 0, 1, ... n and that the source Node is 0 | |
ArrayList<Node> findShortestPath(Node[] nodes, Edge[] edges, Node target) { | |
int[][] Weight = initializeWeight(nodes, edges); | |
int[] D = new int[nodes.length]; | |
Node[] P = new Node[nodes.length]; | |
ArrayList<Node> C = new ArrayList<Node>(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
int partition(int arr[], int left, int right) | |
{ | |
int i = left, j = right; | |
int tmp; | |
int pivot = arr[(left + right) / 2]; | |
while (i <= j) { | |
while (arr[i] < pivot) | |
i++; | |
while (arr[j] > pivot) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Mergesort algorithm. | |
* @param a an array of Comparable items. | |
*/ | |
public static void mergeSort( Comparable [ ] a ) { | |
Comparable [ ] tmpArray = new Comparable[ a.length ]; | |
mergeSort( a, tmpArray, 0, a.length - 1 ); | |
} | |
/** |
OlderNewer