Skip to content

Instantly share code, notes, and snippets.

View renatoargh's full-sized avatar
🚀

Renato Gama renatoargh

🚀
View GitHub Profile
@renatoargh
renatoargh / InsertionSort.cs
Created October 8, 2011 03:43
InsertionSort
public void InsertionSort(List<Int32> elements, Boolean ascending = true)
{
for (Int32 j = 1; j < elements.Count; j++)
{
Int32 key = elements[j];
Int32 i = j - 1;
while (i >= 0 && (elements[i] > key) == ascending)
{
elements[i + 1] = elements[i];
@renatoargh
renatoargh / InsertionSort-Analizado.cs
Created October 9, 2011 07:42
InsertionSort-Analizado
public void InsertionSort(List<Int32> elements, Boolean ascending = true)
{ //CUSTO EXECUÇÕES
for (Int32 j = 1; j < elements.Count; j++) //c1 n
{
Int32 key = elements[j]; //c2 n - 1
Int32 i = j - 1; //c3 n - 1
while (i >= 0 && (elements[i] > key) == ascending) //c4 somatorio[j = 1 -> n] tj
{
elements[i + 1] = elements[i]; //c5 somatorio[j = 1 -> n] tj - 1
public static Int32 FibonacciR(Int32 n)
{
if (n == 0 || n == 1)
return n;
else
return FibonacciR(n - 1) + FibonacciR(n - 2);
}
public static Int32 FibonacciI(Int32 n)
{
@renatoargh
renatoargh / MergeSort-Merge.cs
Created November 28, 2011 01:30
MergeSort-Merge
public List<Int32> Merge(List<Int32> a, List<Int32> b)
{
Int32 size = a.Count + b.Count;
List<Int32> mergedList = new List<Int32>(size);
a.Add(Int32.MaxValue);
b.Add(Int32.MaxValue);
Int32 i = 0;
Int32 j = 0;
var global = 'Eu sou uma variavel global!';
function prisao() {
var prisioneiro = 'Eu sou uma variavel local!';
}
prisao();
console.log(global);
console.log(prisioneiro);
var nome = 'Fulano';
function prisao() {
console.log(nome);
var nome;
}
prisao();
var pessoa = {
id: 1,
nome: 'Renato Gama',
idade: 25
};
var prototipo = {
id: 0,
nome: '',
idade: 0
};
var construirPessoa = function(id, nome, idade){
var novo = Object.create(prototipo);
novo.id = id;
var objectCreate = function(arg){
if (!arg) { return {}; }
function obj() {};
obj.prototype = arg;
return new obj;
};
Object.create = Object.create || objectCreate;
var prototipo = {
id: 0,
nome: '',
idade: 0,
constante: 3.14 //Essa linha é nova
};
var construirPessoa = function(id, nome, idade){
var novo = Object.create(prototipo);