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 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]; |
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 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 |
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 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) | |
{ |
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 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; |
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
var global = 'Eu sou uma variavel global!'; | |
function prisao() { | |
var prisioneiro = 'Eu sou uma variavel local!'; | |
} | |
prisao(); | |
console.log(global); | |
console.log(prisioneiro); |
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
var nome = 'Fulano'; | |
function prisao() { | |
console.log(nome); | |
var nome; | |
} | |
prisao(); |
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
var pessoa = { | |
id: 1, | |
nome: 'Renato Gama', | |
idade: 25 | |
}; |
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
var prototipo = { | |
id: 0, | |
nome: '', | |
idade: 0 | |
}; | |
var construirPessoa = function(id, nome, idade){ | |
var novo = Object.create(prototipo); | |
novo.id = id; |
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
var objectCreate = function(arg){ | |
if (!arg) { return {}; } | |
function obj() {}; | |
obj.prototype = arg; | |
return new obj; | |
}; | |
Object.create = Object.create || objectCreate; |
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
var prototipo = { | |
id: 0, | |
nome: '', | |
idade: 0, | |
constante: 3.14 //Essa linha é nova | |
}; | |
var construirPessoa = function(id, nome, idade){ | |
var novo = Object.create(prototipo); |
OlderNewer