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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T18:27:27+00:00 2026-06-09T18:27:27+00:00

I have an array with 32 numbers. Initially, every number is 0, although it’s

  • 0

I have an array with 32 numbers. Initially, every number is 0, although it’s probably not important.

At any time I can change one number in this array.

I want to quickly find the minimum value and its index after such an update. Is there a way to do it in O(1) time?

  • 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-09T18:27:28+00:00Added an answer on June 9, 2026 at 6:27 pm

    almost everything you do on an array of size 32 is O(1). Linear scan requires 32 comparisons, which is in O(1)

    O(1) = constant number of ops. If the array is of size 32 (or any fixed size for the matter), the number of ops is indeed constant (Think of it this way: you can replace the linear scan with a chained if conditions instead of a loop:

    if (arr[0] < min), if (arr[1] < min) , ... if (arr[31] < min)

    For the thrill of it, regarding the general case for an array of size n, it is not possible with compare based algorithms.

    If it was, we could sort in O(n) using comparisons based algorithm:

    given an array A:
    max <- max(A)
    build an empty data structure as desired let it be `S`.
    for each element of A - insert it into S in a different index.
    while (S.min() <= max):
       idx <- S.findminIndex()
       print S.min()
       S.update(idx,max+1)
    

    Assuming each op in the above algorithm is O(1), and the loop iterates n times, your algorithm sorts A in O(n) – which cannot be done, since comparations based sorting are proved to be Omega(nlogn) problem

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

Sidebar

Related Questions

Lets say I have an array numbers that contains the following values: int numbers
I have an array of numbers: @numbers = 1,2,3,6,8,9,11,12,13,14,15,20 and I want to print
Consider the following scenario . I have an array of numbers: [ 1,2,3,4 ]
I have an array of phone numbers, and I need a fast way to
I have a PHP array with numbers of ID's in it. These numbers are
I have a array of integer numbers (say 1,2,3,4,5 or 1,2,3, ... 10 or
I have an array of prime numbers from 2 to 997. How do you
I have an array which contains 12 numbers and I want to save this
I have a nested array with valid numbers => data:- $validData = array(array(1 =>
I have an array of lists of numbers, e.g.: [0] (0.01, 0.01, 0.02, 0.04,

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.