Julia samples (#108)

* Add julialang binary search sample

* Add unit test

* Add julialang selection sort sample

* Change julia suffix to jl

* Add recursion and quick sort with tests

* add quick sort

* Add hash table samples

* Add BFS

* Changed file names

* Add dijkstras

* Add Dijkstras test
This commit is contained in:
Massoud Afrashteh
2019-11-12 18:49:21 +03:30
committed by Aditya Bhargava
parent 30bbe9cf01
commit 9dc7611411
14 changed files with 255 additions and 0 deletions

View File

@@ -0,0 +1,26 @@
using Test
function find_smallest(arr)
smallest = arr[1]
smallest_index = 1
for i = 1:length(arr)
if arr[i] < smallest
smallest = arr[i]
smallest_index = i
end
end
return smallest_index
end
function selection_sort(arr)
new_arr = Array{Int64}(undef,0)
for i = 1:length(arr)
smallest = find_smallest(arr)
append!(new_arr,arr[smallest])
deleteat!(arr,smallest)
end
return new_arr
end
arr = [5,3,6,2,10]
@test selection_sort(arr) == [2,3,5,6,10]