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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T02:26:05+00:00 2026-05-27T02:26:05+00:00

Sorting five integers using bitwise or comparison operators can be achieved by first getting

  • 0

Sorting five integers using bitwise or comparison operators can be achieved by first getting the highest number then the second highest then the third and so on.

Here is my code in getting the highest number:

#include <stdio.h>

int main() {
    int a, b, c, d, e;
    int aa, bb, cc, dd, ee;

    a = 4; b = 2; c = 5; d = 1; e = 3;

    aa = (a > b) ?
         ((a > c) ? ((a > d) ? ((a > e) ? a : e) : ((d > e) ? d : e)) :
                    ((c > d) ? ((c > e) ? c : e) : ((d > e) ? d : e))) :
         ((b > c) ? ((b > d) ? ((b > e) ? b : e) : ((d > e) ? d : e)) :
                    ((c > d) ? ((c > e) ? c : e) : ((d > e) ? d : e)));


    printf("highest: %d\n", aa);
    return 0;
}

I think getting the second, third, forth and fifth highest number could be possible using this method.

Is there any other way in getting the median of five integers using comparison/bitwise operators? any other combinatorial method might be valid.

By the way, I’m going to implement this algorithm in hardware.

Using combinatorial method in sorting will be fast rather than using a state machine.

  • 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-05-27T02:26:06+00:00Added an answer on May 27, 2026 at 2:26 am

    One way to think about it is to consider the 10 comparison operations between the 5 numbers as your binary inputs. Then you have options:

    1. Draw a 10-input Karnaugh map and simplify the logic where possible.
    2. Build a 10-bit number as an index into a table.

    Some of the possibilities will never occur, so I’m sure there’s some simplification possible. For instance if (a>b) and (b>c) then (a>c) will always be true. Which will help with approach #1 and generates an error case in approach #2.

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

Sidebar

Related Questions

Possible Duplicate: Sorting a hash in Ruby by its value first then its key.
Normally sorting based on keys and then iterating a hash can be done as
After reading Guido's Sorting a million 32-bit integers in 2MB of RAM using Python
This recent question about sorting randomly using C# got me thinking about the way
I'm working on sorting a list of objects, and unfortunately, I'm not quite getting
Question is about sorting std::vector<myclass> using function sort from STL's algorithms class. Standard way
iam using leigeber's sorting javascript to sort my data on my page......i took the
I am sorting datatable datewise like TableWithOnlyFixedColumns.DefaultView.Sort = TradingDate asc; then assign this datatable
What is the fastest sorting algorithm for a large number (tens of thousands) of
I'm doing sorting of a list of elements, using: jQuery.fn.sort = function() { return

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.