Thread: Number repeated thrice

  1. #16
    Registered User
    Join Date
    Oct 2008
    Posts
    1,262
    Quote Originally Posted by anirban View Post
    So is the problem not solvable in linear time!!! ???
    As stated several times before, only when there's a constraint on the input, for instance a small range allowed as integers (eg. each number in the input must be greater than 0 and less than or equal to 100).

  2. #17
    spurious conceit MK27's Avatar
    Join Date
    Jul 2008
    Location
    segmentation fault
    Posts
    8,300
    Quote Originally Posted by anirban View Post
    So is the problem not solvable in linear time!!! ???
    Think outside the box.
    C programming resources:
    GNU C Function and Macro Index -- glibc reference manual
    The C Book -- nice online learner guide
    Current ISO draft standard
    CCAN -- new CPAN like open source library repository
    3 (different) GNU debugger tutorials: #1 -- #2 -- #3
    cpwiki -- our wiki on sourceforge

  3. #18
    Registered User
    Join Date
    Mar 2009
    Posts
    48
    The question said : Constant Extra Space.

    Did not say you must use O(n) space.
    It did not say you cannot sort data.

    Why not use non comparison based sorting techniques?

  4. #19
    C++ Witch laserlight's Avatar
    Join Date
    Oct 2003
    Location
    Singapore
    Posts
    28,413
    Quote Originally Posted by zalezog
    The question said : Constant Space.

    Did not say you must use O(n) space.
    It did not say you cannot sort data.

    Why not use non comparison based sorting techniques?
    That would require a non-constant amount of extra space.
    Quote Originally Posted by Bjarne Stroustrup (2000-10-14)
    I get maybe two dozen requests for help with some sort of programming or design problem every day. Most have more sense than to send me hundreds of lines of code. If they do, I ask them to find the smallest example that exhibits the problem and send me that. Mostly, they then find the error themselves. "Finding the smallest program that demonstrates the error" is a powerful debugging tool.
    Look up a C++ Reference and learn How To Ask Questions The Smart Way

  5. #20
    Registered User
    Join Date
    Oct 2008
    Posts
    1,262
    Quote Originally Posted by laserlight View Post
    That would require a non-constant amount of extra space.
    And it wouldn't be doable in O(n), I think. If I understand the poster correctly.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Guess My Number (Need help)
    By dhardin in forum C++ Programming
    Replies: 5
    Last Post: 12-10-2009, 12:59 PM
  2. Need help with this compiler error
    By Evangeline in forum C Programming
    Replies: 7
    Last Post: 04-05-2008, 09:27 AM
  3. Prime number program problem
    By Guti14 in forum C Programming
    Replies: 11
    Last Post: 08-06-2004, 04:25 AM
  4. help with a source code..
    By venom424 in forum C++ Programming
    Replies: 8
    Last Post: 05-21-2004, 12:42 PM
  5. Random Number problem in number guessing game...
    By -leech- in forum Windows Programming
    Replies: 8
    Last Post: 01-15-2002, 05:00 PM