This file contains hidden or 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
| /** | |
| procedure bubbleSort(A : list of sortable items ) | |
| n = length(A) | |
| repeat | |
| swapped = false | |
| for i = 1 to n-1 inclusive do | |
| // if this pair is out of order | |
| if A[i-1] > A[i] then | |
| // swap them and remember something changed | |
| swap( A[i-1], A[i] ) |
This file contains hidden or 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
| (function () { | |
| function selectionSort(array){ | |
| let tmp, min; | |
| /* advance the position through the entire array */ | |
| /* (could do i < array.length-1 because single element is also min element) */ | |
| for(let i = 0;i < array.length -1; i++){ | |
| /* find the min element in the unsorted a[i .. array.length-1] */ | |
| /* assume the min is the first element */ | |
| min = i; | |
| /* test against elements after i to find the smallest */ |
This file contains hidden or 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
| /** | |
| i ← 1 | |
| while i < length(A) | |
| j ← i | |
| while j > 0 and A[j-1] > A[j] | |
| swap A[j] and A[j-1] | |
| j ← j - 1 | |
| end while | |
| i ← i + 1 | |
| end while |
This file contains hidden or 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
| /*Given a list of N coins, their values (V1, V2, … , VN), and the total sum S. Find the minimum number of coins the sum of which is S (we can use as many coins of one type as we want), or report that it’s not possible to select coins in such a way that | |
| they sum up to S. | |
| Given coins with values 1, 3, and 5. And the sum S is set to be 9. | |
| Given coins with values 1, 3, and 5. And the sum S is set to be 10. | |
| Given coins with values 1, 3, and 5. And the sum S is set to be 11. | |
| Given coins with values 1, 3, and 5. And the sum S is set to be 20. | |
| */ | |
| (function () { |
This file contains hidden or 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
| /*Using a Memo to Avoid Repetitious Calculation*/ | |
| (function() { | |
| function calcFibonacci(n, memo) { | |
| // If we've got the answer in our memo, no need to recalculate | |
| if (memo[n] !== -1) { | |
| return memo[n]; | |
| } | |
| // Otherwise, calculate the answer and store it in memo |
This file contains hidden or 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
| /* | |
| Veronica | |
| | | |
| | | |
| ____________ | |
| | | | |
| Nathan Sally | |
| | | | |
| | __________ |
This file contains hidden or 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
| /** | |
| * Implement function verify (text) which checks whether brackets within text are correctly nested. | |
| * You need to consider brackets of three kinds: (), [], <>. | |
| */ | |
| (function() { | |
| function verify(value){ | |
| var str = ''; | |
| value = value.replace(/[^\(\)\[\]\<\>]/g,''); |
This file contains hidden or 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
| Complete the markup for put the number in a badge | |
| -------------- | |
| | Inbox |42| | | |
| -------------- | |
| |Messages |4| | | |
| --------------- | |
| <a href="#">Inbox 42</a> | |
| <button class="btn btn-primary" type="button"> |
This file contains hidden or 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
| //IIEF don't populate window namespace | |
| (function () { | |
| // Create a name space | |
| var answers = answers || {}; | |
| answers = { | |
| meta: function (fn) { | |
| console.log("en meta"); | |
| fn(); | |
| }, |
This file contains hidden or 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
| function meta(f) { | |
| console.log("en meta"); | |
| f(); | |
| } | |
| var lista=[meta,meta,meta]; | |
| var fun=function() { | |
| console.log("funcion"); | |
| } | |
| for(var i=0;i<lista.length;i++) { | |
| var item=lista[i]; |
NewerOlder