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 |
|---|---|---|---|---|---|---|
201 | C++ | Sorting Algorithm | intermediate | Sort a 5-element array of floats in ascending order using bubble sort. | #include <iostream>
#include <vector>
void bubbleSort(std::vector<double>& elements) {
int n = (int) elements.size();
for (int i = 0; i < n; i++) {
for (int j = 0; j < n - i - 1; j++) {
if (elements[j] > elements[j + 1]) std::swap(elements[j], elements[j + 1]);
}
}
}
int main()... | Bubble sort on float data, variable named 'elements', 5 elements. |
202 | C++ | Sorting Algorithm | intermediate | Sort a 8-element array of floats in ascending order using bubble sort. | #include <iostream>
#include <vector>
void bubbleSort(std::vector<double>& buffer) {
int n = (int) buffer.size();
for (int i = 0; i < n; i++) {
for (int j = 0; j < n - i - 1; j++) {
if (buffer[j] > buffer[j + 1]) std::swap(buffer[j], buffer[j + 1]);
}
}
}
int main() {
std::... | Bubble sort on float data, variable named 'buffer', 8 elements. |
203 | C++ | Sorting Algorithm | intermediate | Sort a 8-element array of floats in ascending order using bubble sort. | #include <iostream>
#include <vector>
void bubbleSort(std::vector<double>& nums) {
int n = (int) nums.size();
for (int i = 0; i < n; i++) {
for (int j = 0; j < n - i - 1; j++) {
if (nums[j] > nums[j + 1]) std::swap(nums[j], nums[j + 1]);
}
}
}
int main() {
std::vector<doubl... | Bubble sort on float data, variable named 'nums', 8 elements. |
204 | C++ | Sorting Algorithm | intermediate | Sort a 8-element array of floats in ascending order using bubble sort. | #include <iostream>
#include <vector>
void bubbleSort(std::vector<double>& entries) {
int n = (int) entries.size();
for (int i = 0; i < n; i++) {
for (int j = 0; j < n - i - 1; j++) {
if (entries[j] > entries[j + 1]) std::swap(entries[j], entries[j + 1]);
}
}
}
int main() {
... | Bubble sort on float data, variable named 'entries', 8 elements. |
205 | C++ | Sorting Algorithm | intermediate | Sort a 10-element array of floats in ascending order using bubble sort. | #include <iostream>
#include <vector>
void bubbleSort(std::vector<double>& dataset) {
int n = (int) dataset.size();
for (int i = 0; i < n; i++) {
for (int j = 0; j < n - i - 1; j++) {
if (dataset[j] > dataset[j + 1]) std::swap(dataset[j], dataset[j + 1]);
}
}
}
int main() {
... | Bubble sort on float data, variable named 'dataset', 10 elements. |
206 | C++ | Sorting Algorithm | intermediate | Sort a 10-element array of floats in ascending order using bubble sort. | #include <iostream>
#include <vector>
void bubbleSort(std::vector<double>& collection) {
int n = (int) collection.size();
for (int i = 0; i < n; i++) {
for (int j = 0; j < n - i - 1; j++) {
if (collection[j] > collection[j + 1]) std::swap(collection[j], collection[j + 1]);
}
}
}... | Bubble sort on float data, variable named 'collection', 10 elements. |
207 | C++ | Sorting Algorithm | intermediate | Sort a 10-element array of floats in ascending order using bubble sort. | #include <iostream>
#include <vector>
void bubbleSort(std::vector<double>& list1) {
int n = (int) list1.size();
for (int i = 0; i < n; i++) {
for (int j = 0; j < n - i - 1; j++) {
if (list1[j] > list1[j + 1]) std::swap(list1[j], list1[j + 1]);
}
}
}
int main() {
std::vector... | Bubble sort on float data, variable named 'list1', 10 elements. |
208 | C++ | Sorting Algorithm | intermediate | Sort a 12-element array of floats in ascending order using bubble sort. | #include <iostream>
#include <vector>
void bubbleSort(std::vector<double>& buffer) {
int n = (int) buffer.size();
for (int i = 0; i < n; i++) {
for (int j = 0; j < n - i - 1; j++) {
if (buffer[j] > buffer[j + 1]) std::swap(buffer[j], buffer[j + 1]);
}
}
}
int main() {
std::... | Bubble sort on float data, variable named 'buffer', 12 elements. |
209 | C++ | Sorting Algorithm | intermediate | Sort a 12-element array of floats in ascending order using bubble sort. | #include <iostream>
#include <vector>
void bubbleSort(std::vector<double>& collection) {
int n = (int) collection.size();
for (int i = 0; i < n; i++) {
for (int j = 0; j < n - i - 1; j++) {
if (collection[j] > collection[j + 1]) std::swap(collection[j], collection[j + 1]);
}
}
}... | Bubble sort on float data, variable named 'collection', 12 elements. |
210 | C++ | Sorting Algorithm | intermediate | Sort a 12-element array of floats in ascending order using bubble sort. | #include <iostream>
#include <vector>
void bubbleSort(std::vector<double>& list1) {
int n = (int) list1.size();
for (int i = 0; i < n; i++) {
for (int j = 0; j < n - i - 1; j++) {
if (list1[j] > list1[j + 1]) std::swap(list1[j], list1[j + 1]);
}
}
}
int main() {
std::vector... | Bubble sort on float data, variable named 'list1', 12 elements. |
211 | C++ | Sorting Algorithm | intermediate | Sort a 15-element array of floats in ascending order using bubble sort. | #include <iostream>
#include <vector>
void bubbleSort(std::vector<double>& buffer) {
int n = (int) buffer.size();
for (int i = 0; i < n; i++) {
for (int j = 0; j < n - i - 1; j++) {
if (buffer[j] > buffer[j + 1]) std::swap(buffer[j], buffer[j + 1]);
}
}
}
int main() {
std::... | Bubble sort on float data, variable named 'buffer', 15 elements. |
212 | C++ | Sorting Algorithm | intermediate | Sort a 15-element array of floats in ascending order using bubble sort. | #include <iostream>
#include <vector>
void bubbleSort(std::vector<double>& dataset) {
int n = (int) dataset.size();
for (int i = 0; i < n; i++) {
for (int j = 0; j < n - i - 1; j++) {
if (dataset[j] > dataset[j + 1]) std::swap(dataset[j], dataset[j + 1]);
}
}
}
int main() {
... | Bubble sort on float data, variable named 'dataset', 15 elements. |
213 | C++ | Sorting Algorithm | intermediate | Sort a 15-element array of floats in ascending order using bubble sort. | #include <iostream>
#include <vector>
void bubbleSort(std::vector<double>& buffer) {
int n = (int) buffer.size();
for (int i = 0; i < n; i++) {
for (int j = 0; j < n - i - 1; j++) {
if (buffer[j] > buffer[j + 1]) std::swap(buffer[j], buffer[j + 1]);
}
}
}
int main() {
std::... | Bubble sort on float data, variable named 'buffer', 15 elements. |
214 | C++ | Sorting Algorithm | intermediate | Sort a 20-element array of floats in ascending order using bubble sort. | #include <iostream>
#include <vector>
void bubbleSort(std::vector<double>& list1) {
int n = (int) list1.size();
for (int i = 0; i < n; i++) {
for (int j = 0; j < n - i - 1; j++) {
if (list1[j] > list1[j + 1]) std::swap(list1[j], list1[j + 1]);
}
}
}
int main() {
std::vector... | Bubble sort on float data, variable named 'list1', 20 elements. |
215 | C++ | Sorting Algorithm | intermediate | Sort a 20-element array of floats in ascending order using bubble sort. | #include <iostream>
#include <vector>
void bubbleSort(std::vector<double>& input_arr) {
int n = (int) input_arr.size();
for (int i = 0; i < n; i++) {
for (int j = 0; j < n - i - 1; j++) {
if (input_arr[j] > input_arr[j + 1]) std::swap(input_arr[j], input_arr[j + 1]);
}
}
}
int ... | Bubble sort on float data, variable named 'input_arr', 20 elements. |
216 | C++ | Sorting Algorithm | intermediate | Sort a 20-element array of floats in ascending order using bubble sort. | #include <iostream>
#include <vector>
void bubbleSort(std::vector<double>& records) {
int n = (int) records.size();
for (int i = 0; i < n; i++) {
for (int j = 0; j < n - i - 1; j++) {
if (records[j] > records[j + 1]) std::swap(records[j], records[j + 1]);
}
}
}
int main() {
... | Bubble sort on float data, variable named 'records', 20 elements. |
217 | Rust | Sorting Algorithm | intermediate | Sort a 5-element array of ints in ascending order using bubble sort. | fn bubble_sort(seq: &mut Vec<i32>) {
let n = seq.len();
for i in 0..n {
for j in 0..n - i - 1 {
if seq[j] > seq[j + 1] {
seq.swap(j, j + 1);
}
}
}
}
fn main() {
let mut seq = vec![39, 59, -8, -15, 2];
bubble_sort(&mut seq);
println!("{:?}"... | Bubble sort on int data, variable named 'seq', 5 elements. |
218 | Rust | Sorting Algorithm | intermediate | Sort a 5-element array of ints in ascending order using bubble sort. | fn bubble_sort(records: &mut Vec<i32>) {
let n = records.len();
for i in 0..n {
for j in 0..n - i - 1 {
if records[j] > records[j + 1] {
records.swap(j, j + 1);
}
}
}
}
fn main() {
let mut records = vec![2, -35, 95, 39, 86];
bubble_sort(&mut r... | Bubble sort on int data, variable named 'records', 5 elements. |
219 | Rust | Sorting Algorithm | intermediate | Sort a 5-element array of ints in ascending order using bubble sort. | fn bubble_sort(nums: &mut Vec<i32>) {
let n = nums.len();
for i in 0..n {
for j in 0..n - i - 1 {
if nums[j] > nums[j + 1] {
nums.swap(j, j + 1);
}
}
}
}
fn main() {
let mut nums = vec![87, -7, 32, 24, 24];
bubble_sort(&mut nums);
println!... | Bubble sort on int data, variable named 'nums', 5 elements. |
220 | Rust | Sorting Algorithm | intermediate | Sort a 8-element array of ints in ascending order using bubble sort. | fn bubble_sort(elements: &mut Vec<i32>) {
let n = elements.len();
for i in 0..n {
for j in 0..n - i - 1 {
if elements[j] > elements[j + 1] {
elements.swap(j, j + 1);
}
}
}
}
fn main() {
let mut elements = vec![18, 81, -26, -16, 55, -35, 20, -18];
... | Bubble sort on int data, variable named 'elements', 8 elements. |
221 | Rust | Sorting Algorithm | intermediate | Sort a 8-element array of ints in ascending order using bubble sort. | fn bubble_sort(seq: &mut Vec<i32>) {
let n = seq.len();
for i in 0..n {
for j in 0..n - i - 1 {
if seq[j] > seq[j + 1] {
seq.swap(j, j + 1);
}
}
}
}
fn main() {
let mut seq = vec![-17, 13, -13, 32, 13, 50, 75, -14];
bubble_sort(&mut seq);
... | Bubble sort on int data, variable named 'seq', 8 elements. |
222 | Rust | Sorting Algorithm | intermediate | Sort a 8-element array of ints in ascending order using bubble sort. | fn bubble_sort(elements: &mut Vec<i32>) {
let n = elements.len();
for i in 0..n {
for j in 0..n - i - 1 {
if elements[j] > elements[j + 1] {
elements.swap(j, j + 1);
}
}
}
}
fn main() {
let mut elements = vec![18, 56, 46, 65, -31, -27, 53, 81];
... | Bubble sort on int data, variable named 'elements', 8 elements. |
223 | Rust | Sorting Algorithm | intermediate | Sort a 10-element array of ints in ascending order using bubble sort. | fn bubble_sort(seq: &mut Vec<i32>) {
let n = seq.len();
for i in 0..n {
for j in 0..n - i - 1 {
if seq[j] > seq[j + 1] {
seq.swap(j, j + 1);
}
}
}
}
fn main() {
let mut seq = vec![21, 44, 66, 74, 33, 98, -50, -27, 67, 41];
bubble_sort(&mut seq... | Bubble sort on int data, variable named 'seq', 10 elements. |
224 | Rust | Sorting Algorithm | intermediate | Sort a 10-element array of ints in ascending order using bubble sort. | fn bubble_sort(records: &mut Vec<i32>) {
let n = records.len();
for i in 0..n {
for j in 0..n - i - 1 {
if records[j] > records[j + 1] {
records.swap(j, j + 1);
}
}
}
}
fn main() {
let mut records = vec![-34, 86, 51, 5, 59, 4, 76, 18, 32, 22];
... | Bubble sort on int data, variable named 'records', 10 elements. |
225 | Rust | Sorting Algorithm | intermediate | Sort a 10-element array of ints in ascending order using bubble sort. | fn bubble_sort(list1: &mut Vec<i32>) {
let n = list1.len();
for i in 0..n {
for j in 0..n - i - 1 {
if list1[j] > list1[j + 1] {
list1.swap(j, j + 1);
}
}
}
}
fn main() {
let mut list1 = vec![90, 97, -17, 94, 74, 37, -38, -39, -25, 67];
bubble... | Bubble sort on int data, variable named 'list1', 10 elements. |
226 | Rust | Sorting Algorithm | intermediate | Sort a 12-element array of ints in ascending order using bubble sort. | fn bubble_sort(arr: &mut Vec<i32>) {
let n = arr.len();
for i in 0..n {
for j in 0..n - i - 1 {
if arr[j] > arr[j + 1] {
arr.swap(j, j + 1);
}
}
}
}
fn main() {
let mut arr = vec![-19, -10, 62, 66, -50, 59, 1, -17, 27, -10, 20, -27];
bubble_so... | Bubble sort on int data, variable named 'arr', 12 elements. |
227 | Rust | Sorting Algorithm | intermediate | Sort a 12-element array of ints in ascending order using bubble sort. | fn bubble_sort(buffer: &mut Vec<i32>) {
let n = buffer.len();
for i in 0..n {
for j in 0..n - i - 1 {
if buffer[j] > buffer[j + 1] {
buffer.swap(j, j + 1);
}
}
}
}
fn main() {
let mut buffer = vec![42, 14, -29, 45, -8, -37, 51, 28, 9, 59, -27, -26... | Bubble sort on int data, variable named 'buffer', 12 elements. |
228 | Rust | Sorting Algorithm | intermediate | Sort a 12-element array of ints in ascending order using bubble sort. | fn bubble_sort(arr: &mut Vec<i32>) {
let n = arr.len();
for i in 0..n {
for j in 0..n - i - 1 {
if arr[j] > arr[j + 1] {
arr.swap(j, j + 1);
}
}
}
}
fn main() {
let mut arr = vec![4, 72, -31, -17, 7, 82, 63, -48, -48, 37, -20, 58];
bubble_sort... | Bubble sort on int data, variable named 'arr', 12 elements. |
229 | Rust | Sorting Algorithm | intermediate | Sort a 15-element array of ints in ascending order using bubble sort. | fn bubble_sort(seq: &mut Vec<i32>) {
let n = seq.len();
for i in 0..n {
for j in 0..n - i - 1 {
if seq[j] > seq[j + 1] {
seq.swap(j, j + 1);
}
}
}
}
fn main() {
let mut seq = vec![-17, 72, -32, 8, 48, -28, -24, -24, 30, 44, 26, -15, 47, -16, -14];... | Bubble sort on int data, variable named 'seq', 15 elements. |
230 | Rust | Sorting Algorithm | intermediate | Sort a 15-element array of ints in ascending order using bubble sort. | fn bubble_sort(data: &mut Vec<i32>) {
let n = data.len();
for i in 0..n {
for j in 0..n - i - 1 {
if data[j] > data[j + 1] {
data.swap(j, j + 1);
}
}
}
}
fn main() {
let mut data = vec![85, 94, -48, -8, 62, 39, 4, -12, 55, 63, 5, -28, -25, -15, -1... | Bubble sort on int data, variable named 'data', 15 elements. |
231 | Rust | Sorting Algorithm | intermediate | Sort a 15-element array of ints in ascending order using bubble sort. | fn bubble_sort(elements: &mut Vec<i32>) {
let n = elements.len();
for i in 0..n {
for j in 0..n - i - 1 {
if elements[j] > elements[j + 1] {
elements.swap(j, j + 1);
}
}
}
}
fn main() {
let mut elements = vec![48, 39, 59, 30, -15, 13, 20, -29, 13,... | Bubble sort on int data, variable named 'elements', 15 elements. |
232 | Rust | Sorting Algorithm | intermediate | Sort a 20-element array of ints in ascending order using bubble sort. | fn bubble_sort(elements: &mut Vec<i32>) {
let n = elements.len();
for i in 0..n {
for j in 0..n - i - 1 {
if elements[j] > elements[j + 1] {
elements.swap(j, j + 1);
}
}
}
}
fn main() {
let mut elements = vec![80, -2, 50, 25, -37, 11, 76, 48, -22,... | Bubble sort on int data, variable named 'elements', 20 elements. |
233 | Rust | Sorting Algorithm | intermediate | Sort a 20-element array of ints in ascending order using bubble sort. | fn bubble_sort(list1: &mut Vec<i32>) {
let n = list1.len();
for i in 0..n {
for j in 0..n - i - 1 {
if list1[j] > list1[j + 1] {
list1.swap(j, j + 1);
}
}
}
}
fn main() {
let mut list1 = vec![89, -6, 70, -32, -46, -33, -47, 17, 5, -40, -35, 51, 79... | Bubble sort on int data, variable named 'list1', 20 elements. |
234 | Rust | Sorting Algorithm | intermediate | Sort a 20-element array of ints in ascending order using bubble sort. | fn bubble_sort(input_arr: &mut Vec<i32>) {
let n = input_arr.len();
for i in 0..n {
for j in 0..n - i - 1 {
if input_arr[j] > input_arr[j + 1] {
input_arr.swap(j, j + 1);
}
}
}
}
fn main() {
let mut input_arr = vec![-11, 21, -29, 29, -30, 80, 2, -... | Bubble sort on int data, variable named 'input_arr', 20 elements. |
235 | Rust | Sorting Algorithm | intermediate | Sort a 5-element array of floats in ascending order using bubble sort. | fn bubble_sort(dataset: &mut Vec<f64>) {
let n = dataset.len();
for i in 0..n {
for j in 0..n - i - 1 {
if dataset[j] > dataset[j + 1] {
dataset.swap(j, j + 1);
}
}
}
}
fn main() {
let mut dataset = vec![52.86, -13.45, 59.26, 58.31, 0.9];
bubb... | Bubble sort on float data, variable named 'dataset', 5 elements. |
236 | Rust | Sorting Algorithm | intermediate | Sort a 5-element array of floats in ascending order using bubble sort. | fn bubble_sort(arr: &mut Vec<f64>) {
let n = arr.len();
for i in 0..n {
for j in 0..n - i - 1 {
if arr[j] > arr[j + 1] {
arr.swap(j, j + 1);
}
}
}
}
fn main() {
let mut arr = vec![64.24, 63.48, -0.5, 93.41, 42.24];
bubble_sort(&mut arr);
p... | Bubble sort on float data, variable named 'arr', 5 elements. |
237 | Rust | Sorting Algorithm | intermediate | Sort a 5-element array of floats in ascending order using bubble sort. | fn bubble_sort(vals: &mut Vec<f64>) {
let n = vals.len();
for i in 0..n {
for j in 0..n - i - 1 {
if vals[j] > vals[j + 1] {
vals.swap(j, j + 1);
}
}
}
}
fn main() {
let mut vals = vec![77.88, 10.85, 24.25, 69.22, 83.94];
bubble_sort(&mut vals... | Bubble sort on float data, variable named 'vals', 5 elements. |
238 | Rust | Sorting Algorithm | intermediate | Sort a 8-element array of floats in ascending order using bubble sort. | fn bubble_sort(seq: &mut Vec<f64>) {
let n = seq.len();
for i in 0..n {
for j in 0..n - i - 1 {
if seq[j] > seq[j + 1] {
seq.swap(j, j + 1);
}
}
}
}
fn main() {
let mut seq = vec![85.48, 71.8, -16.51, 76.05, 12.37, -12.4, 64.77, 48.62];
bubble... | Bubble sort on float data, variable named 'seq', 8 elements. |
239 | Rust | Sorting Algorithm | intermediate | Sort a 8-element array of floats in ascending order using bubble sort. | fn bubble_sort(data: &mut Vec<f64>) {
let n = data.len();
for i in 0..n {
for j in 0..n - i - 1 {
if data[j] > data[j + 1] {
data.swap(j, j + 1);
}
}
}
}
fn main() {
let mut data = vec![39.04, 40.78, -13.4, 82.26, -0.14, -1.28, 72.03, 86.42];
... | Bubble sort on float data, variable named 'data', 8 elements. |
240 | Rust | Sorting Algorithm | intermediate | Sort a 8-element array of floats in ascending order using bubble sort. | fn bubble_sort(buffer: &mut Vec<f64>) {
let n = buffer.len();
for i in 0..n {
for j in 0..n - i - 1 {
if buffer[j] > buffer[j + 1] {
buffer.swap(j, j + 1);
}
}
}
}
fn main() {
let mut buffer = vec![66.01, 7.18, 40.55, -14.76, 82.69, 9.1, 36.14, 25... | Bubble sort on float data, variable named 'buffer', 8 elements. |
241 | Rust | Sorting Algorithm | intermediate | Sort a 10-element array of floats in ascending order using bubble sort. | fn bubble_sort(values: &mut Vec<f64>) {
let n = values.len();
for i in 0..n {
for j in 0..n - i - 1 {
if values[j] > values[j + 1] {
values.swap(j, j + 1);
}
}
}
}
fn main() {
let mut values = vec![1.3, 94.28, -15.79, 75.57, 64.97, 58.03, 6.72, 9.... | Bubble sort on float data, variable named 'values', 10 elements. |
242 | Rust | Sorting Algorithm | intermediate | Sort a 10-element array of floats in ascending order using bubble sort. | fn bubble_sort(records: &mut Vec<f64>) {
let n = records.len();
for i in 0..n {
for j in 0..n - i - 1 {
if records[j] > records[j + 1] {
records.swap(j, j + 1);
}
}
}
}
fn main() {
let mut records = vec![-10.73, 24.36, 39.74, 87.33, 1.34, 75.72, 9... | Bubble sort on float data, variable named 'records', 10 elements. |
243 | Rust | Sorting Algorithm | intermediate | Sort a 10-element array of floats in ascending order using bubble sort. | fn bubble_sort(nums: &mut Vec<f64>) {
let n = nums.len();
for i in 0..n {
for j in 0..n - i - 1 {
if nums[j] > nums[j + 1] {
nums.swap(j, j + 1);
}
}
}
}
fn main() {
let mut nums = vec![72.05, 16.97, -9.72, 34.35, 23.9, 14.7, 73.36, 68.01, 8.87, 2... | Bubble sort on float data, variable named 'nums', 10 elements. |
244 | Rust | Sorting Algorithm | intermediate | Sort a 12-element array of floats in ascending order using bubble sort. | fn bubble_sort(dataset: &mut Vec<f64>) {
let n = dataset.len();
for i in 0..n {
for j in 0..n - i - 1 {
if dataset[j] > dataset[j + 1] {
dataset.swap(j, j + 1);
}
}
}
}
fn main() {
let mut dataset = vec![98.74, 72.33, 67.16, 45.04, 74.72, -2.08, 9... | Bubble sort on float data, variable named 'dataset', 12 elements. |
245 | Rust | Sorting Algorithm | intermediate | Sort a 12-element array of floats in ascending order using bubble sort. | fn bubble_sort(list1: &mut Vec<f64>) {
let n = list1.len();
for i in 0..n {
for j in 0..n - i - 1 {
if list1[j] > list1[j + 1] {
list1.swap(j, j + 1);
}
}
}
}
fn main() {
let mut list1 = vec![-19.83, 58.22, 81.03, 66.54, -7.63, 43.05, 8.34, 38.55,... | Bubble sort on float data, variable named 'list1', 12 elements. |
246 | Rust | Sorting Algorithm | intermediate | Sort a 12-element array of floats in ascending order using bubble sort. | fn bubble_sort(entries: &mut Vec<f64>) {
let n = entries.len();
for i in 0..n {
for j in 0..n - i - 1 {
if entries[j] > entries[j + 1] {
entries.swap(j, j + 1);
}
}
}
}
fn main() {
let mut entries = vec![7.55, 80.62, 29.15, 86.57, 34.56, 69.0, 49.... | Bubble sort on float data, variable named 'entries', 12 elements. |
247 | Rust | Sorting Algorithm | intermediate | Sort a 15-element array of floats in ascending order using bubble sort. | fn bubble_sort(buffer: &mut Vec<f64>) {
let n = buffer.len();
for i in 0..n {
for j in 0..n - i - 1 {
if buffer[j] > buffer[j + 1] {
buffer.swap(j, j + 1);
}
}
}
}
fn main() {
let mut buffer = vec![94.74, 8.18, 11.06, 17.49, 75.3, 63.39, 67.51, 17... | Bubble sort on float data, variable named 'buffer', 15 elements. |
248 | Rust | Sorting Algorithm | intermediate | Sort a 15-element array of floats in ascending order using bubble sort. | fn bubble_sort(dataset: &mut Vec<f64>) {
let n = dataset.len();
for i in 0..n {
for j in 0..n - i - 1 {
if dataset[j] > dataset[j + 1] {
dataset.swap(j, j + 1);
}
}
}
}
fn main() {
let mut dataset = vec![17.37, -5.63, 22.64, 71.67, 33.78, 35.14, 8... | Bubble sort on float data, variable named 'dataset', 15 elements. |
249 | Rust | Sorting Algorithm | intermediate | Sort a 15-element array of floats in ascending order using bubble sort. | fn bubble_sort(seq: &mut Vec<f64>) {
let n = seq.len();
for i in 0..n {
for j in 0..n - i - 1 {
if seq[j] > seq[j + 1] {
seq.swap(j, j + 1);
}
}
}
}
fn main() {
let mut seq = vec![9.54, 22.33, 41.1, 60.58, 10.96, 97.89, -16.3, 28.12, 33.81, 69.02,... | Bubble sort on float data, variable named 'seq', 15 elements. |
250 | Rust | Sorting Algorithm | intermediate | Sort a 20-element array of floats in ascending order using bubble sort. | fn bubble_sort(records: &mut Vec<f64>) {
let n = records.len();
for i in 0..n {
for j in 0..n - i - 1 {
if records[j] > records[j + 1] {
records.swap(j, j + 1);
}
}
}
}
fn main() {
let mut records = vec![72.93, 6.45, 3.58, 27.67, 61.67, 91.57, -10... | Bubble sort on float data, variable named 'records', 20 elements. |
251 | Rust | Sorting Algorithm | intermediate | Sort a 20-element array of floats in ascending order using bubble sort. | fn bubble_sort(entries: &mut Vec<f64>) {
let n = entries.len();
for i in 0..n {
for j in 0..n - i - 1 {
if entries[j] > entries[j + 1] {
entries.swap(j, j + 1);
}
}
}
}
fn main() {
let mut entries = vec![48.29, 77.78, 27.0, -16.49, 61.3, 0.56, 5.5... | Bubble sort on float data, variable named 'entries', 20 elements. |
252 | Rust | Sorting Algorithm | intermediate | Sort a 20-element array of floats in ascending order using bubble sort. | fn bubble_sort(entries: &mut Vec<f64>) {
let n = entries.len();
for i in 0..n {
for j in 0..n - i - 1 {
if entries[j] > entries[j + 1] {
entries.swap(j, j + 1);
}
}
}
}
fn main() {
let mut entries = vec![74.87, 9.65, 98.3, 44.7, -17.68, 25.52, 64.... | Bubble sort on float data, variable named 'entries', 20 elements. |
253 | Python | Sorting Algorithm | intermediate | Sort a 5-element array of ints in ascending order using selection sort. | def selection_sort(list1):
n = len(list1)
for i in range(n):
min_idx = i
for j in range(i + 1, n):
if list1[j] < list1[min_idx]:
min_idx = j
list1[i], list1[min_idx] = list1[min_idx], list1[i]
return list1
print(selection_sort([99, 9, -10, -25, 13])) | Selection sort on int data, variable named 'list1', 5 elements. |
254 | Python | Sorting Algorithm | intermediate | Sort a 5-element array of ints in ascending order using selection sort. | def selection_sort(buffer):
n = len(buffer)
for i in range(n):
min_idx = i
for j in range(i + 1, n):
if buffer[j] < buffer[min_idx]:
min_idx = j
buffer[i], buffer[min_idx] = buffer[min_idx], buffer[i]
return buffer
print(selection_sort([11, 18, 86, -36, 6... | Selection sort on int data, variable named 'buffer', 5 elements. |
255 | Python | Sorting Algorithm | intermediate | Sort a 5-element array of ints in ascending order using selection sort. | def selection_sort(elements):
n = len(elements)
for i in range(n):
min_idx = i
for j in range(i + 1, n):
if elements[j] < elements[min_idx]:
min_idx = j
elements[i], elements[min_idx] = elements[min_idx], elements[i]
return elements
print(selection_sort([... | Selection sort on int data, variable named 'elements', 5 elements. |
256 | Python | Sorting Algorithm | intermediate | Sort a 8-element array of ints in ascending order using selection sort. | def selection_sort(elements):
n = len(elements)
for i in range(n):
min_idx = i
for j in range(i + 1, n):
if elements[j] < elements[min_idx]:
min_idx = j
elements[i], elements[min_idx] = elements[min_idx], elements[i]
return elements
print(selection_sort([... | Selection sort on int data, variable named 'elements', 8 elements. |
257 | Python | Sorting Algorithm | intermediate | Sort a 8-element array of ints in ascending order using selection sort. | def selection_sort(items):
n = len(items)
for i in range(n):
min_idx = i
for j in range(i + 1, n):
if items[j] < items[min_idx]:
min_idx = j
items[i], items[min_idx] = items[min_idx], items[i]
return items
print(selection_sort([76, 88, 29, -6, 75, -41, -2... | Selection sort on int data, variable named 'items', 8 elements. |
258 | Python | Sorting Algorithm | intermediate | Sort a 8-element array of ints in ascending order using selection sort. | def selection_sort(items):
n = len(items)
for i in range(n):
min_idx = i
for j in range(i + 1, n):
if items[j] < items[min_idx]:
min_idx = j
items[i], items[min_idx] = items[min_idx], items[i]
return items
print(selection_sort([6, -45, 84, 72, -50, 34, 1,... | Selection sort on int data, variable named 'items', 8 elements. |
259 | Python | Sorting Algorithm | intermediate | Sort a 10-element array of ints in ascending order using selection sort. | def selection_sort(list1):
n = len(list1)
for i in range(n):
min_idx = i
for j in range(i + 1, n):
if list1[j] < list1[min_idx]:
min_idx = j
list1[i], list1[min_idx] = list1[min_idx], list1[i]
return list1
print(selection_sort([-5, 32, -35, -45, -13, -14,... | Selection sort on int data, variable named 'list1', 10 elements. |
260 | Python | Sorting Algorithm | intermediate | Sort a 10-element array of ints in ascending order using selection sort. | def selection_sort(list1):
n = len(list1)
for i in range(n):
min_idx = i
for j in range(i + 1, n):
if list1[j] < list1[min_idx]:
min_idx = j
list1[i], list1[min_idx] = list1[min_idx], list1[i]
return list1
print(selection_sort([51, -25, 36, 27, 32, -16, -... | Selection sort on int data, variable named 'list1', 10 elements. |
261 | Python | Sorting Algorithm | intermediate | Sort a 10-element array of ints in ascending order using selection sort. | def selection_sort(values):
n = len(values)
for i in range(n):
min_idx = i
for j in range(i + 1, n):
if values[j] < values[min_idx]:
min_idx = j
values[i], values[min_idx] = values[min_idx], values[i]
return values
print(selection_sort([93, 41, 7, -6, 46,... | Selection sort on int data, variable named 'values', 10 elements. |
262 | Python | Sorting Algorithm | intermediate | Sort a 12-element array of ints in ascending order using selection sort. | def selection_sort(seq):
n = len(seq)
for i in range(n):
min_idx = i
for j in range(i + 1, n):
if seq[j] < seq[min_idx]:
min_idx = j
seq[i], seq[min_idx] = seq[min_idx], seq[i]
return seq
print(selection_sort([96, 50, 95, -42, -4, 31, 6, 94, -24, 77, -14,... | Selection sort on int data, variable named 'seq', 12 elements. |
263 | Python | Sorting Algorithm | intermediate | Sort a 12-element array of ints in ascending order using selection sort. | def selection_sort(seq):
n = len(seq)
for i in range(n):
min_idx = i
for j in range(i + 1, n):
if seq[j] < seq[min_idx]:
min_idx = j
seq[i], seq[min_idx] = seq[min_idx], seq[i]
return seq
print(selection_sort([-31, 10, 38, 31, -8, -28, 35, 64, -48, 17, 3,... | Selection sort on int data, variable named 'seq', 12 elements. |
264 | Python | Sorting Algorithm | intermediate | Sort a 12-element array of ints in ascending order using selection sort. | def selection_sort(seq):
n = len(seq)
for i in range(n):
min_idx = i
for j in range(i + 1, n):
if seq[j] < seq[min_idx]:
min_idx = j
seq[i], seq[min_idx] = seq[min_idx], seq[i]
return seq
print(selection_sort([-33, 39, 15, -23, -50, -38, 48, 62, 57, -8, 5... | Selection sort on int data, variable named 'seq', 12 elements. |
265 | Python | Sorting Algorithm | intermediate | Sort a 15-element array of ints in ascending order using selection sort. | def selection_sort(entries):
n = len(entries)
for i in range(n):
min_idx = i
for j in range(i + 1, n):
if entries[j] < entries[min_idx]:
min_idx = j
entries[i], entries[min_idx] = entries[min_idx], entries[i]
return entries
print(selection_sort([46, 39, 8... | Selection sort on int data, variable named 'entries', 15 elements. |
266 | Python | Sorting Algorithm | intermediate | Sort a 15-element array of ints in ascending order using selection sort. | def selection_sort(nums):
n = len(nums)
for i in range(n):
min_idx = i
for j in range(i + 1, n):
if nums[j] < nums[min_idx]:
min_idx = j
nums[i], nums[min_idx] = nums[min_idx], nums[i]
return nums
print(selection_sort([-24, -32, 37, -7, 46, -9, -31, 90, -... | Selection sort on int data, variable named 'nums', 15 elements. |
267 | Python | Sorting Algorithm | intermediate | Sort a 15-element array of ints in ascending order using selection sort. | def selection_sort(values):
n = len(values)
for i in range(n):
min_idx = i
for j in range(i + 1, n):
if values[j] < values[min_idx]:
min_idx = j
values[i], values[min_idx] = values[min_idx], values[i]
return values
print(selection_sort([-37, -25, 34, 2, -... | Selection sort on int data, variable named 'values', 15 elements. |
268 | Python | Sorting Algorithm | intermediate | Sort a 20-element array of ints in ascending order using selection sort. | def selection_sort(elements):
n = len(elements)
for i in range(n):
min_idx = i
for j in range(i + 1, n):
if elements[j] < elements[min_idx]:
min_idx = j
elements[i], elements[min_idx] = elements[min_idx], elements[i]
return elements
print(selection_sort([... | Selection sort on int data, variable named 'elements', 20 elements. |
269 | Python | Sorting Algorithm | intermediate | Sort a 20-element array of ints in ascending order using selection sort. | def selection_sort(vals):
n = len(vals)
for i in range(n):
min_idx = i
for j in range(i + 1, n):
if vals[j] < vals[min_idx]:
min_idx = j
vals[i], vals[min_idx] = vals[min_idx], vals[i]
return vals
print(selection_sort([51, 70, 75, 17, -27, 89, 49, -3, 44,... | Selection sort on int data, variable named 'vals', 20 elements. |
270 | Python | Sorting Algorithm | intermediate | Sort a 20-element array of ints in ascending order using selection sort. | def selection_sort(elements):
n = len(elements)
for i in range(n):
min_idx = i
for j in range(i + 1, n):
if elements[j] < elements[min_idx]:
min_idx = j
elements[i], elements[min_idx] = elements[min_idx], elements[i]
return elements
print(selection_sort([... | Selection sort on int data, variable named 'elements', 20 elements. |
271 | Python | Sorting Algorithm | intermediate | Sort a 5-element array of floats in ascending order using selection sort. | def selection_sort(collection):
n = len(collection)
for i in range(n):
min_idx = i
for j in range(i + 1, n):
if collection[j] < collection[min_idx]:
min_idx = j
collection[i], collection[min_idx] = collection[min_idx], collection[i]
return collection
prin... | Selection sort on float data, variable named 'collection', 5 elements. |
272 | Python | Sorting Algorithm | intermediate | Sort a 5-element array of floats in ascending order using selection sort. | def selection_sort(buffer):
n = len(buffer)
for i in range(n):
min_idx = i
for j in range(i + 1, n):
if buffer[j] < buffer[min_idx]:
min_idx = j
buffer[i], buffer[min_idx] = buffer[min_idx], buffer[i]
return buffer
print(selection_sort([96.95, -2.45, 92.9... | Selection sort on float data, variable named 'buffer', 5 elements. |
273 | Python | Sorting Algorithm | intermediate | Sort a 5-element array of floats in ascending order using selection sort. | def selection_sort(values):
n = len(values)
for i in range(n):
min_idx = i
for j in range(i + 1, n):
if values[j] < values[min_idx]:
min_idx = j
values[i], values[min_idx] = values[min_idx], values[i]
return values
print(selection_sort([95.69, 76.21, -4.9... | Selection sort on float data, variable named 'values', 5 elements. |
274 | Python | Sorting Algorithm | intermediate | Sort a 8-element array of floats in ascending order using selection sort. | def selection_sort(collection):
n = len(collection)
for i in range(n):
min_idx = i
for j in range(i + 1, n):
if collection[j] < collection[min_idx]:
min_idx = j
collection[i], collection[min_idx] = collection[min_idx], collection[i]
return collection
prin... | Selection sort on float data, variable named 'collection', 8 elements. |
275 | Python | Sorting Algorithm | intermediate | Sort a 8-element array of floats in ascending order using selection sort. | def selection_sort(input_arr):
n = len(input_arr)
for i in range(n):
min_idx = i
for j in range(i + 1, n):
if input_arr[j] < input_arr[min_idx]:
min_idx = j
input_arr[i], input_arr[min_idx] = input_arr[min_idx], input_arr[i]
return input_arr
print(selecti... | Selection sort on float data, variable named 'input_arr', 8 elements. |
276 | Python | Sorting Algorithm | intermediate | Sort a 8-element array of floats in ascending order using selection sort. | def selection_sort(collection):
n = len(collection)
for i in range(n):
min_idx = i
for j in range(i + 1, n):
if collection[j] < collection[min_idx]:
min_idx = j
collection[i], collection[min_idx] = collection[min_idx], collection[i]
return collection
prin... | Selection sort on float data, variable named 'collection', 8 elements. |
277 | Python | Sorting Algorithm | intermediate | Sort a 10-element array of floats in ascending order using selection sort. | def selection_sort(vals):
n = len(vals)
for i in range(n):
min_idx = i
for j in range(i + 1, n):
if vals[j] < vals[min_idx]:
min_idx = j
vals[i], vals[min_idx] = vals[min_idx], vals[i]
return vals
print(selection_sort([14.05, 43.74, 20.92, 28.9, 25.58, 37... | Selection sort on float data, variable named 'vals', 10 elements. |
278 | Python | Sorting Algorithm | intermediate | Sort a 10-element array of floats in ascending order using selection sort. | def selection_sort(elements):
n = len(elements)
for i in range(n):
min_idx = i
for j in range(i + 1, n):
if elements[j] < elements[min_idx]:
min_idx = j
elements[i], elements[min_idx] = elements[min_idx], elements[i]
return elements
print(selection_sort([... | Selection sort on float data, variable named 'elements', 10 elements. |
279 | Python | Sorting Algorithm | intermediate | Sort a 10-element array of floats in ascending order using selection sort. | def selection_sort(vals):
n = len(vals)
for i in range(n):
min_idx = i
for j in range(i + 1, n):
if vals[j] < vals[min_idx]:
min_idx = j
vals[i], vals[min_idx] = vals[min_idx], vals[i]
return vals
print(selection_sort([16.06, 13.36, 38.5, 62.85, -8.31, 83... | Selection sort on float data, variable named 'vals', 10 elements. |
280 | Python | Sorting Algorithm | intermediate | Sort a 12-element array of floats in ascending order using selection sort. | def selection_sort(nums):
n = len(nums)
for i in range(n):
min_idx = i
for j in range(i + 1, n):
if nums[j] < nums[min_idx]:
min_idx = j
nums[i], nums[min_idx] = nums[min_idx], nums[i]
return nums
print(selection_sort([66.73, 51.99, -9.37, 32.56, 88.7, 28... | Selection sort on float data, variable named 'nums', 12 elements. |
281 | Python | Sorting Algorithm | intermediate | Sort a 12-element array of floats in ascending order using selection sort. | def selection_sort(seq):
n = len(seq)
for i in range(n):
min_idx = i
for j in range(i + 1, n):
if seq[j] < seq[min_idx]:
min_idx = j
seq[i], seq[min_idx] = seq[min_idx], seq[i]
return seq
print(selection_sort([40.31, -3.86, 81.3, 84.64, -16.56, 2.94, 79.1... | Selection sort on float data, variable named 'seq', 12 elements. |
282 | Python | Sorting Algorithm | intermediate | Sort a 12-element array of floats in ascending order using selection sort. | def selection_sort(nums):
n = len(nums)
for i in range(n):
min_idx = i
for j in range(i + 1, n):
if nums[j] < nums[min_idx]:
min_idx = j
nums[i], nums[min_idx] = nums[min_idx], nums[i]
return nums
print(selection_sort([23.83, 35.24, 27.24, 89.85, 61.06, 8... | Selection sort on float data, variable named 'nums', 12 elements. |
283 | Python | Sorting Algorithm | intermediate | Sort a 15-element array of floats in ascending order using selection sort. | def selection_sort(records):
n = len(records)
for i in range(n):
min_idx = i
for j in range(i + 1, n):
if records[j] < records[min_idx]:
min_idx = j
records[i], records[min_idx] = records[min_idx], records[i]
return records
print(selection_sort([86.44, 69... | Selection sort on float data, variable named 'records', 15 elements. |
284 | Python | Sorting Algorithm | intermediate | Sort a 15-element array of floats in ascending order using selection sort. | def selection_sort(vals):
n = len(vals)
for i in range(n):
min_idx = i
for j in range(i + 1, n):
if vals[j] < vals[min_idx]:
min_idx = j
vals[i], vals[min_idx] = vals[min_idx], vals[i]
return vals
print(selection_sort([61.18, 36.42, -4.25, 0.61, 75.3, 6.6... | Selection sort on float data, variable named 'vals', 15 elements. |
285 | Python | Sorting Algorithm | intermediate | Sort a 15-element array of floats in ascending order using selection sort. | def selection_sort(nums):
n = len(nums)
for i in range(n):
min_idx = i
for j in range(i + 1, n):
if nums[j] < nums[min_idx]:
min_idx = j
nums[i], nums[min_idx] = nums[min_idx], nums[i]
return nums
print(selection_sort([60.59, 78.09, 27.26, -7.82, 40.87, 5... | Selection sort on float data, variable named 'nums', 15 elements. |
286 | Python | Sorting Algorithm | intermediate | Sort a 20-element array of floats in ascending order using selection sort. | def selection_sort(records):
n = len(records)
for i in range(n):
min_idx = i
for j in range(i + 1, n):
if records[j] < records[min_idx]:
min_idx = j
records[i], records[min_idx] = records[min_idx], records[i]
return records
print(selection_sort([12.95, 58... | Selection sort on float data, variable named 'records', 20 elements. |
287 | Python | Sorting Algorithm | intermediate | Sort a 20-element array of floats in ascending order using selection sort. | def selection_sort(elements):
n = len(elements)
for i in range(n):
min_idx = i
for j in range(i + 1, n):
if elements[j] < elements[min_idx]:
min_idx = j
elements[i], elements[min_idx] = elements[min_idx], elements[i]
return elements
print(selection_sort([... | Selection sort on float data, variable named 'elements', 20 elements. |
288 | Python | Sorting Algorithm | intermediate | Sort a 20-element array of floats in ascending order using selection sort. | def selection_sort(buffer):
n = len(buffer)
for i in range(n):
min_idx = i
for j in range(i + 1, n):
if buffer[j] < buffer[min_idx]:
min_idx = j
buffer[i], buffer[min_idx] = buffer[min_idx], buffer[i]
return buffer
print(selection_sort([-9.37, 22.28, 68.5... | Selection sort on float data, variable named 'buffer', 20 elements. |
289 | JavaScript | Sorting Algorithm | intermediate | Sort a 5-element array of ints in ascending order using selection sort. | function selectionSort(records) {
const n = records.length;
for (let i = 0; i < n; i++) {
let minIdx = i;
for (let j = i + 1; j < n; j++) {
if (records[j] < records[minIdx]) minIdx = j;
}
[records[i], records[minIdx]] = [records[minIdx], records[i]];
}
return records;
}
console.log(select... | Selection sort on int data, variable named 'records', 5 elements. |
290 | JavaScript | Sorting Algorithm | intermediate | Sort a 5-element array of ints in ascending order using selection sort. | function selectionSort(elements) {
const n = elements.length;
for (let i = 0; i < n; i++) {
let minIdx = i;
for (let j = i + 1; j < n; j++) {
if (elements[j] < elements[minIdx]) minIdx = j;
}
[elements[i], elements[minIdx]] = [elements[minIdx], elements[i]];
}
return elements;
}
console.l... | Selection sort on int data, variable named 'elements', 5 elements. |
291 | JavaScript | Sorting Algorithm | intermediate | Sort a 5-element array of ints in ascending order using selection sort. | function selectionSort(dataset) {
const n = dataset.length;
for (let i = 0; i < n; i++) {
let minIdx = i;
for (let j = i + 1; j < n; j++) {
if (dataset[j] < dataset[minIdx]) minIdx = j;
}
[dataset[i], dataset[minIdx]] = [dataset[minIdx], dataset[i]];
}
return dataset;
}
console.log(select... | Selection sort on int data, variable named 'dataset', 5 elements. |
292 | JavaScript | Sorting Algorithm | intermediate | Sort a 8-element array of ints in ascending order using selection sort. | function selectionSort(dataset) {
const n = dataset.length;
for (let i = 0; i < n; i++) {
let minIdx = i;
for (let j = i + 1; j < n; j++) {
if (dataset[j] < dataset[minIdx]) minIdx = j;
}
[dataset[i], dataset[minIdx]] = [dataset[minIdx], dataset[i]];
}
return dataset;
}
console.log(select... | Selection sort on int data, variable named 'dataset', 8 elements. |
293 | JavaScript | Sorting Algorithm | intermediate | Sort a 8-element array of ints in ascending order using selection sort. | function selectionSort(elements) {
const n = elements.length;
for (let i = 0; i < n; i++) {
let minIdx = i;
for (let j = i + 1; j < n; j++) {
if (elements[j] < elements[minIdx]) minIdx = j;
}
[elements[i], elements[minIdx]] = [elements[minIdx], elements[i]];
}
return elements;
}
console.l... | Selection sort on int data, variable named 'elements', 8 elements. |
294 | JavaScript | Sorting Algorithm | intermediate | Sort a 8-element array of ints in ascending order using selection sort. | function selectionSort(input_arr) {
const n = input_arr.length;
for (let i = 0; i < n; i++) {
let minIdx = i;
for (let j = i + 1; j < n; j++) {
if (input_arr[j] < input_arr[minIdx]) minIdx = j;
}
[input_arr[i], input_arr[minIdx]] = [input_arr[minIdx], input_arr[i]];
}
return input_arr;
}
... | Selection sort on int data, variable named 'input_arr', 8 elements. |
295 | JavaScript | Sorting Algorithm | intermediate | Sort a 10-element array of ints in ascending order using selection sort. | function selectionSort(buffer) {
const n = buffer.length;
for (let i = 0; i < n; i++) {
let minIdx = i;
for (let j = i + 1; j < n; j++) {
if (buffer[j] < buffer[minIdx]) minIdx = j;
}
[buffer[i], buffer[minIdx]] = [buffer[minIdx], buffer[i]];
}
return buffer;
}
console.log(selectionSort([... | Selection sort on int data, variable named 'buffer', 10 elements. |
296 | JavaScript | Sorting Algorithm | intermediate | Sort a 10-element array of ints in ascending order using selection sort. | function selectionSort(data) {
const n = data.length;
for (let i = 0; i < n; i++) {
let minIdx = i;
for (let j = i + 1; j < n; j++) {
if (data[j] < data[minIdx]) minIdx = j;
}
[data[i], data[minIdx]] = [data[minIdx], data[i]];
}
return data;
}
console.log(selectionSort([-39, 26, 24, 66, 8... | Selection sort on int data, variable named 'data', 10 elements. |
297 | JavaScript | Sorting Algorithm | intermediate | Sort a 10-element array of ints in ascending order using selection sort. | function selectionSort(entries) {
const n = entries.length;
for (let i = 0; i < n; i++) {
let minIdx = i;
for (let j = i + 1; j < n; j++) {
if (entries[j] < entries[minIdx]) minIdx = j;
}
[entries[i], entries[minIdx]] = [entries[minIdx], entries[i]];
}
return entries;
}
console.log(select... | Selection sort on int data, variable named 'entries', 10 elements. |
298 | JavaScript | Sorting Algorithm | intermediate | Sort a 12-element array of ints in ascending order using selection sort. | function selectionSort(seq) {
const n = seq.length;
for (let i = 0; i < n; i++) {
let minIdx = i;
for (let j = i + 1; j < n; j++) {
if (seq[j] < seq[minIdx]) minIdx = j;
}
[seq[i], seq[minIdx]] = [seq[minIdx], seq[i]];
}
return seq;
}
console.log(selectionSort([-45, 79, -7, -19, 43, -41, ... | Selection sort on int data, variable named 'seq', 12 elements. |
299 | JavaScript | Sorting Algorithm | intermediate | Sort a 12-element array of ints in ascending order using selection sort. | function selectionSort(buffer) {
const n = buffer.length;
for (let i = 0; i < n; i++) {
let minIdx = i;
for (let j = i + 1; j < n; j++) {
if (buffer[j] < buffer[minIdx]) minIdx = j;
}
[buffer[i], buffer[minIdx]] = [buffer[minIdx], buffer[i]];
}
return buffer;
}
console.log(selectionSort([... | Selection sort on int data, variable named 'buffer', 12 elements. |
300 | JavaScript | Sorting Algorithm | intermediate | Sort a 12-element array of ints in ascending order using selection sort. | function selectionSort(seq) {
const n = seq.length;
for (let i = 0; i < n; i++) {
let minIdx = i;
for (let j = i + 1; j < n; j++) {
if (seq[j] < seq[minIdx]) minIdx = j;
}
[seq[i], seq[minIdx]] = [seq[minIdx], seq[i]];
}
return seq;
}
console.log(selectionSort([-48, 27, 57, -25, 83, 19, -... | Selection sort on int data, variable named 'seq', 12 elements. |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.