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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T20:51:27+00:00 2026-06-14T20:51:27+00:00

Design and analyze a linear time algorithm to determine whether there exists an element

  • 0

Design and analyze a linear time algorithm to determine whether
there exists an element in a list of n elements which repeats itself
at least n/10 times in the list.

How can I do this? I’m posting my own idea as an answer.

  • 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-14T20:51:29+00:00Added an answer on June 14, 2026 at 8:51 pm

    I assume the elements are comparable.

    Perform a selection algorithm for the: n/10th, 2n/10th, …, 9n/10th, 10(n/10)th smallest elements1

    These are your candidates. Check the #occurrences for each of them, and if one of them repeats at least n/10 times the answer is true. Otherwise, it is false.

    Proof:

    If an element appears at least n/10 times, then it must “intersect” with k*n/10 for some k (in a sorted list)2. Thus, this element will be chosen as a “candidate”, and you will later discover (by counting) exactly how many times it appears, and will return true.

    If no element is repeated n/10 times, the algorithm will trivially return false in the last step of checking each candidate.

    Complexity:

    Each selection algorithm is O(n), and it is done 10 times. Also for each candidate requires linear scan on the list, which is also O(n) totaling in O(n) overall—but with terrible constants.


    Explanations:

    (1) Selection algorithm will find the element which would be in the index n/10, 2n/10,…9n/10 in a sorted list, and the algorithm itself is only O(n)

    (2) Let’s look at the example of [1,2,..,100,100,..,100] (11 times 100).
    Note that the list is sorted and the element 100 appears in: list[9*n/10] (index 9*n/10). The idea of the selection algorithm is, that—even if you shuffle the list—select(list,9*n/10) will always return the same element—in this case 100—since it is the 9n/10th element in the sorted list (this is what the algorithm does).

    Now, you can see that for each element (let it be e) that repeats n/10 times, there is some index i such that in the sorted version of the list, all elements in indices i,i+1,...,i+n/10 will be e. One of these indices must be one of k*n/10 for some k (convince yourself why!). Thus, the selection algorithm on k*n/10 will yield e.

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

Sidebar

Related Questions

Design an algorithm that, given a list of n elements in an array, finds
Does anyone know if there exists either an algorithm for (or an implementation of)
Design requirement: Show a list of items the user can pick from After having
Design wise and performance wise which approach is recommended for handling multiple Zeromq sockets
By design I'm expecting a DuplicateKeyExeception from time to time. Is it possible to
during design time i cannot figure out how to resize the datagridview columns in
This all started because I am trying to FxCop analyze my assembly, which references
I'm implementing a pthread replacement library which is extremely lightweight. There are several reasons
at design time I could have declare a variable like this: char szDesignTimeArray[120][128]; The
Does anybody know of any tool which can analyze a code base and advise

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.