diff --git a/.gitignore b/.gitignore
index f995064..9b64cf0 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1,16 +1,56 @@
-# dotenv
-.env
+## sbt
+logs
+target
+/.idea
+/.idea_modules
+/.classpath
+/.gradle
+/.project
+/.gradle
+/.settings
+/public/*
-# virtualenv
-venv/
-ENV/
+# sbt specific
+.cache
+.history
+.lib/
+.bsp/
+dist/*
+lib_managed/
+src_managed/
+project/boot/
-# Rope project settings
+# Scala-IDE specific
+.scala_dependencies
+.worksheet
.ropeproject
.idea
+
+# Temporary
+.netrwhist
+*~
+
+# Vim specific ---
+# Swap
+[._]*.s[a-v][a-z]
+[._]*.sw[a-p]
+[._]s[a-v][a-z]
+[._]sw[a-p]
+._*
+*.swp
+*.swo
+
+# System Files
.DS_Store
+Thumbs.db%
+## Metals
+.metals
+.bloop
-# sbt specific
-target/
-project/target
+# dotenv
+.env
+
+# virtualenv
+venv/
+ENV/
diff --git a/.scalafmt.conf b/.scalafmt.conf
new file mode 100644
index 0000000..2e53d9f
--- /dev/null
+++ b/.scalafmt.conf
@@ -0,0 +1,13 @@
+version = "3.0.6"
+
+runner.dialect = scala213source3
+align.preset = more
+style = defaultWithAlign
+maxColumn = 115
+docstrings.style = SpaceAsterisk
+docstrings.removeEmpty = true
+continuationIndent.callSite = 2
+continuationIndent.defnSite = 4
+includeCurlyBraceInSelectChains = false
+project.git = true
+project.excludeFilters = ["target/"]
diff --git a/.travis.yml b/.travis.yml
index 7d34b7e..4a9fb46 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -2,9 +2,9 @@
os: linux
dist: xenial
language: scala
-scala: 2.13.3
+scala:
+ - 2.13.6
jdk:
- - openjdk8
- # - openjdk11 # Fails!
+ - openjdk11
# - openjdk14 # Fails!
# - openjdk15 # Fails!
diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md
new file mode 100644
index 0000000..1620269
--- /dev/null
+++ b/CONTRIBUTING.md
@@ -0,0 +1,62 @@
+## How to contribute?
+
+#### Did you find a bug?
+
+* **Ensure the bug was not already reported** by searching on GitHub
+ under [Project Issues](https://github.com/TheAlgorithms/Scala/issues).
+* Please avoid opening issues asking to be "assigned" to a particular algorithm. This merely creates unnecessary noise
+ for maintainers. Instead, please submit your implementation in a pull request, and it will be evaluated by project
+ maintainers.
+* If you are unable to find an open issue referring to the same problem, depending on the type of issue follow the
+ appropriate steps:
+
+#### Do you want to contribute to the documentation?
+
+- Please read the documentation in
+ here [Contributing to the Documentation](https://github.com/TheAlgorithms/Scala/blob/master/CONTRIBUTING.md),
+ [open a new one issue](https://github.com/TheAlgorithms/Scala/issues/new), make changes and then create a pull
+ request, it will be put under review and accepted if it is appropriate.
+
+#### Do you want to add a new feature?
+
+* [Open a new one issue](https://github.com/TheAlgorithms/Scala/issues/new). Be sure to include a **title and a clear
+ description** and a **test case** demonstrating the new feature that you want to add to the project.
+
+##### Contributing to Algorithms (Make sure to check all the points below before opening a PR)
+
+* Make sure you follow proper coding standards and naming conventions.
+ * Please
+ use [Binary Search Implementation](https://github.com/TheAlgorithms/Scala/blob/master/src/main/scala/Search/BinarySearch.scala)
+ *
+ and [Binary Search Test](https://github.com/TheAlgorithms/Scala/blob/master/src/test/scala/Search/BinarySearchSpec.scala)
+ as a reference.
+* Add the algorithm implementation as an object and not as a class
+* Add proper comments about the algorithm implementation and the functions present in the algorithm
+* Add a test spec in the test folder under the same domain as that of your algorithm. **PRs without a test spec would
+ not be accepted!**
+* Add at least 1 positive and 1 negative test in the test spec
+* Raise a PR for the algorithm object file and the test spec
+* [How to write a test case in Scala](http://www.scalatest.org/user_guide/writing_your_first_test)
+
+#### Contributing to Tests
+
+* You can contribute tests for a specific algorithm
+* Add as many tests as you can and try to cover all the borderline test cases
+* Open a PR with for your testSpec
+* Make sure you are not adding redundant test cases
+* If you see that the algorithm fails for a particular test case, then open an issue with proper explanation.
+* [How to write a test case in Scala](http://www.scalatest.org/user_guide/writing_your_first_test)
+
+#### Do you want to fix a bug?
+
+* [Open a new issue](https://github.com/TheAlgorithms/Scala/issues/new).Be sure to include a **title and a clear
+ description** and a **test case** demonstrating the expected behaviour that is not occurring.
+
+#### **Do you have questions about the source code?**
+
+* Ask any question about how to use the repository in
+ the [TheAlgorithms room in GITTER](https://gitter.im/TheAlgorithms/community?source=orgpage#) or
+ [open a new one issue](https://github.com/TheAlgorithms/Scala/issues/new)
+
+:+1::tada: That's all you need to know about the process now it's your turn to help us improve the repository, thank you
+again! :+1::tada:
\ No newline at end of file
diff --git a/DIRECTORY.md b/DIRECTORY.md
index b48aa26..8a3b712 100644
--- a/DIRECTORY.md
+++ b/DIRECTORY.md
@@ -1,58 +1,283 @@
-# List of all files
-
-## Src
- * Main
- * Scala
- * Dynamicprogramming
- * [Coinchange](https://github.com/TheAlgorithms/Scala/blob/master/src/main/scala/DynamicProgramming/CoinChange.scala)
- * Mathematics
- * [Abs](https://github.com/TheAlgorithms/Scala/blob/master/src/main/scala/Mathematics/Abs.scala)
- * [Absmax](https://github.com/TheAlgorithms/Scala/blob/master/src/main/scala/Mathematics/AbsMax.scala)
- * [Absmin](https://github.com/TheAlgorithms/Scala/blob/master/src/main/scala/Mathematics/AbsMin.scala)
- * [Binaryexponentiation](https://github.com/TheAlgorithms/Scala/blob/master/src/main/scala/Mathematics/BinaryExponentiation.scala)
- * [Fibonacci](https://github.com/TheAlgorithms/Scala/blob/master/src/main/scala/Mathematics/Fibonacci.scala)
- * [Findmax](https://github.com/TheAlgorithms/Scala/blob/master/src/main/scala/Mathematics/FindMax.scala)
- * [Findmin](https://github.com/TheAlgorithms/Scala/blob/master/src/main/scala/Mathematics/FindMin.scala)
- * [Greatercommondivisor](https://github.com/TheAlgorithms/Scala/blob/master/src/main/scala/Mathematics/GreaterCommonDivisor.scala)
- * [Linearsieve](https://github.com/TheAlgorithms/Scala/blob/master/src/main/scala/Mathematics/LinearSieve.scala)
- * [Primefactors](https://github.com/TheAlgorithms/Scala/blob/master/src/main/scala/Mathematics/PrimeFactors.scala)
- * [Streamsieve](https://github.com/TheAlgorithms/Scala/blob/master/src/main/scala/Mathematics/StreamSieve.scala)
- * Search
- * [Binarysearch](https://github.com/TheAlgorithms/Scala/blob/master/src/main/scala/Search/BinarySearch.scala)
- * [Jumpsearch](https://github.com/TheAlgorithms/Scala/blob/master/src/main/scala/Search/JumpSearch.scala)
- * [Linearsearch](https://github.com/TheAlgorithms/Scala/blob/master/src/main/scala/Search/LinearSearch.scala)
- * Sort
- * [Bubblesort](https://github.com/TheAlgorithms/Scala/blob/master/src/main/scala/Sort/BubbleSort.scala)
- * [Heapsort](https://github.com/TheAlgorithms/Scala/blob/master/src/main/scala/Sort/HeapSort.scala)
- * [Insertionsort](https://github.com/TheAlgorithms/Scala/blob/master/src/main/scala/Sort/InsertionSort.scala)
- * [Mergesort](https://github.com/TheAlgorithms/Scala/blob/master/src/main/scala/Sort/MergeSort.scala)
- * [Quicksort](https://github.com/TheAlgorithms/Scala/blob/master/src/main/scala/Sort/QuickSort.scala)
- * [Recursiveinsertionsort](https://github.com/TheAlgorithms/Scala/blob/master/src/main/scala/Sort/RecursiveInsertionSort.scala)
- * [Selectionsort](https://github.com/TheAlgorithms/Scala/blob/master/src/main/scala/Sort/SelectionSort.scala)
- * Test
- * Dynamicprogramming
- * [Coinchangespec](https://github.com/TheAlgorithms/Scala/blob/master/src/test/scala/DynamicProgramming/CoinChangeSpec.scala)
- * Mathematics
- * [Absmaxspec](https://github.com/TheAlgorithms/Scala/blob/master/src/test/scala/Mathematics/AbsMaxSpec.scala)
- * [Absminspec](https://github.com/TheAlgorithms/Scala/blob/master/src/test/scala/Mathematics/AbsMinSpec.scala)
- * [Absspec](https://github.com/TheAlgorithms/Scala/blob/master/src/test/scala/Mathematics/AbsSpec.scala)
- * [Binaryexponentiationspec](https://github.com/TheAlgorithms/Scala/blob/master/src/test/scala/Mathematics/BinaryExponentiationSpec.scala)
- * [Fibonaccispec](https://github.com/TheAlgorithms/Scala/blob/master/src/test/scala/Mathematics/FibonacciSpec.scala)
- * [Findmaxspec](https://github.com/TheAlgorithms/Scala/blob/master/src/test/scala/Mathematics/FindMaxSpec.scala)
- * [Findminspec](https://github.com/TheAlgorithms/Scala/blob/master/src/test/scala/Mathematics/FindMinSpec.scala)
- * [Greatercommondivisorspec](https://github.com/TheAlgorithms/Scala/blob/master/src/test/scala/Mathematics/GreaterCommonDivisorSpec.scala)
- * [Linearsievespec](https://github.com/TheAlgorithms/Scala/blob/master/src/test/scala/Mathematics/LinearSieveSpec.scala)
- * [Primefactorsspec](https://github.com/TheAlgorithms/Scala/blob/master/src/test/scala/Mathematics/PrimeFactorsSpec.scala)
- * [Streamsievespec](https://github.com/TheAlgorithms/Scala/blob/master/src/test/scala/Mathematics/StreamSieveSpec.scala)
- * Search
- * [Binarysearchspec](https://github.com/TheAlgorithms/Scala/blob/master/src/test/scala/Search/BinarySearchSpec.scala)
- * [Jumpsearchspec](https://github.com/TheAlgorithms/Scala/blob/master/src/test/scala/Search/JumpSearchSpec.scala)
- * [Linearsearchspec](https://github.com/TheAlgorithms/Scala/blob/master/src/test/scala/Search/LinearSearchSpec.scala)
- * Sort
- * [Bubblesortspec](https://github.com/TheAlgorithms/Scala/blob/master/src/test/scala/Sort/BubbleSortSpec.scala)
- * [Heapsortspec](https://github.com/TheAlgorithms/Scala/blob/master/src/test/scala/Sort/HeapSortSpec.scala)
- * [Insertionsortspec](https://github.com/TheAlgorithms/Scala/blob/master/src/test/scala/Sort/InsertionSortSpec.scala)
- * [Mergesortspec](https://github.com/TheAlgorithms/Scala/blob/master/src/test/scala/Sort/MergeSortSpec.scala)
- * [Quicksortspec](https://github.com/TheAlgorithms/Scala/blob/master/src/test/scala/Sort/QuickSortSpec.scala)
- * [Recursiveinsertionsortspec](https://github.com/TheAlgorithms/Scala/blob/master/src/test/scala/Sort/RecursiveInsertionSortSpec.scala)
- * [Selectionsortspec](https://github.com/TheAlgorithms/Scala/blob/master/src/test/scala/Sort/SelectionSortSpec.scala)
+# Examples
+* [Java algorithms](https://github.com/TheAlgorithms/Java/blob/master/DIRECTORY.md)
+* [Python algorithms](https://github.com/TheAlgorithms/Python/blob/master/DIRECTORY.md)
+
+# Scala algorithms
+
+## Ciphers
+* AES
+* AESEncryption
+* Caesar
+* ColumnarTranspositionCipher
+* RSA
+* SimpleSubstitutionCipher
+* Vigenere
+
+## Conversions
+* AnyBaseToAnyBase
+* AnyBaseToDecimal
+* AnytoAny
+* BinaryToDecimal
+* BinaryToHexadecimal
+* BinaryToOctal
+* DecimalToAnyBase
+* DecimalToBinary
+* DecimalToHexaDecimal
+* DecimalToOctal
+* HexaDecimalToBinary
+* HexaDecimalToDecimal
+* HexToOct
+* IntegerToRoman
+* OctalToDecimal
+* OctalToHexadecimal
+* RgbHsvConversion
+* RomanToInteger
+* TurkishToLatinConversion
+
+## DataStructures
+* Bags
+ * Bag
+* Buffers
+ * CircularBuffer
+* DynamicArray
+ * DynamicArray
+* Graphs
+ * A Star
+ * BellmanFord
+ * ConnectedComponent
+ * Cycles
+ * FloydWarshall
+ * Graphs
+ * Kruskal
+ * MatrixGraphs
+ * PrimMST
+* HashMap
+ * Hashing
+ * HashMap
+ * HashMapLinearProbing
+ * Main
+ * MainLinearProbing
+* Heaps
+ * EmptyHeapException
+ * Heap
+ * HeapElement
+ * MaxHeap
+ * MinHeap
+ * MinPriorityQueue
+* Lists
+ * CircleLinkedList
+ * CountSinglyLinkedListRecursion
+ * CursorLinkedList
+ * DoublyLinkedList
+ * Merge K SortedLinkedList
+ * MergeSortedArrayList
+ * MergeSortedSinglyLinkedList
+ * SearchSinglyLinkedListRecursion
+ * SinglyLinkedList
+* Queues
+ * GenericArrayListQueue
+ * LinkedQueue
+ * PriorityQueues
+ * Queues
+* Stacks
+ * BalancedBrackets
+ * DecimalToAnyUsingStack
+ * InfixToPostfix
+ * NodeStack
+ * StackArray
+ * StackArrayList
+ * StackOfLinkedList
+* Trees
+ * AVLTree
+ * BinaryTree
+ * BSTIterative
+ * BSTRecursive
+ * GenericTree
+ * LevelOrderTraversal
+ * LevelOrderTraversalQueue
+ * PrintTopViewofTree
+ * RedBlackBST
+ * TreeTraversal
+ * TrieImp
+ * ValidBSTOrNot
+
+## DivideAndConquer
+* ClosestPair
+* SkylineAlgorithm
+
+## DynamicProgramming
+* BoardPath
+* BruteForceKnapsack
+* [Coinchange](https://github.com/TheAlgorithms/Scala/blob/master/src/main/scala/DynamicProgramming/CoinChange.scala)
+* DyanamicProgrammingKnapsack
+* EditDistance
+* EggDropping
+* Fibonacci
+* FordFulkerson
+* KadaneAlgorithm
+* Knapsack
+* LevenshteinDistance
+* LongestCommonSubsequence
+* LongestIncreasingSubsequence
+* LongestPalindromicSubsequence
+* LongestValidParentheses
+* MatrixChainMultiplication
+* MemoizationTechniqueKnapsack
+* MinimumPathSum
+* MinimumSumPartition
+* RodCutting
+* SubsetSum
+
+## Maths
+* [AbsoluteMax](https://github.com/TheAlgorithms/Scala/blob/master/src/main/scala/Mathematics/AbsMax.scala)
+* [AbsoluteMin](https://github.com/TheAlgorithms/Scala/blob/master/src/main/scala/Mathematics/AbsMin.scala)
+* [AbsoluteValue](https://github.com/TheAlgorithms/Scala/blob/master/src/main/scala/Mathematics/Abs.scala)
+* AliquotSum
+* AmicableNumber
+* Area
+* Armstrong
+* Average
+* [Binaryexponentiation](https://github.com/TheAlgorithms/Scala/blob/master/src/main/scala/Mathematics/BinaryExponentiation.scala)
+* Ceil
+* CircularConvolutionFFT
+* Combinations
+* Convolution
+* ConvolutionFFT
+* EulerMethod
+* Factorial
+* FactorialRecursion
+* FFT
+* FFTBluestein
+* [Fibonacci](https://github.com/TheAlgorithms/Scala/blob/master/src/main/scala/Mathematics/Fibonacci.scala)
+* [Findmax](https://github.com/TheAlgorithms/Scala/blob/master/src/main/scala/Mathematics/FindMax.scala)
+* [Findmin](https://github.com/TheAlgorithms/Scala/blob/master/src/main/scala/Mathematics/FindMin.scala)
+* Floor
+* [Greatercommondivisor](https://github.com/TheAlgorithms/Scala/blob/master/src/main/scala/Mathematics/GreaterCommonDivisor.scala)
+* [Linearsieve](https://github.com/TheAlgorithms/Scala/blob/master/src/main/scala/Mathematics/LinearSieve.scala)
+* LucasSeries
+* [Primefactors](https://github.com/TheAlgorithms/Scala/blob/master/src/main/scala/Mathematics/PrimeFactors.scala)
+* MaxValue
+* Median
+* MinValue
+* Mode
+* NumberOfDigits
+* PalindromeNumber
+* ParseInteger
+* PerfectCube
+* PerfectNumber
+* PerfectSquare
+* PiNilakantha
+* Pow
+* PowerOfTwoOrNot
+* PowRecursion
+* PrimeCheck
+* PrimeFactorization
+* PythagoreanTriple
+* [Streamsieve](https://github.com/TheAlgorithms/Scala/blob/master/src/main/scala/Mathematics/StreamSieve.scala)
+* SumOfArithmeticSeries
+* SumOfDigits
+* VampireNumber
+
+## MinimizingLateness
+* MinimizingLateness
+
+## Misc
+* ColorContrastRatio
+* matrixTranspose
+* MedianOfRunningArray
+* PalindromePrime
+* RangeInSortedArray
+* WordBoggle
+
+## Others
+* BestFit
+* BrianKernighanAlgorithm
+* CountChar
+* CountWords
+* CRC32
+* CRCAlgorithm
+* Dijkstra
+* EulersFunction
+* FibToN
+* FirstFit
+* FloydTriangle
+* GuassLegendre
+* InsertDeleteInArray
+* KMP
+* KochSnowflake
+* Krishnamurthy
+* LinearCongruentialGenerator
+* LowestBasePalindrome
+* Mandelbrot
+* PasswordGen
+* PerlinNoise
+* QueueUsingTwoStacks
+* RabinKarp
+* RemoveDuplicateFromString
+* RestrictedTowerOfHanoi
+ * Main
+ * Hanoi
+* ReturnSubsequence
+* ReverseStackUsingRecursion
+* RootPrecision
+* RotateMatriceBy90Degree
+* SieveOfEratosthenes
+* SJF
+* SkylineProblem
+* StackPostfixNotation
+* StringMatchFiniteAutomata
+* ThreeSum
+* TopKWords
+* TowerOfHanoi
+* TwoPointers
+* WorstFit
+
+## Searches
+* [BinarySearch](https://github.com/TheAlgorithms/Scala/blob/master/src/main/scala/Search/BinarySearch.scala)
+* [Jumpsearch](https://github.com/TheAlgorithms/Scala/blob/master/src/main/scala/Search/JumpSearch.scala)
+* [Linearsearch](https://github.com/TheAlgorithms/Scala/blob/master/src/main/scala/Search/LinearSearch.scala)
+* InterpolationSearch
+* IterativeBinarySearch
+* IterativeTernarySearch
+* JumpSearch
+* LinearSearch
+* PerfectBinarySearch
+* SaddlebackSearch
+* SearchAlgorithm
+* TernarySearch
+
+## Sorts
+* BitonicSort
+* [BubbleSort](https://github.com/TheAlgorithms/Scala/blob/master/src/main/scala/Sort/BubbleSort.scala)
+* BubbleSortRecursion
+* BucketSort
+* CocktailShakerSort
+* CombSort
+* CountingSort
+* CycleSort
+* GnomeSort
+* [HeapSort](https://github.com/TheAlgorithms/Scala/blob/master/src/main/scala/Sort/HeapSort.scala)
+* [InsertionSort](https://github.com/TheAlgorithms/Scala/blob/master/src/main/scala/Sort/InsertionSort.scala)
+* [InsertionSortRecursive](https://github.com/TheAlgorithms/Scala/blob/master/src/main/scala/Sort/RecursiveInsertionSort.scala)
+* [Mergesort](https://github.com/TheAlgorithms/Scala/blob/master/src/main/scala/Sort/MergeSort.scala)
+* PancakeSort
+* [Quicksort](https://github.com/TheAlgorithms/Scala/blob/master/src/main/scala/Sort/QuickSort.scala)
+* RadixSort
+* [SelectionSort](https://github.com/TheAlgorithms/Scala/blob/master/src/main/scala/Sort/SelectionSort.scala)
+* ShellSort
+* SortAlgorithm
+* SortUtils
+* TimSort
+
+## Strings
+* Alphabetical
+* CharactersSame
+* CheckAnagrams
+* CheckVowels
+* HorspoolSearch
+* Lower
+* Palindrome
+* Pangram
+* ReverseString
+* Rotation
+* Upper
diff --git a/License b/LICENSE
similarity index 94%
rename from License
rename to LICENSE
index 7f26db8..abfcc52 100644
--- a/License
+++ b/LICENSE
@@ -1,6 +1,6 @@
MIT License
-Copyright (c) 2020 The Algorithms
+Copyright (c) 2016 - 2021 The Algorithms
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
diff --git a/README.md b/README.md
new file mode 100644
index 0000000..f2d610a
--- /dev/null
+++ b/README.md
@@ -0,0 +1,55 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
All algorithms implemented in Scala - for education
+
+
+Implementations are for learning purposes only. As they may be less efficient than the implementations in the Scala
+standard library, use them at your discretion.
+
+## Getting Started
+
+Read through our [Contribution Guidelines](CONTRIBUTING.md) before you contribute.
+
+## Community Channels
+
+We're on [Discord](https://discord.gg/c7MnfGFGa6) and [Gitter](https://gitter.im/TheAlgorithms)! Community channels are
+great for you to ask questions and get help. Please join us!
+
+## List of Algorithms
+
+See our [directory](DIRECTORY.md) for easier navigation and better overview of the project.
+
+## How to use this repository for learning purpose ?
+
+- [Download and install Scala](https://www.scala-lang.org/download/)
+- Clone the repository on your local machine
+
+ `git clone https://github.com/TheAlgorithms/Scala.git`
+
+- Open the repository using an IDE (Preferably IntelliJ Idea)
+
+- Enable auto-import to import the dependencies from build.sbt
+- Open the [src/main/scala](https://github.com/TheAlgorithms/Scala/tree/master/src/main/scala) to view the algorithm
+ implementations under various categories
+- Open [src/test/scala](https://github.com/TheAlgorithms/Scala/tree/master/src/test/scala) to run the test cases and
+ view the algorithm in action
+- Visit [Algorithms-Explained](https://github.com/TheAlgorithms/Algorithms-Explainations.git) to get a more detailed
+ explanation about specific algorithms
+- Check [Algorithms Visualization](https://github.com/TheAlgorithms/Scala/blob/master/Algorithms%20Visualization.md) for
+ visualization of numerous algorithms
diff --git a/Readme.md b/Readme.md
deleted file mode 100644
index 34babe9..0000000
--- a/Readme.md
+++ /dev/null
@@ -1,40 +0,0 @@
-# The Algorithms - Scala
-
-Implementation of various algorithms in Scala programming language
-
-#### How to use this repository for learning purpose ?
-
- - [Download and install Scala](https://www.scala-lang.org/download/)
- - Clone the repository on your local machine
-
- `git clone https://github.com/TheAlgorithms/Scala.git`
-
- - Open the repository using an IDE (Preferably IntelliJ)
-
- - Enable auto-import to import the dependencies from build.sbt
- - Open the [src/main/scala](https://github.com/TheAlgorithms/Scala/tree/master/src/main/scala) to view the algorithm implementations under various categories
- - Open [src/test/scala](https://github.com/TheAlgorithms/Scala/tree/master/src/test/scala) to run the test cases and view the algorithm in action
- - Visit [Algorithms-Explained](https://github.com/TheAlgorithms/Algorithms-Explainations.git) to get a more detailed explanation about specific algorithms
- - Check [Algorithms Visualization](https://github.com/TheAlgorithms/Scala/blob/master/Algorithms%20Visualization.md) for visualization of numerous algorithms
-
-#### How to contribute to this repository ?
-
-#### Contributing Algorithms : (Make sure to check all the points below before opening a PR)
-
- - Make sure you follow proper coding standards and naming conventions. Please use [Binary Search Implementation](https://github.com/TheAlgorithms/Scala/blob/master/src/main/scala/Search/BinarySearch.scala) and [Binary Search Test](https://github.com/TheAlgorithms/Scala/blob/master/src/test/scala/Search/BinarySearchSpec.scala) as a reference.
- - Add the algorithm implementation as an object and not as a class
- - Add proper comments about the algorithm implementation and the functions present in the algorithm
- - Add a test spec in the test folder under the same domain as that of your algorithm. PR without a test spec would not be accepted
- - Add at least 1 positive and 1 negative test in the test spec
- - Raise a PR for the algorithm object file and the test spec
- - [How to write a test case in Scala](http://www.scalatest.org/user_guide/writing_your_first_test)
-
-#### Contributing Tests :
-
- - You can contribute tests for a specific algorithm
- - Add as many tests as you can and try to cover all the border line test cases
- - Open a PR with for your testSpec
- - Make sure you are not adding redundant test cases
- - If you see that the algorithm fails for a particular test case, then open an issue with proper explanation.
- - [How to write a test case in Scala](http://www.scalatest.org/user_guide/writing_your_first_test)
-
diff --git a/build.sbt b/build.sbt
index d02e2cf..327584c 100644
--- a/build.sbt
+++ b/build.sbt
@@ -1,8 +1,26 @@
-name := "TheAlgorithmsScala"
+val PureConfigVersion = "0.17.0"
+val EnumeratumVersion = "1.7.0"
+val LogbackVersion = "1.2.6"
+val ScalaTestVersion = "3.2.10"
+val FlexmarkVersion = "0.62.2"
-version := "0.1"
+scalafmtOnCompile := true
-scalaVersion := "2.12.4"
-
-libraryDependencies += "org.scalactic" %% "scalactic" % "3.0.4"
-libraryDependencies += "org.scalatest" %% "scalatest" % "3.0.4" % "test"
\ No newline at end of file
+lazy val root = (project in file("."))
+ .settings(
+ organization := "com.github.thealgorithms",
+ name := "TheAlgorithmsScala",
+ version := "0.2.0-SNAPSHOT",
+ scalaVersion := "2.13.6",
+ libraryDependencies ++= Seq(
+ "com.beachape" %% "enumeratum" % EnumeratumVersion,
+ "com.github.pureconfig" %% "pureconfig" % PureConfigVersion,
+ "ch.qos.logback" % "logback-classic" % LogbackVersion,
+ "org.scalatest" %% "scalatest" % ScalaTestVersion % Test,
+ "org.scalatestplus" %% "mockito-3-4" % (ScalaTestVersion + ".0") % Test,
+ "org.scalactic" %% "scalactic" % ScalaTestVersion % Test,
+ "com.vladsch.flexmark" % "flexmark-all" % FlexmarkVersion % Test
+ ),
+ addCompilerPlugin("org.typelevel" %% "kind-projector" % "0.13.2" cross CrossVersion.full),
+ addCompilerPlugin("com.olegpy" %% "better-monadic-for" % "0.3.1")
+ )
diff --git a/project/build.properties b/project/build.properties
index 45a71bd..215ddd2 100644
--- a/project/build.properties
+++ b/project/build.properties
@@ -1 +1 @@
-sbt.version = 1.0.3
\ No newline at end of file
+sbt.version = 1.5.5
\ No newline at end of file
diff --git a/project/plugins.sbt b/project/plugins.sbt
index e69de29..f8c7b90 100644
--- a/project/plugins.sbt
+++ b/project/plugins.sbt
@@ -0,0 +1,17 @@
+// Easily manage scalac settings across scala versions with this
+addSbtPlugin("io.github.davidgregory084" % "sbt-tpolecat" % "0.1.20")
+
+// Makes our code tidy
+addSbtPlugin("org.scalameta" % "sbt-scalafmt" % "2.4.3")
+
+// Revolver allows us to use re-start and work a lot faster!
+addSbtPlugin("io.spray" % "sbt-revolver" % "0.9.1")
+
+// To keep our dependencies up to date
+addSbtPlugin("net.vonbuchholtz" % "sbt-dependency-check" % "3.2.0")
+
+// Enables test coverage analysis
+addSbtPlugin("org.scoverage" % "sbt-scoverage" % "1.9.0")
+
+// Checks Maven and Ivy repositories for dependency updates
+addSbtPlugin("com.timushev.sbt" % "sbt-updates" % "0.6.0")
diff --git a/src/main/resources/application.conf b/src/main/resources/application.conf
new file mode 100644
index 0000000..e69de29
diff --git a/src/main/scala/DynamicProgramming/CoinChange.scala b/src/main/scala/DynamicProgramming/CoinChange.scala
index 93501e0..ced9d7d 100644
--- a/src/main/scala/DynamicProgramming/CoinChange.scala
+++ b/src/main/scala/DynamicProgramming/CoinChange.scala
@@ -1,30 +1,28 @@
package DynamicProgramming
-/**
- * An implementation of famous dynamic programming Coin Change Problem
- * Problem Statement: Given an amount and a list of coin change, find number of possible
- * combinations to get the amount
+/** An implementation of famous dynamic programming Coin Change Problem Problem Statement: Given an amount and a
+ * list of coin change, find number of possible combinations to get the amount
*/
-
object CoinChange {
- /**
- *
- * @param coins - a list of integers i.e. change coins
- * @param money - the target amount
- * @return - number of combinations possible to get the amount
+ /** @param coins
+ * - a list of integers i.e. change coins
+ * @param money
+ * - the target amount
+ * @return
+ * - number of combinations possible to get the amount
*/
def coinChange(coins: List[Int], money: Int): Int = {
- val combinations :Array[Int] = new Array[Int](money+1)
+ val combinations: Array[Int] = new Array[Int](money + 1)
combinations(0) = 1
for (coin <- coins) {
for (i <- coin to money) {
if (i >= coin) {
- combinations(i) += combinations(i-coin)
+ combinations(i) += combinations(i - coin)
}
}
}
diff --git a/src/main/scala/Mathematics/Abs.scala b/src/main/scala/Mathematics/Abs.scala
index 181c0ca..eb22ce0 100644
--- a/src/main/scala/Mathematics/Abs.scala
+++ b/src/main/scala/Mathematics/Abs.scala
@@ -2,16 +2,15 @@ package Mathematics
object Abs {
- /**
- * Method returns absolute value of the number
- *
- * @param Int
- * @return
- */
+ /** Method returns absolute value of the number
+ *
+ * @param Int
+ * @return
+ */
- def abs(number : Int): Int = {
- if (number < 0)
- return number * -1
- return number;
- }
+ def abs(number: Int): Int = {
+ if (number < 0)
+ return number * -1
+ return number;
+ }
}
diff --git a/src/main/scala/Mathematics/AbsMax.scala b/src/main/scala/Mathematics/AbsMax.scala
index fd2f02b..883ca4f 100644
--- a/src/main/scala/Mathematics/AbsMax.scala
+++ b/src/main/scala/Mathematics/AbsMax.scala
@@ -2,8 +2,7 @@ package Mathematics
object AbsMax {
- /**
- * Method returns absolute Maximum Element from the list
+ /** Method returns absolute Maximum Element from the list
*
* @param listOfElements
* @return
diff --git a/src/main/scala/Mathematics/AbsMin.scala b/src/main/scala/Mathematics/AbsMin.scala
index f624c68..dee9f75 100644
--- a/src/main/scala/Mathematics/AbsMin.scala
+++ b/src/main/scala/Mathematics/AbsMin.scala
@@ -2,8 +2,7 @@ package Mathematics
object AbsMin {
- /**
- * Method returns Absolute minimum Element from the list
+ /** Method returns Absolute minimum Element from the list
*
* @param listOfElements
* @return
diff --git a/src/main/scala/Mathematics/BinaryExponentiation.scala b/src/main/scala/Mathematics/BinaryExponentiation.scala
index 5986c3f..44101bd 100644
--- a/src/main/scala/Mathematics/BinaryExponentiation.scala
+++ b/src/main/scala/Mathematics/BinaryExponentiation.scala
@@ -1,11 +1,11 @@
package Mathematics
object BinaryExponentiation {
- /**
- * Method returns the binary exponentiation of a given number
- * when base and power are passed the parameters
+
+ /** Method returns the binary exponentiation of a given number when base and power are passed the parameters
*
- * @param Int , Int
+ * @param Int
+ * , Int
* @return
*/
@@ -19,4 +19,4 @@ object BinaryExponentiation {
return answer * answer
}
}
-}
+}
diff --git a/src/main/scala/Mathematics/Fibonacci.scala b/src/main/scala/Mathematics/Fibonacci.scala
index f694467..6edcb51 100644
--- a/src/main/scala/Mathematics/Fibonacci.scala
+++ b/src/main/scala/Mathematics/Fibonacci.scala
@@ -1,13 +1,13 @@
package Mathematics
object Fibonacci {
- private val allFibonacci: Stream[Int] = 1 #:: 1 #:: allFibonacci.zip(allFibonacci.tail).map(t => t._1 + t._2)
+ private val allFibonacci: LazyList[Int] = 1 #:: 1 #:: allFibonacci.zip(allFibonacci.tail).map(t => t._1 + t._2)
- /**
- * Method to use the allFibonacci stream to take the first total numbers
- * Using streams is both an easy and efficient way to generate fibonacci numbers (streams are memoized)
+ /** Method to use the allFibonacci stream to take the first total numbers Using streams is both an easy and
+ * efficient way to generate fibonacci numbers (streams are memoized)
*
* @param total
+ * Maximum number of elements of the sequence
* @return
*/
def fibGenerate(total: Int): Seq[Int] = allFibonacci.take(total)
diff --git a/src/main/scala/Mathematics/FindMax.scala b/src/main/scala/Mathematics/FindMax.scala
index ec45f72..40e9124 100644
--- a/src/main/scala/Mathematics/FindMax.scala
+++ b/src/main/scala/Mathematics/FindMax.scala
@@ -2,8 +2,7 @@ package Mathematics
object FindMax {
- /**
- * Method returns Max Element from the list
+ /** Method returns Max Element from the list
*
* @param listOfElements
* @return
diff --git a/src/main/scala/Mathematics/FindMin.scala b/src/main/scala/Mathematics/FindMin.scala
index 16f0c89..1d67110 100644
--- a/src/main/scala/Mathematics/FindMin.scala
+++ b/src/main/scala/Mathematics/FindMin.scala
@@ -2,8 +2,7 @@ package Mathematics
object FindMin {
- /**
- * Method returns Minimum Element from the list
+ /** Method returns Minimum Element from the list
*
* @param listOfElements
* @return
diff --git a/src/main/scala/Mathematics/GreaterCommonDivisor.scala b/src/main/scala/Mathematics/GreaterCommonDivisor.scala
index b1745d9..256519d 100644
--- a/src/main/scala/Mathematics/GreaterCommonDivisor.scala
+++ b/src/main/scala/Mathematics/GreaterCommonDivisor.scala
@@ -2,10 +2,10 @@ package Mathematics
object GreaterCommonDivisor {
- /**
- * Method returns the Greatest Common Divisor of two numbers n, m
+ /** Method returns the Greatest Common Divisor of two numbers n, m
*
- * @param num1 , num2
+ * @param num1
+ * , num2
* @return
*/
diff --git a/src/main/scala/Mathematics/LinearSieve.scala b/src/main/scala/Mathematics/LinearSieve.scala
index 060f852..774efa5 100644
--- a/src/main/scala/Mathematics/LinearSieve.scala
+++ b/src/main/scala/Mathematics/LinearSieve.scala
@@ -1,14 +1,14 @@
package Mathematics
object LinearSieve {
- /**
- * Method returns sequence of prime numbers which all are not greater than n
+
+ /** Method returns sequence of prime numbers which all are not greater than n
*
* @param n
* @return
*/
def getPrimeNumbers(n: Int): Seq[Int] = {
- var primeNumbers = Seq.empty[Int]
+ var primeNumbers = Seq.empty[Int]
val lowestPrimeDivisor: Array[Int] = Array.fill(n + 1)(0)
for (i <- 2 to n) {
if (lowestPrimeDivisor(i) == 0) {
diff --git a/src/main/scala/Mathematics/PrimeFactors.scala b/src/main/scala/Mathematics/PrimeFactors.scala
index 9e6e92b..43fbbfe 100644
--- a/src/main/scala/Mathematics/PrimeFactors.scala
+++ b/src/main/scala/Mathematics/PrimeFactors.scala
@@ -2,19 +2,12 @@ package Mathematics
object PrimeFactors {
- /**
- * Method returns list of prime factors of number n
- *
- * @param num
- * @return
- */
-
- def primeFactors(number: Long): List[Long] = {
- val exists = (2L to math.sqrt(number).toLong).find(number % _ == 0)
+ /** Returns list of prime factors of number n */
+ def primeFactors(n: Long): List[Long] = {
+ val exists = (2L to math.sqrt(n.toDouble).toLong).find(n % _ == 0)
exists match {
- case None => List(number)
- case Some(factor) => factor :: primeFactors(number / factor)
-
+ case None => List(n)
+ case Some(factor) => factor :: primeFactors(n / factor)
}
}
}
diff --git a/src/main/scala/Mathematics/StreamSieve.scala b/src/main/scala/Mathematics/StreamSieve.scala
index c9f84e6..096f044 100644
--- a/src/main/scala/Mathematics/StreamSieve.scala
+++ b/src/main/scala/Mathematics/StreamSieve.scala
@@ -2,19 +2,14 @@ package Mathematics
object StreamSieve {
- private val allPrimes: Stream[Int] = 2 #:: Stream.from(3).filter { c =>
- val primesUptoSqrt = allPrimes.takeWhile(p => p <= math.sqrt(c))
- !primesUptoSqrt.exists(p => c % p == 0)
+ private val allPrimes: LazyList[Int] = 2 #:: LazyList.from(3).filter { c =>
+ val primesUpToSqrt = allPrimes.takeWhile(p => p <= math.sqrt(c.toDouble))
+ !primesUpToSqrt.exists(p => c % p == 0)
}
- /**
- * Method to use the allPrimes stream to take the first n prime numbers
- * Using streams is both an easy and efficient way to generate fibonacci numbers (streams are memoized)
- * Using streams as opposed to the classic sieve ensures that we stay following functional principles
- * and not change states
- *
- * @param total
- * @return
+ /** Method to use the allPrimes stream to take the first n prime numbers Using streams is both an easy and
+ * efficient way to generate fibonacci numbers (streams are memoized) Using streams as opposed to the classic
+ * sieve ensures that we stay following functional principles and not change states
*/
def getPrimeNumbers(n: Int): Seq[Int] = allPrimes.take(n)
}
diff --git a/src/main/scala/Search/BinarySearch.scala b/src/main/scala/Search/BinarySearch.scala
index af97530..1f19e48 100644
--- a/src/main/scala/Search/BinarySearch.scala
+++ b/src/main/scala/Search/BinarySearch.scala
@@ -1,29 +1,34 @@
package Search
-/**
- * An implementation of binary search algorithm to search an element in a sorted list
+/** An implementation of binary search algorithm to search an element in a sorted list
*/
import scala.annotation.tailrec
object BinarySearch {
- /**
- * @param arr - a sequence of integers
- * @param elem - a integer to search for in the @args
- * @return - index of the @elem otherwise -1
+ /** @param arr
+ * - a sequence of integers
+ * @param elem
+ * - a integer to search for in the @args
+ * @return
+ * - index of the @elem otherwise -1
*/
def binarySearch(arr: List[Int], elem: Int): Int = {
binarySearch(arr, elem, 0, arr.length)
}
- /**
- * @param arr - a sequence of integers
- * @param elem - a integer to search for in the @args
- * @param fromIndex - the index of the first element (inclusive) to be searched
- * @param toIndex - toIndex the index of the last element (exclusive) to be searched
- * @return - index of the @elem otherwise -1
+ /** @param arr
+ * - a sequence of integers
+ * @param elem
+ * - a integer to search for in the @args
+ * @param fromIndex
+ * - the index of the first element (inclusive) to be searched
+ * @param toIndex
+ * - toIndex the index of the last element (exclusive) to be searched
+ * @return
+ * - index of the @elem otherwise -1
*/
def binarySearch(arr: List[Int], elem: Int, fromIndex: Int, toIndex: Int): Int = {
@@ -37,7 +42,7 @@ object BinarySearch {
arr(mid) match {
case mv if (mv == elem) => mid
case mv if (mv <= elem) => SearchImpl(mid + 1, hi)
- case _ => SearchImpl(lo, mid - 1)
+ case _ => SearchImpl(lo, mid - 1)
}
}
}
@@ -45,22 +50,24 @@ object BinarySearch {
SearchImpl(fromIndex, toIndex - 1)
}
- /**
- *
- * @param arr - a sequence of integers
- * @param elem - a integer to search for in the @args
+ /** @param arr
+ * - a sequence of integers
+ * @param elem
+ * - a integer to search for in the @args
* @return
*/
def lowerBound(arr: List[Int], elem: Int): Int = {
lowerBound(arr, elem, 0, arr.length - 1)
}
- /**
- *
- * @param arr - a sequence of integers
- * @param elem - a integer to search for in the @args
- * @param lo - lowest value index
- * @param hi - highest value index
+ /** @param arr
+ * - a sequence of integers
+ * @param elem
+ * - a integer to search for in the @args
+ * @param lo
+ * - lowest value index
+ * @param hi
+ * - highest value index
* @return
*/
def lowerBound(arr: List[Int], elem: Int, lo: Int, hi: Int): Int = {
@@ -68,9 +75,9 @@ object BinarySearch {
else {
val m: Int = lo + (hi - lo) / 2
arr(m) match {
- case mv if (mv < elem) => lowerBound(arr, elem, m + 1, hi)
+ case mv if (mv < elem) => lowerBound(arr, elem, m + 1, hi)
case mv if (mv >= elem) => lowerBound(arr, elem, lo, m)
}
}
}
-}
\ No newline at end of file
+}
diff --git a/src/main/scala/Search/JumpSearch.scala b/src/main/scala/Search/JumpSearch.scala
index d183484..0f98108 100644
--- a/src/main/scala/Search/JumpSearch.scala
+++ b/src/main/scala/Search/JumpSearch.scala
@@ -1,29 +1,26 @@
package Search
-/**
- * An implementation of the jump search algorithm in scala used
- * to search a sorted list
- */
-
import scala.math.{floor, min, sqrt}
object JumpSearch {
- /**
- * @param arr - a list of integers
- * @param elem - an integer to search for in @arr
- * @return - index of the @elem otherwise -1
+ /** An implementation of the jump search algorithm in scala used to search a sorted list
+ * @param arr
+ * - a list of integers
+ * @param elem
+ * - an integer to search for in @arr
+ * @return
+ * - index of the @elem otherwise -1
*/
-
def jumpSearch(arr: List[Int], elem: Int): Int = {
- val len = arr.size
+ val len = arr.size
var a: Int = 0
- var b: Int = floor(sqrt(len)).toInt
+ var b: Int = floor(sqrt(len.toDouble)).toInt
while (arr(min(b, len) - 1) < elem) {
a = b
- b = b + floor(sqrt(len)).toInt
+ b = b + floor(sqrt(len.toDouble)).toInt
if (a >= len) {
return -1
}
@@ -37,10 +34,9 @@ object JumpSearch {
}
if (arr(a) == elem) {
- return a
- }
- else {
- return -1
+ a
+ } else {
+ -1
}
}
diff --git a/src/main/scala/Search/LinearSearch.scala b/src/main/scala/Search/LinearSearch.scala
index ce838b4..2184c16 100644
--- a/src/main/scala/Search/LinearSearch.scala
+++ b/src/main/scala/Search/LinearSearch.scala
@@ -1,21 +1,24 @@
package Search
-/**
- * This is scala implementation of linear search algorithm
+import scala.annotation.tailrec
+
+/** This is scala implementation of linear search algorithm
*/
object LinearSearch {
- /**
- *
- * @param arr - a sequence of integers
- * @param elem - a integer to search for in the @args
- * @return - index of the @elem or -1 if elem is not fount in the @arr
+
+ /** @param arr
+ * - a sequence of integers
+ * @param elem
+ * - a integer to search for in the @args
+ * @return
+ * - index of the @elem or -1 if elem is not fount in the @arr
*/
def linearSearch(arr: Vector[Int], elem: Int): Int = {
- def iter(index: Int): Int =
+ @tailrec
+ def iter(index: Int): Int =
if (index == arr.length) -1
else if (arr(index) == elem) index
else iter(index + 1)
- }
iter(0)
}
diff --git a/src/main/scala/Sort/BubbleSort.scala b/src/main/scala/Sort/BubbleSort.scala
index 73af6a2..bd21a30 100644
--- a/src/main/scala/Sort/BubbleSort.scala
+++ b/src/main/scala/Sort/BubbleSort.scala
@@ -4,15 +4,15 @@ import scala.util.control.Breaks._
object BubbleSort {
- /**
- *
- * @param array - a sequence of unsorted integers
- * @return - sequence of sorted integers @array
+ /** @param array
+ * - a sequence of unsorted integers
+ * @return
+ * - sequence of sorted integers @array
*/
def bubbleSort(array: Array[Int]): Array[Int] = {
breakable {
- for (i <- 0 to array.length - 1) {
+ for (_ <- array.indices) {
var swap = false
for (j <- 0 to array.length - 2) {
@@ -25,7 +25,7 @@ object BubbleSort {
}
if (!swap) {
- break
+ break()
}
}
}
@@ -33,4 +33,4 @@ object BubbleSort {
array
}
-}
\ No newline at end of file
+}
diff --git a/src/main/scala/Sort/HeapSort.scala b/src/main/scala/Sort/HeapSort.scala
index bc8c330..d33899d 100644
--- a/src/main/scala/Sort/HeapSort.scala
+++ b/src/main/scala/Sort/HeapSort.scala
@@ -2,9 +2,10 @@ package Sort
object HeapSort {
- /**
- * @param array - a sequence of unsorted integers
- * @return - sequence of sorted integers @array
+ /** @param arr
+ * - a sequence of unsorted integers
+ * @return
+ * - sequence of sorted integers @array
*/
def heapSort(arr: Array[Int]): Array[Int] = {
@@ -23,14 +24,13 @@ object HeapSort {
sortedArray(root) = sortedArray(child)
sortedArray(child) = t
root = child
- }
- else return
+ } else return
}
}
- var count = sortedArray.length
+ val count = sortedArray.length
var start = count / 2 - 1
- var end = count - 1
+ var end = count - 1
while (start >= 0) {
sift(start, count)
diff --git a/src/main/scala/Sort/InsertionSort.scala b/src/main/scala/Sort/InsertionSort.scala
index 8a029b4..ee9173d 100644
--- a/src/main/scala/Sort/InsertionSort.scala
+++ b/src/main/scala/Sort/InsertionSort.scala
@@ -2,17 +2,17 @@ package Sort
object InsertionSort {
- /**
- *
- * @param array - a sequence of unsorted integers
- * @return - sequence of sorted integers @array
+ /** @param array
+ * - a sequence of unsorted integers
+ * @return
+ * - sequence of sorted integers @array
*/
def insertionSort(array: Array[Int]): Array[Int] = {
for (i <- 0 to array.length - 1) {
val temp: Int = array(i)
- var j = i - 1
+ var j = i - 1
while (j >= 0 && temp < array(j)) {
array(j + 1) = array(j)
j -= 1
@@ -24,4 +24,4 @@ object InsertionSort {
array
}
-}
\ No newline at end of file
+}
diff --git a/src/main/scala/Sort/MergeSort.scala b/src/main/scala/Sort/MergeSort.scala
index efa8be0..f991bb5 100644
--- a/src/main/scala/Sort/MergeSort.scala
+++ b/src/main/scala/Sort/MergeSort.scala
@@ -1,12 +1,11 @@
package Sort
-
object MergeSort {
- /**
- *
- * @param array - a sequence of unsorted integers
- * @return - sequence of sorted integers @array
+ /** @param array
+ * - a sequence of unsorted integers
+ * @return
+ * - sequence of sorted integers @array
*/
def mergeSort(array: Array[Int]): Array[Int] = {
@@ -28,7 +27,7 @@ object MergeSort {
def merge(array: Array[Int], low: Int, mid: Int, high: Int): Array[Int] = {
// copy subarrays
- val left = array.slice(low, mid + 1)
+ val left = array.slice(low, mid + 1)
val right = array.slice(mid + 1, high + 1)
var i = 0
@@ -59,4 +58,4 @@ object MergeSort {
sort(array)
}
-}
\ No newline at end of file
+}
diff --git a/src/main/scala/Sort/QuickSort.scala b/src/main/scala/Sort/QuickSort.scala
index 3405eb6..f757ba0 100644
--- a/src/main/scala/Sort/QuickSort.scala
+++ b/src/main/scala/Sort/QuickSort.scala
@@ -1,19 +1,20 @@
package Sort
object QuickSort {
- /**
- *
- * @param array - a sequence of unsorted integers
- * @return - sequence of sorted integers @array
+
+ /** @param array
+ * - a sequence of unsorted integers
+ * @return
+ * - sequence of sorted integers @array
*/
def quickSort(array: Array[Int]): Array[Int] = {
def quickSortImpl(array: Array[Int], first: Int, last: Int): Array[Int] = {
var pivot: Int = 0
- var i: Int = 0
- var j: Int = 0
- var temp: Int = 0
+ var i: Int = 0
+ var j: Int = 0
+ var temp: Int = 0
if (first < last) {
pivot = first
@@ -48,4 +49,4 @@ object QuickSort {
quickSortImpl(array, 0, array.length - 1)
}
-}
\ No newline at end of file
+}
diff --git a/src/main/scala/Sort/RecursiveInsertionSort.scala b/src/main/scala/Sort/RecursiveInsertionSort.scala
index cb7cf42..18d79f0 100644
--- a/src/main/scala/Sort/RecursiveInsertionSort.scala
+++ b/src/main/scala/Sort/RecursiveInsertionSort.scala
@@ -2,27 +2,27 @@ package Sort
object RecursiveInsertionSort {
- /**
- *
- * @param array - a List of unsorted integers
- * @return - sequence of sorted integers @array
+ /** @param array
+ * - a List of unsorted integers
+ * @return
+ * - sequence of sorted integers @array
*/
def recursiveInsertionSort(array: List[Int]): List[Int] = {
def insertion(x: List[Int]): List[Int] = {
x match {
- case List() => List()
+ case List() => List()
case x :: xs => ins(x, insertion(xs))
}
}
def ins(x: Int, xs: List[Int]): List[Int] = {
xs match {
- case List() => List(x)
+ case List() => List(x)
case x2 :: xs2 => if (x <= x2) x :: xs else x2 :: ins(x, xs2)
}
}
insertion(array)
}
-}
\ No newline at end of file
+}
diff --git a/src/main/scala/Sort/SelectionSort.scala b/src/main/scala/Sort/SelectionSort.scala
index 72fe535..02f8bb2 100644
--- a/src/main/scala/Sort/SelectionSort.scala
+++ b/src/main/scala/Sort/SelectionSort.scala
@@ -2,17 +2,17 @@ package Sort
object SelectionSort {
- /**
- *
- * @param array - a sequence of unsorted integers
- * @return - sequence of sorted integers @array
+ /** @param array
+ * - a sequence of unsorted integers
+ * @return
+ * - sequence of sorted integers @array
*/
def selectionSort(array: Array[Int]): Array[Int] = {
for (i <- 0 to array.length - 1) {
var min: Int = i
- var minVal = array(i)
+ var minVal = array(i)
for (j <- i + 1 to array.length - 1) {
if (array(j) < minVal) {
@@ -29,4 +29,4 @@ object SelectionSort {
array
}
-}
\ No newline at end of file
+}
diff --git a/src/test/resources/application.conf b/src/test/resources/application.conf
new file mode 100644
index 0000000..e69de29
diff --git a/src/test/scala/DynamicProgramming/CoinChangeSpec.scala b/src/test/scala/DynamicProgramming/CoinChangeSpec.scala
index 2fe4bb8..63fa125 100644
--- a/src/test/scala/DynamicProgramming/CoinChangeSpec.scala
+++ b/src/test/scala/DynamicProgramming/CoinChangeSpec.scala
@@ -1,25 +1,25 @@
package DynamicProgramming
-import org.scalatest.FlatSpec
+import org.scalatest.flatspec.AnyFlatSpec
-class CoinChangeSpec extends FlatSpec {
+class CoinChangeSpec extends AnyFlatSpec {
"Coin Change 1" should "return the number of combinations for the amount1" in {
- assert(CoinChange.coinChange(List(1,2), 4) === 3)
+ assert(CoinChange.coinChange(List(1, 2), 4) === 3)
}
"Coin Change 2" should "return the number of combinations for the amount2" in {
- assert(CoinChange.coinChange(List(5,10,20,50,100,200,500), 300) === 1022)
+ assert(CoinChange.coinChange(List(5, 10, 20, 50, 100, 200, 500), 300) === 1022)
}
"Coin Change 3" should "return the number of combinations for the amount3" in {
- assert(CoinChange.coinChange(List(5,10,20,50,100,200,500), 301) === 0)
+ assert(CoinChange.coinChange(List(5, 10, 20, 50, 100, 200, 500), 301) === 0)
}
"Coin Change 4" should "return the number of combinations for the amount4" in {
- assert(CoinChange.coinChange(List(500,5,50,100,20,200,10), 300) === 1022)
+ assert(CoinChange.coinChange(List(500, 5, 50, 100, 20, 200, 10), 300) === 1022)
}
}
diff --git a/src/test/scala/Mathematics/AbsMaxSpec.scala b/src/test/scala/Mathematics/AbsMaxSpec.scala
index 761f575..0de6c93 100644
--- a/src/test/scala/Mathematics/AbsMaxSpec.scala
+++ b/src/test/scala/Mathematics/AbsMaxSpec.scala
@@ -1,8 +1,8 @@
package Mathematics
-import org.scalatest.FlatSpec
+import org.scalatest.flatspec.AnyFlatSpec
-class AbsMaxSpec extends FlatSpec {
+class AbsMaxSpec extends AnyFlatSpec {
"Abs max spec 1" should "output the correct Integer as a result from the list of elements" in {
assert(AbsMax.absMax(List(-1000, -1, 999, 72, 65, -56, -767)) === 1000)
diff --git a/src/test/scala/Mathematics/AbsMinSpec.scala b/src/test/scala/Mathematics/AbsMinSpec.scala
index 8f4eb1e..983098a 100644
--- a/src/test/scala/Mathematics/AbsMinSpec.scala
+++ b/src/test/scala/Mathematics/AbsMinSpec.scala
@@ -1,8 +1,8 @@
package Mathematics
-import org.scalatest.FlatSpec
+import org.scalatest.flatspec.AnyFlatSpec
-class AbsMinSpec extends FlatSpec {
+class AbsMinSpec extends AnyFlatSpec {
"abs min spec 1" should "output the correct Integer as a result from the list of elements" in {
assert(AbsMin.absMin(List(1000, -1, 999, 72, 65, -56, -767)) === 1)
diff --git a/src/test/scala/Mathematics/AbsSpec.scala b/src/test/scala/Mathematics/AbsSpec.scala
index fdf2d46..db4f483 100644
--- a/src/test/scala/Mathematics/AbsSpec.scala
+++ b/src/test/scala/Mathematics/AbsSpec.scala
@@ -1,8 +1,8 @@
package Mathematics
-import org.scalatest.FlatSpec
+import org.scalatest.flatspec.AnyFlatSpec
-class AbsSpec extends FlatSpec {
+class AbsSpec extends AnyFlatSpec {
"abs spec 1" should "output the correct Integer as a result" in {
assert(Abs.abs(-1) === 1)
diff --git a/src/test/scala/Mathematics/BinaryExponentiationSpec.scala b/src/test/scala/Mathematics/BinaryExponentiationSpec.scala
index 7ae669e..6b88be4 100644
--- a/src/test/scala/Mathematics/BinaryExponentiationSpec.scala
+++ b/src/test/scala/Mathematics/BinaryExponentiationSpec.scala
@@ -1,8 +1,8 @@
package Mathematics
-import org.scalatest.FlatSpec
+import org.scalatest.flatspec.AnyFlatSpec
-class BinaryExponentiationSpec extends FlatSpec {
+class BinaryExponentiationSpec extends AnyFlatSpec {
it should "output the correct Integer as a result for base raised to the power " in {
assert(BinaryExponentiation.binaryExponentiation(2, 3) === 8)
diff --git a/src/test/scala/Mathematics/FibonacciSpec.scala b/src/test/scala/Mathematics/FibonacciSpec.scala
index 8e6b831..6d54d44 100644
--- a/src/test/scala/Mathematics/FibonacciSpec.scala
+++ b/src/test/scala/Mathematics/FibonacciSpec.scala
@@ -1,13 +1,15 @@
package Mathematics
-import org.scalatest.FlatSpec
+import org.scalatest.flatspec.AnyFlatSpec
-class FibonacciSpec extends FlatSpec {
+class FibonacciSpec extends AnyFlatSpec {
"FibonacciSpec 1" should "output the correct sequence of the first 40 fib numbers" in {
- assert(Fibonacci.fibGenerate(40) === Seq(1, 1, 2, 3, 5, 8, 13, 21, 34, 55, 89, 144, 233, 377, 610, 987, 1597,
- 2584, 4181, 6765, 10946, 17711, 28657, 46368, 75025, 121393, 196418, 317811, 514229, 832040,
- 1346269, 2178309, 3524578, 5702887, 9227465, 14930352, 24157817, 39088169, 63245986, 102334155))
+ assert(
+ Fibonacci.fibGenerate(40) === Seq(1, 1, 2, 3, 5, 8, 13, 21, 34, 55, 89, 144, 233, 377, 610, 987, 1597, 2584,
+ 4181, 6765, 10946, 17711, 28657, 46368, 75025, 121393, 196418, 317811, 514229, 832040, 1346269, 2178309,
+ 3524578, 5702887, 9227465, 14930352, 24157817, 39088169, 63245986, 102334155)
+ )
}
it should "output the correct sequence of the 45th fib number" in {
diff --git a/src/test/scala/Mathematics/FindMaxSpec.scala b/src/test/scala/Mathematics/FindMaxSpec.scala
index ac752fc..3220b29 100644
--- a/src/test/scala/Mathematics/FindMaxSpec.scala
+++ b/src/test/scala/Mathematics/FindMaxSpec.scala
@@ -1,8 +1,8 @@
package Mathematics
-import org.scalatest.FlatSpec
+import org.scalatest.flatspec.AnyFlatSpec
-class FindMaxSpec extends FlatSpec {
+class FindMaxSpec extends AnyFlatSpec {
"FindMaxSpec 1" should "output the correct Integer as a result from the list of elements" in {
assert(FindMax.findMax(List(-1000, -1, 999, 72, 65, -56, -767)) === 999)
diff --git a/src/test/scala/Mathematics/FindMinSpec.scala b/src/test/scala/Mathematics/FindMinSpec.scala
index 98a91ff..57c04aa 100644
--- a/src/test/scala/Mathematics/FindMinSpec.scala
+++ b/src/test/scala/Mathematics/FindMinSpec.scala
@@ -1,13 +1,12 @@
package Mathematics
-import org.scalatest.FlatSpec
+import org.scalatest.flatspec.AnyFlatSpec
-class FindMinSpec extends FlatSpec {
+class FindMinSpec extends AnyFlatSpec {
"FindMinSpec 1" should "output the correct Integer as a result from the list of elements" in {
assert(FindMin.findMin(List(-1000, -1, 999, 72, 65, -56, -767)) === -1000)
}
-1
"FindMinSpec 2" should "output the correct Integer as a result from the list of elements" in {
assert(FindMin.findMin(List(121, 221, 3, 4112)) === 3)
}
diff --git a/src/test/scala/Mathematics/GreaterCommonDivisorSpec.scala b/src/test/scala/Mathematics/GreaterCommonDivisorSpec.scala
index ab0341b..29ea102 100644
--- a/src/test/scala/Mathematics/GreaterCommonDivisorSpec.scala
+++ b/src/test/scala/Mathematics/GreaterCommonDivisorSpec.scala
@@ -1,8 +1,8 @@
package Mathematics
-import org.scalatest.FlatSpec
+import org.scalatest.flatspec.AnyFlatSpec
-class GreaterCommonDivisorSpec extends FlatSpec {
+class GreaterCommonDivisorSpec extends AnyFlatSpec {
"GreaterCommonDivisorSpec 1" should "output the correct Integer as a result Greatest Common Divisor of two numbers" in {
assert(GreaterCommonDivisor.gcd(80, 10) === 10)
diff --git a/src/test/scala/Mathematics/LinearSieveSpec.scala b/src/test/scala/Mathematics/LinearSieveSpec.scala
index 8076fe1..da2f649 100644
--- a/src/test/scala/Mathematics/LinearSieveSpec.scala
+++ b/src/test/scala/Mathematics/LinearSieveSpec.scala
@@ -1,8 +1,8 @@
package Mathematics
-import org.scalatest.FlatSpec
+import org.scalatest.flatspec.AnyFlatSpec
-class LinearSieveSpec extends FlatSpec {
+class LinearSieveSpec extends AnyFlatSpec {
"Linear sieve" should "return all prime numbers for specific n" in {
val n = 15
assert(LinearSieve.getPrimeNumbers(n) === List(2, 3, 5, 7, 11, 13))
@@ -18,6 +18,3 @@ class LinearSieveSpec extends FlatSpec {
true
}
}
-
-
-
diff --git a/src/test/scala/Mathematics/PrimeFactorsSpec.scala b/src/test/scala/Mathematics/PrimeFactorsSpec.scala
index cb2256e..cf996d2 100644
--- a/src/test/scala/Mathematics/PrimeFactorsSpec.scala
+++ b/src/test/scala/Mathematics/PrimeFactorsSpec.scala
@@ -1,8 +1,8 @@
package Mathematics
-import org.scalatest.FlatSpec
+import org.scalatest.flatspec.AnyFlatSpec
-class PrimeFactorsSpec extends FlatSpec {
+class PrimeFactorsSpec extends AnyFlatSpec {
"PrimeFactorsSpec 1" should "output the correct list of all the prime factors of a number" in {
assert(PrimeFactors.primeFactors(80) === List(2, 2, 2, 2, 5))
diff --git a/src/test/scala/Mathematics/StreamSieveSpec.scala b/src/test/scala/Mathematics/StreamSieveSpec.scala
index 0d7e316..0f8f295 100644
--- a/src/test/scala/Mathematics/StreamSieveSpec.scala
+++ b/src/test/scala/Mathematics/StreamSieveSpec.scala
@@ -1,14 +1,16 @@
package Mathematics
-import org.scalatest.FlatSpec
+import org.scalatest.flatspec.AnyFlatSpec
-class StreamSieveSpec extends FlatSpec {
+class StreamSieveSpec extends AnyFlatSpec {
"StreamSieveSpec 1" should "output the correct sequence of the first 100 primes" in {
- assert(StreamSieve.getPrimeNumbers(100) === Seq(2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43,
- 47, 53, 59, 61, 67, 71, 73, 79, 83, 89, 97, 101, 103, 107, 109, 113, 127, 131, 137, 139, 149, 151, 157, 163,
- 167, 173, 179, 181, 191, 193, 197, 199, 211, 223, 227, 229, 233, 239, 241, 251, 257, 263, 269, 271, 277, 281,
- 283, 293, 307, 311, 313, 317, 331, 337, 347, 349, 353, 359, 367, 373, 379, 383, 389, 397, 401, 409, 419, 421,
- 431, 433, 439, 443, 449, 457, 461, 463, 467, 479, 487, 491, 499, 503, 509, 521, 523, 541))
+ assert(
+ StreamSieve.getPrimeNumbers(100) === Seq(2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61,
+ 67, 71, 73, 79, 83, 89, 97, 101, 103, 107, 109, 113, 127, 131, 137, 139, 149, 151, 157, 163, 167, 173, 179,
+ 181, 191, 193, 197, 199, 211, 223, 227, 229, 233, 239, 241, 251, 257, 263, 269, 271, 277, 281, 283, 293,
+ 307, 311, 313, 317, 331, 337, 347, 349, 353, 359, 367, 373, 379, 383, 389, 397, 401, 409, 419, 421, 431,
+ 433, 439, 443, 449, 457, 461, 463, 467, 479, 487, 491, 499, 503, 509, 521, 523, 541)
+ )
}
it should "output the correct sequence of the 1001h prime" in {
diff --git a/src/test/scala/Search/BinarySearchSpec.scala b/src/test/scala/Search/BinarySearchSpec.scala
index 1c961ce..494de88 100644
--- a/src/test/scala/Search/BinarySearchSpec.scala
+++ b/src/test/scala/Search/BinarySearchSpec.scala
@@ -1,8 +1,8 @@
package Search
-import org.scalatest.FlatSpec
+import org.scalatest.flatspec.AnyFlatSpec
-class BinarySearchSpec extends FlatSpec {
+class BinarySearchSpec extends AnyFlatSpec {
"A Binary Search" should "return the index of an element in an array" in {
val l = List.range(1, 10)
assert(BinarySearch.binarySearch(l, 2) === 1)
diff --git a/src/test/scala/Search/JumpSearchSpec.scala b/src/test/scala/Search/JumpSearchSpec.scala
index 3c56f2e..b94facb 100644
--- a/src/test/scala/Search/JumpSearchSpec.scala
+++ b/src/test/scala/Search/JumpSearchSpec.scala
@@ -1,8 +1,8 @@
package Search
-import org.scalatest.FlatSpec
+import org.scalatest.flatspec.AnyFlatSpec
-class JumpSearchSpec extends FlatSpec {
+class JumpSearchSpec extends AnyFlatSpec {
"A Jump Search" should "return the index of an element in an array" in {
val l = List.range(1, 10)
assert(JumpSearch.jumpSearch(l, 2) == 1)
@@ -10,8 +10,8 @@ class JumpSearchSpec extends FlatSpec {
}
it should "return -1 if the element is not present in the list" in {
- val l = List.range(1,10)
- val m = List(1,3,5,7)
+ val l = List.range(1, 10)
+ val m = List(1, 3, 5, 7)
assert(JumpSearch.jumpSearch(l, 12) == -1)
assert(JumpSearch.jumpSearch(l, -3) == -1)
assert(JumpSearch.jumpSearch(m, 4) == -1)
diff --git a/src/test/scala/Search/LinearSearchSpec.scala b/src/test/scala/Search/LinearSearchSpec.scala
index fdbb1e2..e32e98e 100644
--- a/src/test/scala/Search/LinearSearchSpec.scala
+++ b/src/test/scala/Search/LinearSearchSpec.scala
@@ -1,18 +1,18 @@
package Search
-import org.scalatest.FlatSpec
+import org.scalatest.flatspec.AnyFlatSpec
-class LinearSearchSpec extends FlatSpec {
+class LinearSearchSpec extends AnyFlatSpec {
"A Linear Search" should "return the index of an element in an array" in {
- val l = List(3,2,7,1,9,0)
- assert(LinearSearch.linearSearch(l,2) === 1)
- assert(LinearSearch.linearSearch(l,7) === 2)
+ val l = Vector(3, 2, 7, 1, 9, 0)
+ assert(LinearSearch.linearSearch(l, 2) === 1)
+ assert(LinearSearch.linearSearch(l, 7) === 2)
}
it should "return -1 if the element is not present in the list" in {
- val l = List(3,2,7,1,9,0)
- assert(LinearSearch.linearSearch(l,17) === -1)
+ val l = Vector(3, 2, 7, 1, 9, 0)
+ assert(LinearSearch.linearSearch(l, 17) === -1)
}
}
diff --git a/src/test/scala/Sort/BubbleSortSpec.scala b/src/test/scala/Sort/BubbleSortSpec.scala
index e746749..7331df9 100644
--- a/src/test/scala/Sort/BubbleSortSpec.scala
+++ b/src/test/scala/Sort/BubbleSortSpec.scala
@@ -1,12 +1,12 @@
package Sort
-import org.scalatest.FlatSpec
+import org.scalatest.flatspec.AnyFlatSpec
-class BubbleSortSpec extends FlatSpec {
+class BubbleSortSpec extends AnyFlatSpec {
"A Bubble Sort" should "return a sorted version of an array passed to it" in {
- val arr = Array(3,2,7,1,9,0)
- assert(BubbleSort.bubbleSort(arr) === Array(0,1,2,3,7,9))
+ val arr = Array(3, 2, 7, 1, 9, 0)
+ assert(BubbleSort.bubbleSort(arr) === Array(0, 1, 2, 3, 7, 9))
}
}
diff --git a/src/test/scala/Sort/HeapSortSpec.scala b/src/test/scala/Sort/HeapSortSpec.scala
index 114ab09..37895ae 100644
--- a/src/test/scala/Sort/HeapSortSpec.scala
+++ b/src/test/scala/Sort/HeapSortSpec.scala
@@ -1,8 +1,8 @@
package Sort
-import org.scalatest.FlatSpec
+import org.scalatest.flatspec.AnyFlatSpec
-class HeapSortSpec extends FlatSpec {
+class HeapSortSpec extends AnyFlatSpec {
"Heap Sort" should "return a sorted version of an array passed to it" in {
val arr = Array(3, 2, 7, 1, 9, 0)
diff --git a/src/test/scala/Sort/InsertionSortSpec.scala b/src/test/scala/Sort/InsertionSortSpec.scala
index 84b2712..0c8231a 100644
--- a/src/test/scala/Sort/InsertionSortSpec.scala
+++ b/src/test/scala/Sort/InsertionSortSpec.scala
@@ -1,8 +1,8 @@
package Sort
-import org.scalatest.FlatSpec
+import org.scalatest.flatspec.AnyFlatSpec
-class InsertionSortSpec extends FlatSpec {
+class InsertionSortSpec extends AnyFlatSpec {
"An Insertion Sort" should "return a sorted version of an array passed to it" in {
val arr = Array(3, 2, 7, 1, 9, 0)
diff --git a/src/test/scala/Sort/MergeSortSpec.scala b/src/test/scala/Sort/MergeSortSpec.scala
index 3497264..73cefbc 100644
--- a/src/test/scala/Sort/MergeSortSpec.scala
+++ b/src/test/scala/Sort/MergeSortSpec.scala
@@ -1,12 +1,12 @@
package Sort
-import org.scalatest.FlatSpec
+import org.scalatest.flatspec.AnyFlatSpec
-class MergeSortSpec extends FlatSpec {
+class MergeSortSpec extends AnyFlatSpec {
"A Merge Sort" should "return a sorted version of an array passed to it" in {
- val arr = Array(3,2,7,1,9,0)
- assert(MergeSort.mergeSort(arr) === Array(0,1,2,3,7,9))
+ val arr = Array(3, 2, 7, 1, 9, 0)
+ assert(MergeSort.mergeSort(arr) === Array(0, 1, 2, 3, 7, 9))
}
}
diff --git a/src/test/scala/Sort/QuickSortSpec.scala b/src/test/scala/Sort/QuickSortSpec.scala
index 2f5fad3..56eb055 100644
--- a/src/test/scala/Sort/QuickSortSpec.scala
+++ b/src/test/scala/Sort/QuickSortSpec.scala
@@ -1,12 +1,12 @@
package Sort
-import org.scalatest.FlatSpec
+import org.scalatest.flatspec.AnyFlatSpec
-class QuickSortSpec extends FlatSpec {
+class QuickSortSpec extends AnyFlatSpec {
"A Quick Sort" should "return a sorted version of an array passed to it" in {
- val arr = Array(3,2,7,1,9,0)
- assert(QuickSort.quickSort(arr) === Array(0,1,2,3,7,9))
+ val arr = Array(3, 2, 7, 1, 9, 0)
+ assert(QuickSort.quickSort(arr) === Array(0, 1, 2, 3, 7, 9))
}
}
diff --git a/src/test/scala/Sort/RecursiveInsertionSortSpec.scala b/src/test/scala/Sort/RecursiveInsertionSortSpec.scala
index ad332c6..f842b68 100644
--- a/src/test/scala/Sort/RecursiveInsertionSortSpec.scala
+++ b/src/test/scala/Sort/RecursiveInsertionSortSpec.scala
@@ -1,12 +1,12 @@
package Sort
-import org.scalatest.FlatSpec
+import org.scalatest.flatspec.AnyFlatSpec
-class RecursiveInsertionSortSpec extends FlatSpec {
+class RecursiveInsertionSortSpec extends AnyFlatSpec {
"A Recursive Insertion Sort" should "return a sorted version of a list passed to it" in {
- val arr = List(3,2,7,1,9,0)
- assert(RecursiveInsertionSort.recursiveInsertionSort(arr) === List(0,1,2,3,7,9))
+ val arr = List(3, 2, 7, 1, 9, 0)
+ assert(RecursiveInsertionSort.recursiveInsertionSort(arr) === List(0, 1, 2, 3, 7, 9))
}
}
diff --git a/src/test/scala/Sort/SelectionSortSpec.scala b/src/test/scala/Sort/SelectionSortSpec.scala
index 4fe3405..24b5fe1 100644
--- a/src/test/scala/Sort/SelectionSortSpec.scala
+++ b/src/test/scala/Sort/SelectionSortSpec.scala
@@ -1,12 +1,12 @@
package Sort
-import org.scalatest.FlatSpec
+import org.scalatest.flatspec.AnyFlatSpec
-class SelectionSortSpec extends FlatSpec {
+class SelectionSortSpec extends AnyFlatSpec {
"A Selection Sort" should "return a sorted version of an array passed to it" in {
- val arr = Array(3,2,7,1,9,0)
- assert(SelectionSort.selectionSort(arr) === Array(0,1,2,3,7,9))
+ val arr = Array(3, 2, 7, 1, 9, 0)
+ assert(SelectionSort.selectionSort(arr) === Array(0, 1, 2, 3, 7, 9))
}
}