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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T19:12:41+00:00 2026-06-02T19:12:41+00:00

The following algorithm checks whether a number is prime: Given a number n,loop over

  • 0

The following algorithm checks whether a number is prime:

Given a number n,loop over all numbers smaller than n and check whether they divide n. 
If one of them divides n, answer no. Otherwise, answer yes.

Now, I have to analyse the number of division operations performed by the algorithm as a function of the length of its input in the following two cases:

1) The number is encoded in unary (i.e, 4 is 1111). How do I show that the number of divisions is polynomial?

2) The number is encoded in binary (i.e, 4 is 100). How do I show that the number of divisions is exponential?

  • 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-02T19:12:42+00:00Added an answer on June 2, 2026 at 7:12 pm

    Suppose we have n 1‘s strung together (notated 1^n). n is the length of our input, obviously. We will divide all the integers from 11, 111, … ,1^(n-1) into 1^n. How many numbers will you be dividing into 1^n, as a function of n? Is this a polynomial?

    Note that it takes log_2(x) (log base 2 of x) bits to represent x, approximately, in binary. Also note that we will be performing x-2 divisions (2, 3, 4, 5, … , x-1 will be divided into x). So, for log_2(x) bits we use x-2 divisions. Suppose, instead, that we let n be the size of our input. So we have n = log_2(x). How many divisions will we take, then, in terms of a function of n?

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

Sidebar

Related Questions

My current algorithm to check the primality of numbers in python is way to
I was wondering if the following algorithm to check if a point is inside
the following algorithm add users to a company array. I want to add a
Here's the following algorithm: int encryption(int a, int b) { short int c, c2;
My company uses the following algorithm to hash passwords before store it in the
I am trying to implement the following algorithm using the divide and conquer method
I have a SP that has the following algorithm. IF <SomeCondition> BEGIN SELECT *
I am currently using the following algorithm to search on my iPhone app: NSRange
We are doing some 32bit * 32bit multiplication using the following algorithm Let us
I'm running perl -ple '$_=length' datafile The datafile contains the following: algorithm student government

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.