-
Notifications
You must be signed in to change notification settings - Fork 286
Sentinel Linear Search #337
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 our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
Implement Sentinel Linear Search algorithm with benchmarking.
💎 Code Quality Check Results❌ Missing Complexity AnalysisThese files don't include time/space complexity:
Required: Add comments explaining time and space complexity (e.g., ❌ Missing Algorithm DescriptionThese files don't explain what the algorithm does:
Required: Add a description explaining the algorithm, its purpose, and how it works 📚 Quality StandardsTo maintain high quality, every contribution should include:
💡 Example Template"""
Binary Search Algorithm
Description: Searches for a target value in a sorted array using divide-and-conquer
Time Complexity: O(log n) - halves search space each iteration
Space Complexity: O(1) - only uses constant extra space
"""
def binary_search(arr, target):
# Initialize pointers
left, right = 0, len(arr) - 1
while left <= right:
mid = (left + right) // 2
# Check if target found
if arr[mid] == target:
return mid
# Search right half
elif arr[mid] < target:
left = mid + 1
# Search left half
else:
right = mid - 1
return -1 # Not found
# Test cases
if __name__ == "__main__":
test_arr = [1, 3, 5, 7, 9]
print(binary_search(test_arr, 5)) # Output: 2
print(binary_search(test_arr, 6)) # Output: -1🔧 How to Fix
💪 You've Got This!These checks help maintain quality and make your contribution more valuable to learners. Thank you for taking the time to improve! 🙏 Quality over quantity - let's build something amazing together! 🌟 |
|
🎉 Welcome to Hacktoberfest 2025, @Yaser-123! 🎃 Thank you for your first contribution to our DSA repository! Here's what happens next: 🔍 Automatic Checks
📋 Next Steps🎯 Great job! Your code compiled successfully. Maintainers @Karanjot786 and @Pradeepsingh61 will review your PR soon. 🎁 What You Get
💡 Tips for Success
Welcome to the community! 🚀 |
🤖 Automated PR Status🔍 Code Validation✅ Passed - File naming and structure look good! 🧪 Compilation Tests✅ Passed - All code compiles successfully! 📋 Overall Status🎉 Ready for Review - Your PR has passed all automated checks! This comment was generated automatically. Checks will re-run when you push new commits. |
Karanjot786
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It is good to go @Pradeepsingh61 now you can merge it and @Yaser-123 thank for this PR
Sentinel Linear Search
Python implementation of Sentinel Linear Search algorithm. Optimizes standard linear search by eliminating boundary checks using a sentinel value. Includes performance comparison and test cases.
Don't forget to add the
hacktoberfestandhacktoberfest-acceptedlabels!