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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T21:42:57+00:00 2026-05-20T21:42:57+00:00

Given a sequence of 16 bits, I want to recursively reverse these bits. For

  • 0

Given a sequence of 16 bits, I want to recursively reverse these bits.
For example, 1001 1110 0010 0110 becomes 0110 0100 0111 1001.

I only have access to ADD, AND and NOT.
The subroutine accepts 2 parameters, the number of bits remaining to be reversed and the bit values. It returns the result.

I’m trying to think of ways to do this. One thing that’s popped into my head is having a sequence of bits : 0000 0000 0000 0001 to start, and adding it with itself the number of bits left to be processed left -1 times, then anding these bits with the passed in bit pattern. The problem is this seems very ineficient, and also I’m not sure how I would store the result to reverse the bits.

Any hints on this? It is homework, so just hints please 🙂

  • 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-20T21:42:58+00:00Added an answer on May 20, 2026 at 9:42 pm

    You’ve already figured out you can use ADD to shift left (adding a value to itself). So you can repeatedly shift and then AND with a constant with 1 high bit set to extract the bits from highest to lowest. You can build OR out of AND and NOT (via DeMorgan’s law), so you can recombine those bits from lowest to highest by or-ing together single bits starting with a constant 1 and shifting that left as you go, which will give you the reversed bit sequence.

    Turning that into a recursive process is fairly straight-forward

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

Sidebar

Related Questions

Given an arbitrary sequence of points in space, how would you produce a smooth
Given the URL (single line): http://test.example.com/dir/subdir/file.html How can I extract the following parts using
Suppose I have a sequence x1,x2,x3.....xn, and I want to find the longest continuous
Given a specific DateTime value, how do I display relative time, like: 2 hours
Given a Python object of any kind, is there an easy way to get
Given a select with multiple option's in jQuery. $select = $(<select></select>); $select.append(<option>Jason</option>) //Key =
Given a DateTime representing a person's birthday, how do I calculate their age in
Given an absolute or relative path (in a Unix-like system), I would like to
Given 2 rgb colors and a rectangular area, I'd like to generate a basic
Given a (source) patch file, what's the easiest way to apply this patch on

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.