Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6678495
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T04:15:00+00:00 2026-05-26T04:15:00+00:00

I have a small doubt here… If I know that a search element in

  • 0

I have a small doubt here…

If I know that a search element in a list ,say containing 32 elements sorted in order, is appearing within first four positions,

which is the best searching algorithm.

Linear search at least needs 4 iteration….
Binary search at least 5 iteration
How about binary search tree .. does it give better solution in this case or is equal to binary search…

I believe Linear search will be better for such circumstances ..

can anybody confirm this please ?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-26T04:15:01+00:00Added an answer on May 26, 2026 at 4:15 am

    If you know the location is in the first 4 positions than a linear search is better since you’ll have to test no more than 4 elements. With a binary search lg 32 = 5 so you’ll have to test at most 5 elements.

    In addition, for a small amount of elements like this, the time difference is negligible and you’ll be best served by keeping it simple and doing a linear search.

    You may also be able to use a HashTable or HashSet for O(1) time but then again, for a small amount of data, a linear search would probably be faster than executing a hash function.

    And if the small difference really does matter, I would suggest measuring it in the environment where it will run.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Have a small doubt with static method. Documentation says that Static method can't access
I have a small architecture doubt about organizing code in separate functional units (most
I have small utility that does some processing on a file and changes the
I have small web app that generate PDF files as a report. I'm trying
I have a small doubt regarding network connection procedure in Android. My scenario is
I have a small doubt regarding BEFORE INSERT TRIGGER in oracle, my trigger looks
I have a small doubt in CCAnimation. Is there any difference between the code1
I have a small doubt I have following code bool res= false; if(cond1) {
I have been using Hibernate/Spring. I have a small doubt. If we get 1000
I have a small doubt, so apologies first. I am creating an iPhone application

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.