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
fun bubbleSortLoop(inputArray: Array<Int>): Array<Int> { | |
var iterations = 1 | |
var isSorted: Boolean | |
for (i in 0 until inputArray.size -1) { | |
isSorted = true | |
// This print is for see the interactions in sort algorithm | |
println("Iteration number: ${iterations++}") | |
for (j in 0 until inputArray.size -i -1) { | |
if (inputArray[j] > inputArray[j+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
fun bubbleSort(inputArray: Array<Int>, nextIterIndex: Int = inputArray.size): Array<Int> { | |
// This print is for see the interactions in sort algorithm | |
println("iteration number ${inputArray.size - nextIterIndex+1}") | |
val lastIndex = nextIterIndex -1 | |
var isSorted = true | |
for (i in 0 until lastIndex) { | |
val currentItem = inputArray[i] | |
val nextItem = inputArray[i+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
// The inputArray must be sorted in order to apply the binary search. | |
fun binarySearch(inputArray: Array<Int>, itemToSearch: Int) : Boolean { | |
// This print is for see the interactions in the search | |
println() | |
inputArray.forEach { | |
print("$it,") | |
} | |
if (inputArray.size > 1) { | |
if (itemToSearch == inputArray[(inputArray.size / 2) - 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
const functions = require('firebase-functions'); | |
const gcs = require('@google-cloud/storage')(); | |
const spawn = require('child-process-promise').spawn; | |
const mkdirp = require('mkdirp-promise'); | |
const path = require('path'); | |
const os = require('os'); | |
const fs = require('fs'); | |
// // Create and Deploy Your First Cloud Functions | |
exports.optimizeImages= functions.storage.object().onFinalize((data) => { |