id int64 1 2.26k | language stringclasses 7
values | category stringclasses 3
values | difficulty stringclasses 2
values | task_description stringclasses 132
values | code stringlengths 68 753 | explanation stringclasses 449
values |
|---|---|---|---|---|---|---|
501 | Rust | Sorting Algorithm | intermediate | Sort a 15-element array of floats in ascending order using selection sort. | fn selection_sort(collection: &mut Vec<f64>) {
let n = collection.len();
for i in 0..n {
let mut min_idx = i;
for j in (i + 1)..n {
if collection[j] < collection[min_idx] {
min_idx = j;
}
}
collection.swap(i, min_idx);
}
}
fn main() {
... | Selection sort on float data, variable named 'collection', 15 elements. |
502 | Rust | Sorting Algorithm | intermediate | Sort a 20-element array of floats in ascending order using selection sort. | fn selection_sort(values: &mut Vec<f64>) {
let n = values.len();
for i in 0..n {
let mut min_idx = i;
for j in (i + 1)..n {
if values[j] < values[min_idx] {
min_idx = j;
}
}
values.swap(i, min_idx);
}
}
fn main() {
let mut values =... | Selection sort on float data, variable named 'values', 20 elements. |
503 | Rust | Sorting Algorithm | intermediate | Sort a 20-element array of floats in ascending order using selection sort. | fn selection_sort(collection: &mut Vec<f64>) {
let n = collection.len();
for i in 0..n {
let mut min_idx = i;
for j in (i + 1)..n {
if collection[j] < collection[min_idx] {
min_idx = j;
}
}
collection.swap(i, min_idx);
}
}
fn main() {
... | Selection sort on float data, variable named 'collection', 20 elements. |
504 | Rust | Sorting Algorithm | intermediate | Sort a 20-element array of floats in ascending order using selection sort. | fn selection_sort(items: &mut Vec<f64>) {
let n = items.len();
for i in 0..n {
let mut min_idx = i;
for j in (i + 1)..n {
if items[j] < items[min_idx] {
min_idx = j;
}
}
items.swap(i, min_idx);
}
}
fn main() {
let mut items = vec![... | Selection sort on float data, variable named 'items', 20 elements. |
505 | Python | Sorting Algorithm | intermediate | Sort a 5-element array of ints in ascending order using insertion sort. | def insertion_sort(entries):
for i in range(1, len(entries)):
key = entries[i]
j = i - 1
while j >= 0 and entries[j] > key:
entries[j + 1] = entries[j]
j -= 1
entries[j + 1] = key
return entries
print(insertion_sort([35, 85, -42, 25, 59])) | Insertion sort on int data, variable named 'entries', 5 elements. |
506 | Python | Sorting Algorithm | intermediate | Sort a 5-element array of ints in ascending order using insertion sort. | def insertion_sort(vals):
for i in range(1, len(vals)):
key = vals[i]
j = i - 1
while j >= 0 and vals[j] > key:
vals[j + 1] = vals[j]
j -= 1
vals[j + 1] = key
return vals
print(insertion_sort([19, 88, 97, 3, -30])) | Insertion sort on int data, variable named 'vals', 5 elements. |
507 | Python | Sorting Algorithm | intermediate | Sort a 5-element array of ints in ascending order using insertion sort. | def insertion_sort(elements):
for i in range(1, len(elements)):
key = elements[i]
j = i - 1
while j >= 0 and elements[j] > key:
elements[j + 1] = elements[j]
j -= 1
elements[j + 1] = key
return elements
print(insertion_sort([35, -36, 81, 43, -37])) | Insertion sort on int data, variable named 'elements', 5 elements. |
508 | Python | Sorting Algorithm | intermediate | Sort a 8-element array of ints in ascending order using insertion sort. | def insertion_sort(data):
for i in range(1, len(data)):
key = data[i]
j = i - 1
while j >= 0 and data[j] > key:
data[j + 1] = data[j]
j -= 1
data[j + 1] = key
return data
print(insertion_sort([48, 43, 69, -40, 43, 43, -6, 93])) | Insertion sort on int data, variable named 'data', 8 elements. |
509 | Python | Sorting Algorithm | intermediate | Sort a 8-element array of ints in ascending order using insertion sort. | def insertion_sort(seq):
for i in range(1, len(seq)):
key = seq[i]
j = i - 1
while j >= 0 and seq[j] > key:
seq[j + 1] = seq[j]
j -= 1
seq[j + 1] = key
return seq
print(insertion_sort([-33, 93, 2, -15, 35, 11, 88, -21])) | Insertion sort on int data, variable named 'seq', 8 elements. |
510 | Python | Sorting Algorithm | intermediate | Sort a 8-element array of ints in ascending order using insertion sort. | def insertion_sort(buffer):
for i in range(1, len(buffer)):
key = buffer[i]
j = i - 1
while j >= 0 and buffer[j] > key:
buffer[j + 1] = buffer[j]
j -= 1
buffer[j + 1] = key
return buffer
print(insertion_sort([72, 98, 3, 7, 32, 40, 18, 78])) | Insertion sort on int data, variable named 'buffer', 8 elements. |
511 | Python | Sorting Algorithm | intermediate | Sort a 10-element array of ints in ascending order using insertion sort. | def insertion_sort(buffer):
for i in range(1, len(buffer)):
key = buffer[i]
j = i - 1
while j >= 0 and buffer[j] > key:
buffer[j + 1] = buffer[j]
j -= 1
buffer[j + 1] = key
return buffer
print(insertion_sort([58, 20, -37, -34, 45, 38, 65, 74, 78, 84])) | Insertion sort on int data, variable named 'buffer', 10 elements. |
512 | Python | Sorting Algorithm | intermediate | Sort a 10-element array of ints in ascending order using insertion sort. | def insertion_sort(records):
for i in range(1, len(records)):
key = records[i]
j = i - 1
while j >= 0 and records[j] > key:
records[j + 1] = records[j]
j -= 1
records[j + 1] = key
return records
print(insertion_sort([-19, 70, 86, 86, 24, 65, 44, -34, -2, ... | Insertion sort on int data, variable named 'records', 10 elements. |
513 | Python | Sorting Algorithm | intermediate | Sort a 10-element array of ints in ascending order using insertion sort. | def insertion_sort(data):
for i in range(1, len(data)):
key = data[i]
j = i - 1
while j >= 0 and data[j] > key:
data[j + 1] = data[j]
j -= 1
data[j + 1] = key
return data
print(insertion_sort([-30, 50, -5, 23, -31, -23, -8, 20, -22, -13])) | Insertion sort on int data, variable named 'data', 10 elements. |
514 | Python | Sorting Algorithm | intermediate | Sort a 12-element array of ints in ascending order using insertion sort. | def insertion_sort(dataset):
for i in range(1, len(dataset)):
key = dataset[i]
j = i - 1
while j >= 0 and dataset[j] > key:
dataset[j + 1] = dataset[j]
j -= 1
dataset[j + 1] = key
return dataset
print(insertion_sort([-12, 2, 83, -45, 25, 56, 88, -17, 71, ... | Insertion sort on int data, variable named 'dataset', 12 elements. |
515 | Python | Sorting Algorithm | intermediate | Sort a 12-element array of ints in ascending order using insertion sort. | def insertion_sort(seq):
for i in range(1, len(seq)):
key = seq[i]
j = i - 1
while j >= 0 and seq[j] > key:
seq[j + 1] = seq[j]
j -= 1
seq[j + 1] = key
return seq
print(insertion_sort([-45, 24, -2, -34, -45, 9, 83, 35, 55, 98, 37, 33])) | Insertion sort on int data, variable named 'seq', 12 elements. |
516 | Python | Sorting Algorithm | intermediate | Sort a 12-element array of ints in ascending order using insertion sort. | def insertion_sort(dataset):
for i in range(1, len(dataset)):
key = dataset[i]
j = i - 1
while j >= 0 and dataset[j] > key:
dataset[j + 1] = dataset[j]
j -= 1
dataset[j + 1] = key
return dataset
print(insertion_sort([85, 90, 63, 67, 27, 95, -17, 28, -7, 1... | Insertion sort on int data, variable named 'dataset', 12 elements. |
517 | Python | Sorting Algorithm | intermediate | Sort a 15-element array of ints in ascending order using insertion sort. | def insertion_sort(list1):
for i in range(1, len(list1)):
key = list1[i]
j = i - 1
while j >= 0 and list1[j] > key:
list1[j + 1] = list1[j]
j -= 1
list1[j + 1] = key
return list1
print(insertion_sort([23, -38, -13, 40, 22, 66, -8, -9, 87, 23, -4, -6, -11,... | Insertion sort on int data, variable named 'list1', 15 elements. |
518 | Python | Sorting Algorithm | intermediate | Sort a 15-element array of ints in ascending order using insertion sort. | def insertion_sort(data):
for i in range(1, len(data)):
key = data[i]
j = i - 1
while j >= 0 and data[j] > key:
data[j + 1] = data[j]
j -= 1
data[j + 1] = key
return data
print(insertion_sort([-40, 31, 97, -18, 62, 16, 44, -3, 2, 93, -42, 31, 38, -13, 45]... | Insertion sort on int data, variable named 'data', 15 elements. |
519 | Python | Sorting Algorithm | intermediate | Sort a 15-element array of ints in ascending order using insertion sort. | def insertion_sort(dataset):
for i in range(1, len(dataset)):
key = dataset[i]
j = i - 1
while j >= 0 and dataset[j] > key:
dataset[j + 1] = dataset[j]
j -= 1
dataset[j + 1] = key
return dataset
print(insertion_sort([88, -9, 86, 27, -19, -44, 53, 77, -13,... | Insertion sort on int data, variable named 'dataset', 15 elements. |
520 | Python | Sorting Algorithm | intermediate | Sort a 20-element array of ints in ascending order using insertion sort. | def insertion_sort(list1):
for i in range(1, len(list1)):
key = list1[i]
j = i - 1
while j >= 0 and list1[j] > key:
list1[j + 1] = list1[j]
j -= 1
list1[j + 1] = key
return list1
print(insertion_sort([25, 71, 24, 96, -13, 94, 63, 36, -22, 72, -40, -15, 91... | Insertion sort on int data, variable named 'list1', 20 elements. |
521 | Python | Sorting Algorithm | intermediate | Sort a 20-element array of ints in ascending order using insertion sort. | def insertion_sort(data):
for i in range(1, len(data)):
key = data[i]
j = i - 1
while j >= 0 and data[j] > key:
data[j + 1] = data[j]
j -= 1
data[j + 1] = key
return data
print(insertion_sort([33, -36, -1, 99, 84, 6, 21, 0, -45, -29, 87, 64, -28, 81, 50, ... | Insertion sort on int data, variable named 'data', 20 elements. |
522 | Python | Sorting Algorithm | intermediate | Sort a 20-element array of ints in ascending order using insertion sort. | def insertion_sort(entries):
for i in range(1, len(entries)):
key = entries[i]
j = i - 1
while j >= 0 and entries[j] > key:
entries[j + 1] = entries[j]
j -= 1
entries[j + 1] = key
return entries
print(insertion_sort([42, 51, -13, 59, 44, 48, 45, -47, 22, ... | Insertion sort on int data, variable named 'entries', 20 elements. |
523 | Python | Sorting Algorithm | intermediate | Sort a 5-element array of floats in ascending order using insertion sort. | def insertion_sort(values):
for i in range(1, len(values)):
key = values[i]
j = i - 1
while j >= 0 and values[j] > key:
values[j + 1] = values[j]
j -= 1
values[j + 1] = key
return values
print(insertion_sort([75.88, 95.47, 30.44, 86.68, -3.39])) | Insertion sort on float data, variable named 'values', 5 elements. |
524 | Python | Sorting Algorithm | intermediate | Sort a 5-element array of floats in ascending order using insertion sort. | def insertion_sort(elements):
for i in range(1, len(elements)):
key = elements[i]
j = i - 1
while j >= 0 and elements[j] > key:
elements[j + 1] = elements[j]
j -= 1
elements[j + 1] = key
return elements
print(insertion_sort([51.15, -2.91, 16.08, 97.62, 42... | Insertion sort on float data, variable named 'elements', 5 elements. |
525 | Python | Sorting Algorithm | intermediate | Sort a 5-element array of floats in ascending order using insertion sort. | def insertion_sort(list1):
for i in range(1, len(list1)):
key = list1[i]
j = i - 1
while j >= 0 and list1[j] > key:
list1[j + 1] = list1[j]
j -= 1
list1[j + 1] = key
return list1
print(insertion_sort([-12.13, 94.25, 69.98, -9.47, 28.73])) | Insertion sort on float data, variable named 'list1', 5 elements. |
526 | Python | Sorting Algorithm | intermediate | Sort a 8-element array of floats in ascending order using insertion sort. | def insertion_sort(entries):
for i in range(1, len(entries)):
key = entries[i]
j = i - 1
while j >= 0 and entries[j] > key:
entries[j + 1] = entries[j]
j -= 1
entries[j + 1] = key
return entries
print(insertion_sort([12.53, 0.81, 34.99, 47.58, 88.87, 3.71... | Insertion sort on float data, variable named 'entries', 8 elements. |
527 | Python | Sorting Algorithm | intermediate | Sort a 8-element array of floats in ascending order using insertion sort. | def insertion_sort(dataset):
for i in range(1, len(dataset)):
key = dataset[i]
j = i - 1
while j >= 0 and dataset[j] > key:
dataset[j + 1] = dataset[j]
j -= 1
dataset[j + 1] = key
return dataset
print(insertion_sort([-14.97, 78.32, 79.32, 16.17, 46.55, 35... | Insertion sort on float data, variable named 'dataset', 8 elements. |
528 | Python | Sorting Algorithm | intermediate | Sort a 8-element array of floats in ascending order using insertion sort. | def insertion_sort(nums):
for i in range(1, len(nums)):
key = nums[i]
j = i - 1
while j >= 0 and nums[j] > key:
nums[j + 1] = nums[j]
j -= 1
nums[j + 1] = key
return nums
print(insertion_sort([15.72, 56.23, 55.75, -5.22, 59.24, 14.23, 1.35, 87.91])) | Insertion sort on float data, variable named 'nums', 8 elements. |
529 | Python | Sorting Algorithm | intermediate | Sort a 10-element array of floats in ascending order using insertion sort. | def insertion_sort(buffer):
for i in range(1, len(buffer)):
key = buffer[i]
j = i - 1
while j >= 0 and buffer[j] > key:
buffer[j + 1] = buffer[j]
j -= 1
buffer[j + 1] = key
return buffer
print(insertion_sort([9.13, -5.8, 12.99, 98.33, -12.06, 68.72, 49.15... | Insertion sort on float data, variable named 'buffer', 10 elements. |
530 | Python | Sorting Algorithm | intermediate | Sort a 10-element array of floats in ascending order using insertion sort. | def insertion_sort(dataset):
for i in range(1, len(dataset)):
key = dataset[i]
j = i - 1
while j >= 0 and dataset[j] > key:
dataset[j + 1] = dataset[j]
j -= 1
dataset[j + 1] = key
return dataset
print(insertion_sort([95.94, 77.38, 24.41, 67.22, -17.91, 10... | Insertion sort on float data, variable named 'dataset', 10 elements. |
531 | Python | Sorting Algorithm | intermediate | Sort a 10-element array of floats in ascending order using insertion sort. | def insertion_sort(list1):
for i in range(1, len(list1)):
key = list1[i]
j = i - 1
while j >= 0 and list1[j] > key:
list1[j + 1] = list1[j]
j -= 1
list1[j + 1] = key
return list1
print(insertion_sort([-0.57, 12.45, 29.92, 88.54, 22.36, 14.49, 43.02, 91.42... | Insertion sort on float data, variable named 'list1', 10 elements. |
532 | Python | Sorting Algorithm | intermediate | Sort a 12-element array of floats in ascending order using insertion sort. | def insertion_sort(values):
for i in range(1, len(values)):
key = values[i]
j = i - 1
while j >= 0 and values[j] > key:
values[j + 1] = values[j]
j -= 1
values[j + 1] = key
return values
print(insertion_sort([71.0, 51.25, -0.11, 18.39, 17.63, 80.55, 75.19... | Insertion sort on float data, variable named 'values', 12 elements. |
533 | Python | Sorting Algorithm | intermediate | Sort a 12-element array of floats in ascending order using insertion sort. | def insertion_sort(values):
for i in range(1, len(values)):
key = values[i]
j = i - 1
while j >= 0 and values[j] > key:
values[j + 1] = values[j]
j -= 1
values[j + 1] = key
return values
print(insertion_sort([-18.47, 41.66, 24.39, 37.7, 20.5, 88.38, -7.81... | Insertion sort on float data, variable named 'values', 12 elements. |
534 | Python | Sorting Algorithm | intermediate | Sort a 12-element array of floats in ascending order using insertion sort. | def insertion_sort(records):
for i in range(1, len(records)):
key = records[i]
j = i - 1
while j >= 0 and records[j] > key:
records[j + 1] = records[j]
j -= 1
records[j + 1] = key
return records
print(insertion_sort([93.35, 80.68, 64.79, 63.57, 75.51, 29.... | Insertion sort on float data, variable named 'records', 12 elements. |
535 | Python | Sorting Algorithm | intermediate | Sort a 15-element array of floats in ascending order using insertion sort. | def insertion_sort(values):
for i in range(1, len(values)):
key = values[i]
j = i - 1
while j >= 0 and values[j] > key:
values[j + 1] = values[j]
j -= 1
values[j + 1] = key
return values
print(insertion_sort([77.23, 85.88, 51.12, 70.87, 20.7, 64.48, -16.5... | Insertion sort on float data, variable named 'values', 15 elements. |
536 | Python | Sorting Algorithm | intermediate | Sort a 15-element array of floats in ascending order using insertion sort. | def insertion_sort(seq):
for i in range(1, len(seq)):
key = seq[i]
j = i - 1
while j >= 0 and seq[j] > key:
seq[j + 1] = seq[j]
j -= 1
seq[j + 1] = key
return seq
print(insertion_sort([70.8, -6.71, -17.76, 37.63, 31.32, 3.37, -16.1, 58.51, 50.59, 35.82, 8... | Insertion sort on float data, variable named 'seq', 15 elements. |
537 | Python | Sorting Algorithm | intermediate | Sort a 15-element array of floats in ascending order using insertion sort. | def insertion_sort(data):
for i in range(1, len(data)):
key = data[i]
j = i - 1
while j >= 0 and data[j] > key:
data[j + 1] = data[j]
j -= 1
data[j + 1] = key
return data
print(insertion_sort([89.49, 4.44, 87.24, 1.99, 21.83, -9.2, 80.66, 92.08, 92.91, 21... | Insertion sort on float data, variable named 'data', 15 elements. |
538 | Python | Sorting Algorithm | intermediate | Sort a 20-element array of floats in ascending order using insertion sort. | def insertion_sort(data):
for i in range(1, len(data)):
key = data[i]
j = i - 1
while j >= 0 and data[j] > key:
data[j + 1] = data[j]
j -= 1
data[j + 1] = key
return data
print(insertion_sort([77.53, 70.83, 42.93, 65.18, 94.75, 0.44, 69.73, -19.48, 66.32,... | Insertion sort on float data, variable named 'data', 20 elements. |
539 | Python | Sorting Algorithm | intermediate | Sort a 20-element array of floats in ascending order using insertion sort. | def insertion_sort(input_arr):
for i in range(1, len(input_arr)):
key = input_arr[i]
j = i - 1
while j >= 0 and input_arr[j] > key:
input_arr[j + 1] = input_arr[j]
j -= 1
input_arr[j + 1] = key
return input_arr
print(insertion_sort([7.08, -6.57, 97.17, -5... | Insertion sort on float data, variable named 'input_arr', 20 elements. |
540 | Python | Sorting Algorithm | intermediate | Sort a 20-element array of floats in ascending order using insertion sort. | def insertion_sort(items):
for i in range(1, len(items)):
key = items[i]
j = i - 1
while j >= 0 and items[j] > key:
items[j + 1] = items[j]
j -= 1
items[j + 1] = key
return items
print(insertion_sort([81.96, 86.48, 75.49, 91.75, 23.73, -18.48, 60.22, 59.9... | Insertion sort on float data, variable named 'items', 20 elements. |
541 | JavaScript | Sorting Algorithm | intermediate | Sort a 5-element array of ints in ascending order using insertion sort. | function insertionSort(items) {
for (let i = 1; i < items.length; i++) {
const key = items[i];
let j = i - 1;
while (j >= 0 && items[j] > key) {
items[j + 1] = items[j];
j--;
}
items[j + 1] = key;
}
return items;
}
console.log(insertionSort([53, -19, 9, 58, 77])); | Insertion sort on int data, variable named 'items', 5 elements. |
542 | JavaScript | Sorting Algorithm | intermediate | Sort a 5-element array of ints in ascending order using insertion sort. | function insertionSort(nums) {
for (let i = 1; i < nums.length; i++) {
const key = nums[i];
let j = i - 1;
while (j >= 0 && nums[j] > key) {
nums[j + 1] = nums[j];
j--;
}
nums[j + 1] = key;
}
return nums;
}
console.log(insertionSort([98, 19, 52, 41, 71])); | Insertion sort on int data, variable named 'nums', 5 elements. |
543 | JavaScript | Sorting Algorithm | intermediate | Sort a 5-element array of ints in ascending order using insertion sort. | function insertionSort(buffer) {
for (let i = 1; i < buffer.length; i++) {
const key = buffer[i];
let j = i - 1;
while (j >= 0 && buffer[j] > key) {
buffer[j + 1] = buffer[j];
j--;
}
buffer[j + 1] = key;
}
return buffer;
}
console.log(insertionSort([53, 74, 80, 21, -13])); | Insertion sort on int data, variable named 'buffer', 5 elements. |
544 | JavaScript | Sorting Algorithm | intermediate | Sort a 8-element array of ints in ascending order using insertion sort. | function insertionSort(vals) {
for (let i = 1; i < vals.length; i++) {
const key = vals[i];
let j = i - 1;
while (j >= 0 && vals[j] > key) {
vals[j + 1] = vals[j];
j--;
}
vals[j + 1] = key;
}
return vals;
}
console.log(insertionSort([66, -23, -19, 14, 75, 77, 9, -16])); | Insertion sort on int data, variable named 'vals', 8 elements. |
545 | JavaScript | Sorting Algorithm | intermediate | Sort a 8-element array of ints in ascending order using insertion sort. | function insertionSort(arr) {
for (let i = 1; i < arr.length; i++) {
const key = arr[i];
let j = i - 1;
while (j >= 0 && arr[j] > key) {
arr[j + 1] = arr[j];
j--;
}
arr[j + 1] = key;
}
return arr;
}
console.log(insertionSort([-25, -37, -33, 77, -44, -5, 47, 33])); | Insertion sort on int data, variable named 'arr', 8 elements. |
546 | JavaScript | Sorting Algorithm | intermediate | Sort a 8-element array of ints in ascending order using insertion sort. | function insertionSort(values) {
for (let i = 1; i < values.length; i++) {
const key = values[i];
let j = i - 1;
while (j >= 0 && values[j] > key) {
values[j + 1] = values[j];
j--;
}
values[j + 1] = key;
}
return values;
}
console.log(insertionSort([27, -26, -31, 83, 76, 69, 1, 25... | Insertion sort on int data, variable named 'values', 8 elements. |
547 | JavaScript | Sorting Algorithm | intermediate | Sort a 10-element array of ints in ascending order using insertion sort. | function insertionSort(buffer) {
for (let i = 1; i < buffer.length; i++) {
const key = buffer[i];
let j = i - 1;
while (j >= 0 && buffer[j] > key) {
buffer[j + 1] = buffer[j];
j--;
}
buffer[j + 1] = key;
}
return buffer;
}
console.log(insertionSort([77, 75, 79, 16, 88, 37, 88, 89,... | Insertion sort on int data, variable named 'buffer', 10 elements. |
548 | JavaScript | Sorting Algorithm | intermediate | Sort a 10-element array of ints in ascending order using insertion sort. | function insertionSort(collection) {
for (let i = 1; i < collection.length; i++) {
const key = collection[i];
let j = i - 1;
while (j >= 0 && collection[j] > key) {
collection[j + 1] = collection[j];
j--;
}
collection[j + 1] = key;
}
return collection;
}
console.log(insertionSort(... | Insertion sort on int data, variable named 'collection', 10 elements. |
549 | JavaScript | Sorting Algorithm | intermediate | Sort a 10-element array of ints in ascending order using insertion sort. | function insertionSort(input_arr) {
for (let i = 1; i < input_arr.length; i++) {
const key = input_arr[i];
let j = i - 1;
while (j >= 0 && input_arr[j] > key) {
input_arr[j + 1] = input_arr[j];
j--;
}
input_arr[j + 1] = key;
}
return input_arr;
}
console.log(insertionSort([27, -8,... | Insertion sort on int data, variable named 'input_arr', 10 elements. |
550 | JavaScript | Sorting Algorithm | intermediate | Sort a 12-element array of ints in ascending order using insertion sort. | function insertionSort(buffer) {
for (let i = 1; i < buffer.length; i++) {
const key = buffer[i];
let j = i - 1;
while (j >= 0 && buffer[j] > key) {
buffer[j + 1] = buffer[j];
j--;
}
buffer[j + 1] = key;
}
return buffer;
}
console.log(insertionSort([75, 91, 88, 96, 70, 71, 93, -10... | Insertion sort on int data, variable named 'buffer', 12 elements. |
551 | JavaScript | Sorting Algorithm | intermediate | Sort a 12-element array of ints in ascending order using insertion sort. | function insertionSort(dataset) {
for (let i = 1; i < dataset.length; i++) {
const key = dataset[i];
let j = i - 1;
while (j >= 0 && dataset[j] > key) {
dataset[j + 1] = dataset[j];
j--;
}
dataset[j + 1] = key;
}
return dataset;
}
console.log(insertionSort([46, 40, 22, 32, -35, -4... | Insertion sort on int data, variable named 'dataset', 12 elements. |
552 | JavaScript | Sorting Algorithm | intermediate | Sort a 12-element array of ints in ascending order using insertion sort. | function insertionSort(vals) {
for (let i = 1; i < vals.length; i++) {
const key = vals[i];
let j = i - 1;
while (j >= 0 && vals[j] > key) {
vals[j + 1] = vals[j];
j--;
}
vals[j + 1] = key;
}
return vals;
}
console.log(insertionSort([37, 47, -26, 59, 38, 41, 55, 39, -36, 12, 13, 1... | Insertion sort on int data, variable named 'vals', 12 elements. |
553 | JavaScript | Sorting Algorithm | intermediate | Sort a 15-element array of ints in ascending order using insertion sort. | function insertionSort(buffer) {
for (let i = 1; i < buffer.length; i++) {
const key = buffer[i];
let j = i - 1;
while (j >= 0 && buffer[j] > key) {
buffer[j + 1] = buffer[j];
j--;
}
buffer[j + 1] = key;
}
return buffer;
}
console.log(insertionSort([29, -29, -34, 28, -21, 36, -7, ... | Insertion sort on int data, variable named 'buffer', 15 elements. |
554 | JavaScript | Sorting Algorithm | intermediate | Sort a 15-element array of ints in ascending order using insertion sort. | function insertionSort(entries) {
for (let i = 1; i < entries.length; i++) {
const key = entries[i];
let j = i - 1;
while (j >= 0 && entries[j] > key) {
entries[j + 1] = entries[j];
j--;
}
entries[j + 1] = key;
}
return entries;
}
console.log(insertionSort([57, 18, -45, 70, -45, 3... | Insertion sort on int data, variable named 'entries', 15 elements. |
555 | JavaScript | Sorting Algorithm | intermediate | Sort a 15-element array of ints in ascending order using insertion sort. | function insertionSort(list1) {
for (let i = 1; i < list1.length; i++) {
const key = list1[i];
let j = i - 1;
while (j >= 0 && list1[j] > key) {
list1[j + 1] = list1[j];
j--;
}
list1[j + 1] = key;
}
return list1;
}
console.log(insertionSort([77, 78, 36, -8, 26, 43, 61, 1, 77, -31,... | Insertion sort on int data, variable named 'list1', 15 elements. |
556 | JavaScript | Sorting Algorithm | intermediate | Sort a 20-element array of ints in ascending order using insertion sort. | function insertionSort(nums) {
for (let i = 1; i < nums.length; i++) {
const key = nums[i];
let j = i - 1;
while (j >= 0 && nums[j] > key) {
nums[j + 1] = nums[j];
j--;
}
nums[j + 1] = key;
}
return nums;
}
console.log(insertionSort([96, 52, 7, -27, 98, -26, 36, 19, -33, 95, 85, 7... | Insertion sort on int data, variable named 'nums', 20 elements. |
557 | JavaScript | Sorting Algorithm | intermediate | Sort a 20-element array of ints in ascending order using insertion sort. | function insertionSort(buffer) {
for (let i = 1; i < buffer.length; i++) {
const key = buffer[i];
let j = i - 1;
while (j >= 0 && buffer[j] > key) {
buffer[j + 1] = buffer[j];
j--;
}
buffer[j + 1] = key;
}
return buffer;
}
console.log(insertionSort([88, 30, 1, 56, 52, 14, 81, 66, ... | Insertion sort on int data, variable named 'buffer', 20 elements. |
558 | JavaScript | Sorting Algorithm | intermediate | Sort a 20-element array of ints in ascending order using insertion sort. | function insertionSort(entries) {
for (let i = 1; i < entries.length; i++) {
const key = entries[i];
let j = i - 1;
while (j >= 0 && entries[j] > key) {
entries[j + 1] = entries[j];
j--;
}
entries[j + 1] = key;
}
return entries;
}
console.log(insertionSort([94, -35, 83, 1, 43, 68,... | Insertion sort on int data, variable named 'entries', 20 elements. |
559 | JavaScript | Sorting Algorithm | intermediate | Sort a 5-element array of floats in ascending order using insertion sort. | function insertionSort(buffer) {
for (let i = 1; i < buffer.length; i++) {
const key = buffer[i];
let j = i - 1;
while (j >= 0 && buffer[j] > key) {
buffer[j + 1] = buffer[j];
j--;
}
buffer[j + 1] = key;
}
return buffer;
}
console.log(insertionSort([51.55, 28.3, -6.49, 2.84, 9.22]... | Insertion sort on float data, variable named 'buffer', 5 elements. |
560 | JavaScript | Sorting Algorithm | intermediate | Sort a 5-element array of floats in ascending order using insertion sort. | function insertionSort(records) {
for (let i = 1; i < records.length; i++) {
const key = records[i];
let j = i - 1;
while (j >= 0 && records[j] > key) {
records[j + 1] = records[j];
j--;
}
records[j + 1] = key;
}
return records;
}
console.log(insertionSort([16.95, 37.76, 97.96, 30... | Insertion sort on float data, variable named 'records', 5 elements. |
561 | JavaScript | Sorting Algorithm | intermediate | Sort a 5-element array of floats in ascending order using insertion sort. | function insertionSort(items) {
for (let i = 1; i < items.length; i++) {
const key = items[i];
let j = i - 1;
while (j >= 0 && items[j] > key) {
items[j + 1] = items[j];
j--;
}
items[j + 1] = key;
}
return items;
}
console.log(insertionSort([-1.04, -3.76, 10.75, 75.62, 58.38])); | Insertion sort on float data, variable named 'items', 5 elements. |
562 | JavaScript | Sorting Algorithm | intermediate | Sort a 8-element array of floats in ascending order using insertion sort. | function insertionSort(values) {
for (let i = 1; i < values.length; i++) {
const key = values[i];
let j = i - 1;
while (j >= 0 && values[j] > key) {
values[j + 1] = values[j];
j--;
}
values[j + 1] = key;
}
return values;
}
console.log(insertionSort([56.67, -14.97, 65.97, 73.09, -1... | Insertion sort on float data, variable named 'values', 8 elements. |
563 | JavaScript | Sorting Algorithm | intermediate | Sort a 8-element array of floats in ascending order using insertion sort. | function insertionSort(data) {
for (let i = 1; i < data.length; i++) {
const key = data[i];
let j = i - 1;
while (j >= 0 && data[j] > key) {
data[j + 1] = data[j];
j--;
}
data[j + 1] = key;
}
return data;
}
console.log(insertionSort([87.17, 28.43, 23.25, 58.23, -9.25, 92.24, 66.18... | Insertion sort on float data, variable named 'data', 8 elements. |
564 | JavaScript | Sorting Algorithm | intermediate | Sort a 8-element array of floats in ascending order using insertion sort. | function insertionSort(data) {
for (let i = 1; i < data.length; i++) {
const key = data[i];
let j = i - 1;
while (j >= 0 && data[j] > key) {
data[j + 1] = data[j];
j--;
}
data[j + 1] = key;
}
return data;
}
console.log(insertionSort([47.95, 39.53, -5.64, 59.04, 49.07, 72.24, 42.51... | Insertion sort on float data, variable named 'data', 8 elements. |
565 | JavaScript | Sorting Algorithm | intermediate | Sort a 10-element array of floats in ascending order using insertion sort. | function insertionSort(data) {
for (let i = 1; i < data.length; i++) {
const key = data[i];
let j = i - 1;
while (j >= 0 && data[j] > key) {
data[j + 1] = data[j];
j--;
}
data[j + 1] = key;
}
return data;
}
console.log(insertionSort([8.33, -5.45, 76.0, 19.19, 49.53, 26.4, 69.06, 8... | Insertion sort on float data, variable named 'data', 10 elements. |
566 | JavaScript | Sorting Algorithm | intermediate | Sort a 10-element array of floats in ascending order using insertion sort. | function insertionSort(values) {
for (let i = 1; i < values.length; i++) {
const key = values[i];
let j = i - 1;
while (j >= 0 && values[j] > key) {
values[j + 1] = values[j];
j--;
}
values[j + 1] = key;
}
return values;
}
console.log(insertionSort([5.48, 12.67, 28.6, 82.69, -13.3... | Insertion sort on float data, variable named 'values', 10 elements. |
567 | JavaScript | Sorting Algorithm | intermediate | Sort a 10-element array of floats in ascending order using insertion sort. | function insertionSort(items) {
for (let i = 1; i < items.length; i++) {
const key = items[i];
let j = i - 1;
while (j >= 0 && items[j] > key) {
items[j + 1] = items[j];
j--;
}
items[j + 1] = key;
}
return items;
}
console.log(insertionSort([94.63, 84.65, 91.5, 23.2, 65.16, 77.74,... | Insertion sort on float data, variable named 'items', 10 elements. |
568 | JavaScript | Sorting Algorithm | intermediate | Sort a 12-element array of floats in ascending order using insertion sort. | function insertionSort(buffer) {
for (let i = 1; i < buffer.length; i++) {
const key = buffer[i];
let j = i - 1;
while (j >= 0 && buffer[j] > key) {
buffer[j + 1] = buffer[j];
j--;
}
buffer[j + 1] = key;
}
return buffer;
}
console.log(insertionSort([75.07, -13.49, 89.18, 59.92, 10... | Insertion sort on float data, variable named 'buffer', 12 elements. |
569 | JavaScript | Sorting Algorithm | intermediate | Sort a 12-element array of floats in ascending order using insertion sort. | function insertionSort(dataset) {
for (let i = 1; i < dataset.length; i++) {
const key = dataset[i];
let j = i - 1;
while (j >= 0 && dataset[j] > key) {
dataset[j + 1] = dataset[j];
j--;
}
dataset[j + 1] = key;
}
return dataset;
}
console.log(insertionSort([26.23, 88.26, 26.76, 96... | Insertion sort on float data, variable named 'dataset', 12 elements. |
570 | JavaScript | Sorting Algorithm | intermediate | Sort a 12-element array of floats in ascending order using insertion sort. | function insertionSort(entries) {
for (let i = 1; i < entries.length; i++) {
const key = entries[i];
let j = i - 1;
while (j >= 0 && entries[j] > key) {
entries[j + 1] = entries[j];
j--;
}
entries[j + 1] = key;
}
return entries;
}
console.log(insertionSort([76.66, 56.69, 73.93, 12... | Insertion sort on float data, variable named 'entries', 12 elements. |
571 | JavaScript | Sorting Algorithm | intermediate | Sort a 15-element array of floats in ascending order using insertion sort. | function insertionSort(data) {
for (let i = 1; i < data.length; i++) {
const key = data[i];
let j = i - 1;
while (j >= 0 && data[j] > key) {
data[j + 1] = data[j];
j--;
}
data[j + 1] = key;
}
return data;
}
console.log(insertionSort([78.1, 63.12, 40.25, 21.87, 51.65, 76.8, 67.8, 3... | Insertion sort on float data, variable named 'data', 15 elements. |
572 | JavaScript | Sorting Algorithm | intermediate | Sort a 15-element array of floats in ascending order using insertion sort. | function insertionSort(buffer) {
for (let i = 1; i < buffer.length; i++) {
const key = buffer[i];
let j = i - 1;
while (j >= 0 && buffer[j] > key) {
buffer[j + 1] = buffer[j];
j--;
}
buffer[j + 1] = key;
}
return buffer;
}
console.log(insertionSort([16.36, 48.52, -6.81, 9.7, 64.91... | Insertion sort on float data, variable named 'buffer', 15 elements. |
573 | JavaScript | Sorting Algorithm | intermediate | Sort a 15-element array of floats in ascending order using insertion sort. | function insertionSort(elements) {
for (let i = 1; i < elements.length; i++) {
const key = elements[i];
let j = i - 1;
while (j >= 0 && elements[j] > key) {
elements[j + 1] = elements[j];
j--;
}
elements[j + 1] = key;
}
return elements;
}
console.log(insertionSort([78.39, 75.14, 3... | Insertion sort on float data, variable named 'elements', 15 elements. |
574 | JavaScript | Sorting Algorithm | intermediate | Sort a 20-element array of floats in ascending order using insertion sort. | function insertionSort(items) {
for (let i = 1; i < items.length; i++) {
const key = items[i];
let j = i - 1;
while (j >= 0 && items[j] > key) {
items[j + 1] = items[j];
j--;
}
items[j + 1] = key;
}
return items;
}
console.log(insertionSort([11.15, 81.37, -14.08, 53.54, 51.45, -2.... | Insertion sort on float data, variable named 'items', 20 elements. |
575 | JavaScript | Sorting Algorithm | intermediate | Sort a 20-element array of floats in ascending order using insertion sort. | function insertionSort(seq) {
for (let i = 1; i < seq.length; i++) {
const key = seq[i];
let j = i - 1;
while (j >= 0 && seq[j] > key) {
seq[j + 1] = seq[j];
j--;
}
seq[j + 1] = key;
}
return seq;
}
console.log(insertionSort([38.81, -4.51, 81.9, 51.41, 98.43, 13.67, 60.59, 29.78, ... | Insertion sort on float data, variable named 'seq', 20 elements. |
576 | JavaScript | Sorting Algorithm | intermediate | Sort a 20-element array of floats in ascending order using insertion sort. | function insertionSort(seq) {
for (let i = 1; i < seq.length; i++) {
const key = seq[i];
let j = i - 1;
while (j >= 0 && seq[j] > key) {
seq[j + 1] = seq[j];
j--;
}
seq[j + 1] = key;
}
return seq;
}
console.log(insertionSort([27.31, 5.25, 25.64, 30.37, 51.07, -11.31, 46.28, -13.8,... | Insertion sort on float data, variable named 'seq', 20 elements. |
577 | Node.js | Sorting Algorithm | intermediate | Sort a 5-element array of ints in ascending order using insertion sort. | function insertionSort(buffer) {
for (let i = 1; i < buffer.length; i++) {
const key = buffer[i];
let j = i - 1;
while (j >= 0 && buffer[j] > key) {
buffer[j + 1] = buffer[j];
j--;
}
buffer[j + 1] = key;
}
return buffer;
}
module.exports = { insertionSort };
console.log(insertionS... | Insertion sort on int data, variable named 'buffer', 5 elements. |
578 | Node.js | Sorting Algorithm | intermediate | Sort a 5-element array of ints in ascending order using insertion sort. | function insertionSort(values) {
for (let i = 1; i < values.length; i++) {
const key = values[i];
let j = i - 1;
while (j >= 0 && values[j] > key) {
values[j + 1] = values[j];
j--;
}
values[j + 1] = key;
}
return values;
}
module.exports = { insertionSort };
console.log(insertionS... | Insertion sort on int data, variable named 'values', 5 elements. |
579 | Node.js | Sorting Algorithm | intermediate | Sort a 5-element array of ints in ascending order using insertion sort. | function insertionSort(entries) {
for (let i = 1; i < entries.length; i++) {
const key = entries[i];
let j = i - 1;
while (j >= 0 && entries[j] > key) {
entries[j + 1] = entries[j];
j--;
}
entries[j + 1] = key;
}
return entries;
}
module.exports = { insertionSort };
console.log(in... | Insertion sort on int data, variable named 'entries', 5 elements. |
580 | Node.js | Sorting Algorithm | intermediate | Sort a 8-element array of ints in ascending order using insertion sort. | function insertionSort(collection) {
for (let i = 1; i < collection.length; i++) {
const key = collection[i];
let j = i - 1;
while (j >= 0 && collection[j] > key) {
collection[j + 1] = collection[j];
j--;
}
collection[j + 1] = key;
}
return collection;
}
module.exports = { inserti... | Insertion sort on int data, variable named 'collection', 8 elements. |
581 | Node.js | Sorting Algorithm | intermediate | Sort a 8-element array of ints in ascending order using insertion sort. | function insertionSort(seq) {
for (let i = 1; i < seq.length; i++) {
const key = seq[i];
let j = i - 1;
while (j >= 0 && seq[j] > key) {
seq[j + 1] = seq[j];
j--;
}
seq[j + 1] = key;
}
return seq;
}
module.exports = { insertionSort };
console.log(insertionSort([42, 60, 22, 17, 17,... | Insertion sort on int data, variable named 'seq', 8 elements. |
582 | Node.js | Sorting Algorithm | intermediate | Sort a 8-element array of ints in ascending order using insertion sort. | function insertionSort(entries) {
for (let i = 1; i < entries.length; i++) {
const key = entries[i];
let j = i - 1;
while (j >= 0 && entries[j] > key) {
entries[j + 1] = entries[j];
j--;
}
entries[j + 1] = key;
}
return entries;
}
module.exports = { insertionSort };
console.log(in... | Insertion sort on int data, variable named 'entries', 8 elements. |
583 | Node.js | Sorting Algorithm | intermediate | Sort a 10-element array of ints in ascending order using insertion sort. | function insertionSort(values) {
for (let i = 1; i < values.length; i++) {
const key = values[i];
let j = i - 1;
while (j >= 0 && values[j] > key) {
values[j + 1] = values[j];
j--;
}
values[j + 1] = key;
}
return values;
}
module.exports = { insertionSort };
console.log(insertionS... | Insertion sort on int data, variable named 'values', 10 elements. |
584 | Node.js | Sorting Algorithm | intermediate | Sort a 10-element array of ints in ascending order using insertion sort. | function insertionSort(entries) {
for (let i = 1; i < entries.length; i++) {
const key = entries[i];
let j = i - 1;
while (j >= 0 && entries[j] > key) {
entries[j + 1] = entries[j];
j--;
}
entries[j + 1] = key;
}
return entries;
}
module.exports = { insertionSort };
console.log(in... | Insertion sort on int data, variable named 'entries', 10 elements. |
585 | Node.js | Sorting Algorithm | intermediate | Sort a 10-element array of ints in ascending order using insertion sort. | function insertionSort(data) {
for (let i = 1; i < data.length; i++) {
const key = data[i];
let j = i - 1;
while (j >= 0 && data[j] > key) {
data[j + 1] = data[j];
j--;
}
data[j + 1] = key;
}
return data;
}
module.exports = { insertionSort };
console.log(insertionSort([39, -27, 2,... | Insertion sort on int data, variable named 'data', 10 elements. |
586 | Node.js | Sorting Algorithm | intermediate | Sort a 12-element array of ints in ascending order using insertion sort. | function insertionSort(items) {
for (let i = 1; i < items.length; i++) {
const key = items[i];
let j = i - 1;
while (j >= 0 && items[j] > key) {
items[j + 1] = items[j];
j--;
}
items[j + 1] = key;
}
return items;
}
module.exports = { insertionSort };
console.log(insertionSort([99,... | Insertion sort on int data, variable named 'items', 12 elements. |
587 | Node.js | Sorting Algorithm | intermediate | Sort a 12-element array of ints in ascending order using insertion sort. | function insertionSort(nums) {
for (let i = 1; i < nums.length; i++) {
const key = nums[i];
let j = i - 1;
while (j >= 0 && nums[j] > key) {
nums[j + 1] = nums[j];
j--;
}
nums[j + 1] = key;
}
return nums;
}
module.exports = { insertionSort };
console.log(insertionSort([-19, 50, 45... | Insertion sort on int data, variable named 'nums', 12 elements. |
588 | Node.js | Sorting Algorithm | intermediate | Sort a 12-element array of ints in ascending order using insertion sort. | function insertionSort(elements) {
for (let i = 1; i < elements.length; i++) {
const key = elements[i];
let j = i - 1;
while (j >= 0 && elements[j] > key) {
elements[j + 1] = elements[j];
j--;
}
elements[j + 1] = key;
}
return elements;
}
module.exports = { insertionSort };
consol... | Insertion sort on int data, variable named 'elements', 12 elements. |
589 | Node.js | Sorting Algorithm | intermediate | Sort a 15-element array of ints in ascending order using insertion sort. | function insertionSort(seq) {
for (let i = 1; i < seq.length; i++) {
const key = seq[i];
let j = i - 1;
while (j >= 0 && seq[j] > key) {
seq[j + 1] = seq[j];
j--;
}
seq[j + 1] = key;
}
return seq;
}
module.exports = { insertionSort };
console.log(insertionSort([-32, 90, 47, -27, 5... | Insertion sort on int data, variable named 'seq', 15 elements. |
590 | Node.js | Sorting Algorithm | intermediate | Sort a 15-element array of ints in ascending order using insertion sort. | function insertionSort(nums) {
for (let i = 1; i < nums.length; i++) {
const key = nums[i];
let j = i - 1;
while (j >= 0 && nums[j] > key) {
nums[j + 1] = nums[j];
j--;
}
nums[j + 1] = key;
}
return nums;
}
module.exports = { insertionSort };
console.log(insertionSort([-11, -20, 2... | Insertion sort on int data, variable named 'nums', 15 elements. |
591 | Node.js | Sorting Algorithm | intermediate | Sort a 15-element array of ints in ascending order using insertion sort. | function insertionSort(dataset) {
for (let i = 1; i < dataset.length; i++) {
const key = dataset[i];
let j = i - 1;
while (j >= 0 && dataset[j] > key) {
dataset[j + 1] = dataset[j];
j--;
}
dataset[j + 1] = key;
}
return dataset;
}
module.exports = { insertionSort };
console.log(in... | Insertion sort on int data, variable named 'dataset', 15 elements. |
592 | Node.js | Sorting Algorithm | intermediate | Sort a 20-element array of ints in ascending order using insertion sort. | function insertionSort(buffer) {
for (let i = 1; i < buffer.length; i++) {
const key = buffer[i];
let j = i - 1;
while (j >= 0 && buffer[j] > key) {
buffer[j + 1] = buffer[j];
j--;
}
buffer[j + 1] = key;
}
return buffer;
}
module.exports = { insertionSort };
console.log(insertionS... | Insertion sort on int data, variable named 'buffer', 20 elements. |
593 | Node.js | Sorting Algorithm | intermediate | Sort a 20-element array of ints in ascending order using insertion sort. | function insertionSort(input_arr) {
for (let i = 1; i < input_arr.length; i++) {
const key = input_arr[i];
let j = i - 1;
while (j >= 0 && input_arr[j] > key) {
input_arr[j + 1] = input_arr[j];
j--;
}
input_arr[j + 1] = key;
}
return input_arr;
}
module.exports = { insertionSort }... | Insertion sort on int data, variable named 'input_arr', 20 elements. |
594 | Node.js | Sorting Algorithm | intermediate | Sort a 20-element array of ints in ascending order using insertion sort. | function insertionSort(vals) {
for (let i = 1; i < vals.length; i++) {
const key = vals[i];
let j = i - 1;
while (j >= 0 && vals[j] > key) {
vals[j + 1] = vals[j];
j--;
}
vals[j + 1] = key;
}
return vals;
}
module.exports = { insertionSort };
console.log(insertionSort([-4, 50, -39... | Insertion sort on int data, variable named 'vals', 20 elements. |
595 | Node.js | Sorting Algorithm | intermediate | Sort a 5-element array of floats in ascending order using insertion sort. | function insertionSort(arr) {
for (let i = 1; i < arr.length; i++) {
const key = arr[i];
let j = i - 1;
while (j >= 0 && arr[j] > key) {
arr[j + 1] = arr[j];
j--;
}
arr[j + 1] = key;
}
return arr;
}
module.exports = { insertionSort };
console.log(insertionSort([27.0, -18.42, 58.04... | Insertion sort on float data, variable named 'arr', 5 elements. |
596 | Node.js | Sorting Algorithm | intermediate | Sort a 5-element array of floats in ascending order using insertion sort. | function insertionSort(buffer) {
for (let i = 1; i < buffer.length; i++) {
const key = buffer[i];
let j = i - 1;
while (j >= 0 && buffer[j] > key) {
buffer[j + 1] = buffer[j];
j--;
}
buffer[j + 1] = key;
}
return buffer;
}
module.exports = { insertionSort };
console.log(insertionS... | Insertion sort on float data, variable named 'buffer', 5 elements. |
597 | Node.js | Sorting Algorithm | intermediate | Sort a 5-element array of floats in ascending order using insertion sort. | function insertionSort(list1) {
for (let i = 1; i < list1.length; i++) {
const key = list1[i];
let j = i - 1;
while (j >= 0 && list1[j] > key) {
list1[j + 1] = list1[j];
j--;
}
list1[j + 1] = key;
}
return list1;
}
module.exports = { insertionSort };
console.log(insertionSort([62.... | Insertion sort on float data, variable named 'list1', 5 elements. |
598 | Node.js | Sorting Algorithm | intermediate | Sort a 8-element array of floats in ascending order using insertion sort. | function insertionSort(values) {
for (let i = 1; i < values.length; i++) {
const key = values[i];
let j = i - 1;
while (j >= 0 && values[j] > key) {
values[j + 1] = values[j];
j--;
}
values[j + 1] = key;
}
return values;
}
module.exports = { insertionSort };
console.log(insertionS... | Insertion sort on float data, variable named 'values', 8 elements. |
599 | Node.js | Sorting Algorithm | intermediate | Sort a 8-element array of floats in ascending order using insertion sort. | function insertionSort(collection) {
for (let i = 1; i < collection.length; i++) {
const key = collection[i];
let j = i - 1;
while (j >= 0 && collection[j] > key) {
collection[j + 1] = collection[j];
j--;
}
collection[j + 1] = key;
}
return collection;
}
module.exports = { inserti... | Insertion sort on float data, variable named 'collection', 8 elements. |
600 | Node.js | Sorting Algorithm | intermediate | Sort a 8-element array of floats in ascending order using insertion sort. | function insertionSort(entries) {
for (let i = 1; i < entries.length; i++) {
const key = entries[i];
let j = i - 1;
while (j >= 0 && entries[j] > key) {
entries[j + 1] = entries[j];
j--;
}
entries[j + 1] = key;
}
return entries;
}
module.exports = { insertionSort };
console.log(in... | Insertion sort on float data, variable named 'entries', 8 elements. |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.