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 7899209
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T08:38:26+00:00 2026-06-03T08:38:26+00:00

I have an Integer array, value[] . It may be of any length. I

  • 0

I have an Integer array, value[]. It may be of any length.

I need to find the smallest number. I am working on a problem in interview street. I am getting an error as my Time Exceeded. I need to increase the speed of computing the smallest value, as iterating gets worse.

I am interested in using Java collections or anything else, so anyone give some suggestions to improve the code.

int mini=value[0];
for (int i = 1; i < noinps; i++) {
    if(mini>value[i]) {
        mini=value[i];
    }
}
System.out.println(mini);
  • 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-06-03T08:38:27+00:00Added an answer on June 3, 2026 at 8:38 am

    The algorithm seems fine for finding the minimum value of an array. If nothing is known about the possible elements contained in the arraym, you need to inspect each element, so your performance is linear (directly proportional to the number on elments in the array).

    If the elements are fully ordered ordered, you can just look up the first (or last, dependng or ordering) element (constant time performance)

    If the elements are semi-ordered (e.g. heap structure), you could find it via a binary search-like technique (log(n) performance)

    If the elements are unordered, but you know they cannot be less than a certain value, you can stop the search if you find the smallest possible value.

    So back to the timeout problem: if the elements are unordered and there are no other restrictions on them, your algorithm is fine, so the timeout must come form some other part of the program (e.g. you are trying to read from the console, but the data is in a file)

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

Sidebar

Related Questions

Given an integer array, i need to find which number occurred most number of
Say that I have an integer-indexed array of length 400, and I want to
I can't figure this interview question. You have an array of integers. You need
I have a pointer to integer array of 10. What should dereferencing this pointer
I have a array of integer numbers (say 1,2,3,4,5 or 1,2,3, ... 10 or
I have an array of integers like these; dim x as integer()={10,9,4,7,6,8,3}. Now I
This problem is taken from interviewstreet.com Given array of integers Y=y1,...,yn, we have n
an input integer is limited by an array of data: [Maski, possible-value-i], (i from
I have an integer array of size 50. So, as you know, initially the
I am programming c on linux and I have a big integer array, how

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.