Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Add exponential search algorithm#6218

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Open
vieriloh wants to merge1 commit intoTheAlgorithms:master
base:master
Choose a base branch
Loading
fromvieriloh:feature/exponential-search

Conversation

vieriloh
Copy link

This pull request adds a new implementation of the Exponential Search algorithm under the searchs package (com.thealgorithms.searchs).
Exponential Search is an efficient algorithm for searching sorted arrays. It works by finding a range where the element is likely to be and then performing Binary Search within that range.

Key Details:

Method: search(int[] arr, int x)

Includes a helper binarySearch method

Added test logic in main method for quick verification

This feature is part of my assignment for software configuration and quality practices, demonstrating version control, branching, and collaborative workflow.

@codecov-commenter
Copy link

Codecov Report

Attention: Patch coverage is0% with21 lines in your changes missing coverage. Please review.

Project coverage is 73.70%. Comparing base(f53bc00) to head(8b86539).

Files with missing linesPatch %Lines
...a/com/thealgorithms/searchs/ExponentialSearch.java0.00%21 Missing⚠️
Additional details and impacted files
@@             Coverage Diff              @@##             master    #6218      +/-   ##============================================- Coverage     73.79%   73.70%   -0.09%  Complexity     5303     5303              ============================================  Files           672      673       +1       Lines         18357    18378      +21       Branches       3549     3554       +5     ============================================  Hits          13546    13546- Misses         4264     4285      +21  Partials        547      547

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report?Share it here.

🚀 New features to boost your workflow:
  • ❄️Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Copy link
Collaborator

@DenizAltunkapanDenizAltunkapan left a comment
edited
Loading

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

There needs to be a fix for the unused import, the addition of a private constructor to the utility class, and the inclusion of curly braces for all 'if'/'else' blocks to improve readability and consistency and pass the actions that failed

@@ -0,0 +1,48 @@
package com.thealgorithms.searchs;

import java.util.Arrays;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

I think there might be an unused import. Is this necessary?


import java.util.Arrays;

public class ExponentialSearch {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

I think you need to insert a private constructor because the default constructor from the Object class is public

int n = arr.length;

// If the element is present at the first position
if (arr[0] == x) return 0;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

It's recommended to use curly braces for 'if' blocks, even for single statements

while (low <= high) {
int mid = low + (high - low) / 2;

if (arr[mid] == x) return mid;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

there are also here curly braces needed


if (arr[mid] == x) return mid;

if (arr[mid] < x) low = mid + 1;
Copy link
Collaborator

@DenizAltunkapanDenizAltunkapanApr 12, 2025
edited
Loading

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

It's necessary to use curly braces for 'if' and 'else' blocks, even for single statements

@siriak
Copy link
Member

Please also check these gates
image

@DenizAltunkapan
Copy link
Collaborator

DenizAltunkapan commentedApr 12, 2025
edited
Loading

Please also check these gatesimage

these gates should pass after he implements the requested changes above but i recommend you to run clang formatter manually@vieriloh

@huseynovvusal
Copy link
Contributor

huseynovvusal commentedApr 17, 2025
edited
Loading

Hello,@vieriloh! You can simply remove the unusedjava.util.Arrays import, adda private constructor to the utils class so it can’t be instantiated, and wrap all yourif-else blocks in braces. Hope it will help you. :)

@github-actionsGitHub Actions
Copy link

This pull request has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contribution!

Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment
Reviewers

@DenizAltunkapanDenizAltunkapanDenizAltunkapan requested changes

@yanglbmeyanglbmeAwaiting requested review from yanglbmeyanglbme is a code owner

@vil02vil02Awaiting requested review from vil02vil02 is a code owner

@BamaCharanChhandogiBamaCharanChhandogiAwaiting requested review from BamaCharanChhandogiBamaCharanChhandogi is a code owner

@alxkmalxkmAwaiting requested review from alxkmalxkm is a code owner

@siriaksiriakAwaiting requested review from siriaksiriak is a code owner

Requested changes must be addressed to merge this pull request.

Assignees
No one assigned
Labels
Projects
None yet
Milestone
No milestone
Development

Successfully merging this pull request may close these issues.

5 participants
@vieriloh@codecov-commenter@siriak@DenizAltunkapan@huseynovvusal

[8]ページ先頭

©2009-2025 Movatter.jp