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
from string import ascii_letters | |
for i in ascii_letters: | |
for j in ascii_letters: | |
for k in ascii_letters: | |
for l in ascii_letters: | |
print(i, j, k, l) |
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
function partition(a, l, r) { | |
let pivot = a[r]; // Select the last element as the pivot | |
let i = l - 1; // Index of the last element smaller than the pivot | |
for (let j = l; j < r; j++) { | |
if (a[j] <= pivot) { | |
i++; | |
// Swap the element to the left of the pivot | |
let temp = a[i]; | |
a[i] = a[j]; |
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
/** | |
* İki alt diziyi birleştiren merge() fonksiyonu. | |
* | |
* @param {Array} array - Sıralanacak dizinin kendisi. | |
* @param {Array} temp - Geçici dizi. | |
* @param {number} left - Alt dizinin başlangıç indis değeri. | |
* @param {number} middle - İki alt dizinin ayıracı. | |
* @param {number} right - Alt dizinin bitiş indis değeri. | |
*/ | |
function merge(array, temp, left, middle, right) { |
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
function insertionSort(array) { | |
for (let i = 1; i < array.length; i++) { | |
let key = array[i] | |
let j = i | |
while (j > 0 && array[j - 1] > key) { | |
// We check j>0 to stop the while loop at the start of the array. | |
array[j] = array[j - 1] | |
j-- | |
} | |
array[j] = key |
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
function selectionSort(array) { | |
for (let i = 0; i < array.length; i++) { | |
let min = i | |
for (let j = i + 1; j < array.length; j++) { | |
if (array[j] <= array[min]) { | |
min = j | |
} | |
} | |
swap(array, i, min) | |
} |
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
function bubbleSort(array) { | |
let isSwapped = true | |
while (isSwapped) { | |
isSwapped = false | |
for (let i = 0; i < array.length; i++) { | |
if (array[i] > array[i + 1]) { | |
swap(array, i, i + 1) | |
isSwapped = true | |
} | |
} |
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
function binarySearch(array, target) { | |
let start = 0 | |
let end = array.length - 1 | |
while (end >= start) { | |
let middle = (end + start) / 2; // Index of the middle element | |
if (target == array[middle]) return true; // found | |
if (target < array[middle]) end = middle - 1 | |
if (target > array[middle]) start = middle + 1 | |
} | |
return false; |
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
function linearSearch(array, target){ | |
for(let i=0; i< array.length; i++){ | |
if(array[i] == target) return true | |
} | |
return false | |
} |
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
<snippet> | |
<content><![CDATA[ | |
<!DOCTYPE html> | |
<html> | |
<head> | |
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /> | |
<title>$1</title> | |
</head> | |
<body> | |
<h1>$1</h1> |