This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| public class BubbleSortAlgorithm implements SortAlgorithm{ | |
| public int[] sort(int[] numbers) { | |
| // Logic for Bubble Sort | |
| return numbers; | |
| } | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| @Component | |
| public class BubbleSortAlgorithm implements SortAlgorithm{ | |
| public int[] sort(int[] numbers) { | |
| // Logic for Bubble Sort | |
| return numbers; | |
| } | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| @Component | |
| @Primary | |
| public class QuickSortAlgorithm implements SortAlgorithm{ | |
| public int[] sort(int[] numbers) { | |
| // Logic for Quick Sort | |
| return numbers; | |
| } | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| public class BinarySearchImpl { | |
| @Autowired | |
| private SortAlgorithm sortAlgorithm; | |
| public BinarySearchImpl(SortAlgorithm sortAlgorithm) { | |
| super(); | |
| this.sortAlgorithm = sortAlgorithm; | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| @Component | |
| public class BinarySearchImpl { | |
| @Autowired | |
| private SortAlgorithm sortAlgorithm; | |
| public BinarySearchImpl(SortAlgorithm sortAlgorithm) { | |
| super(); | |
| this.sortAlgorithm = sortAlgorithm; | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| @Component | |
| @Primary | |
| public class BubbleSortAlgorithm implements SortAlgorithm{ | |
| public int[] sort(int[] numbers) { | |
| // Logic for Bubble Sort | |
| return numbers; | |
| } | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| @Component | |
| public class QuickSortAlgorithm implements SortAlgorithm{ | |
| public int[] sort(int[] numbers) { | |
| // Logic for Quick Sort | |
| return numbers; | |
| } | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| @Component | |
| public class BinarySearchImpl { | |
| @Autowired | |
| private SortAlgorithm sortAlgorithm; | |
| public BinarySearchImpl(SortAlgorithm sortAlgorithm) { | |
| super(); | |
| this.sortAlgorithm = sortAlgorithm; | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| @Component | |
| public class BinarySearchImpl { | |
| @Autowired | |
| private SortAlgorithm sortAlgorithm; | |
| public void setSortAlgorithm(SortAlgorithm sortAlgorithm) { | |
| this.sortAlgorithm = sortAlgorithm; | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| @Component | |
| public class BinarySearchImpl { | |
| @Autowired | |
| private SortAlgorithm sortAlgorithm; | |
| public int binarySearch(int [] numbers,int numberToSearchFor) { | |
| int[] sortedNumbers = sortAlgorithm.sort(numbers); | |
| System.out.println(sortAlgorithm); | |
| //Search the array |