Terms of Service
|
Privacy Policy
|
Cookie Policy
Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
Menu
Open sidebar
java-dojo
binary-search
Commits
ecac4f00
Commit
ecac4f00
authored
Apr 11, 2015
by
Uwe Plonus
Browse files
Changed text from apt format to markdown.
parent
d9b54b47
Changes
3
Hide whitespace changes
Inline
Side-by-side
pom.xml
View file @
ecac4f00
<?xml version="1.0" encoding="UTF-8"?>
<project
xmlns=
"http://maven.apache.org/POM/4.0.0"
xmlns:xsi=
"http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation=
"http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"
>
<project
xmlns=
"http://maven.apache.org/POM/4.0.0"
xmlns:xsi=
"http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation=
"http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"
>
<modelVersion>
4.0.0
</modelVersion>
<groupId>
com.github.java-dojo
</groupId>
...
...
@@ -17,6 +19,7 @@
<testng.version>
6.8.21
</testng.version>
<doxia.markdown.version>
1.6
</doxia.markdown.version>
<javadoc.plugin.version>
2.10.2
</javadoc.plugin.version>
<project-info-reports.plugin.version>
2.8
</project-info-reports.plugin.version>
<scm-publish.plugin.version>
1.1
</scm-publish.plugin.version>
...
...
@@ -39,6 +42,13 @@
<groupId>
org.apache.maven.plugins
</groupId>
<artifactId>
maven-site-plugin
</artifactId>
<version>
${site.plugin.version}
</version>
<dependencies>
<dependency>
<groupId>
org.apache.maven.doxia
</groupId>
<artifactId>
doxia-module-markdown
</artifactId>
<version>
${doxia.markdown.version}
</version>
</dependency>
</dependencies>
<configuration>
<skipDeploy>
true
</skipDeploy>
</configuration>
...
...
src/site/apt/index.apt.vm
deleted
100644 → 0
View file @
d9b54b47
Task
Your task is to implement the method
<
<<
search
>
>> in the class
<
<<
BinarySearch
>
>>.
Specification
The method
<
<<
search
>
>> searches over a given array of
<
<<
int
>
>>s and returns
<
<<
true
>
>>, if the value to search for is found.
Implement a binary search. If needed you can add further (private) methods to
the class
<
<<
BinarySearch
>
>>.
Algorithm
To perform a binary search you test the element in the middle of the (sorted)
array.
If this is the searched element then the search is terminated as the value is
found.
If the middle element in smaller than the value to search then the higher half
of the array is used (all element larger than the middle value) and the search
is performed again.
This is done until the searched element is either found or the remaining array
has only 1 element left.
Support
To support you with implementing the method there are unit tests in
<
<<
BinarySearchTest
>
>>. The unit tests are disabled at the start. To use them
you have to enable them.
Further Challenges
If you solved this kata already and want a new challenge you can solve this
kata with one of the following constraints:
* If you implemented the binary search with a recursive algorithm then create
an iterative implementation.
* If you implemented the binary search with an iterative algorithm then create
a recursive implementation.
* Implement the method without using an additional method.
* To implement a binary search in a generic way (using generics) use the kata
{{{
https://java-dojo.github.io/advanced-binary-search}Advanced Binary Search}}.
Development Requirements
To perform this kata you need a JDK 8 and Maven 3.3.x.
References
*
{{{
http://rosettacode.org/wiki/Binary_search}Rosetta Code}}
src/site/markdown/index.md.vm
0 → 100644
View file @
ecac4f00
#
Task
Your task is to implement the method `search` in the class `BinarySearch`.
#
Specification
The method `search` searches over a given array of `int`s and returns `true`, if
the value to search for is found.
Implement a binary search. If needed you can add further (private) methods to
the class `BinarySearch`.
#
Algorithm
To perform a binary search you test the element in the middle of the (sorted)
array.
If this is the searched element then the search is terminated as the value is
found.
If the middle element in smaller than the value to search then the higher half
of the array is used (all element larger than the middle value) and the search
is performed again.
This is done until the searched element is either found or the remaining array
has only 1 element left.
#
Support
To support you with implementing the method there are unit tests in
`BinarySearchTest`. The unit tests are disabled at the start. To use them you
have to enable them.
#
Further Challenges
If you solved this exercise already and want a new challenge you can solve this
exercise with one of the following constraints:
* If you implemented the binary search with a recursive algorithm then create an
iterative implementation.
* If you implemented the binary search with an iterative algorithm then create a
recursive implementation.
* Implement the method without using an additional method.
* To implement a binary search in a generic way (using generics) use the
exercise [Advanced Binary Search][abs].
#
Development Requirements
To perform this exercise you need a JDK 8 and Maven 3.3.x.
#
References
* [Rosetta Code][rcbs]
[abs]: https://java-dojo.github.io/advanced-binary-search "Advanced Binary Search"
[rcbs]: http://rosettacode.org/wiki/Binary_search "Rosetta Code - Binary Search"
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment