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 a sequence (for example a string Xa), I want to get the next
I've got a sequence of bits, say 0110 [1011] 1111 Let's say I want
Given the following sequence: normal %(b)BOLD% normal I want to transform this into the
Given the following model, I want to index the fields (sequence,stock) class QuoteModel(models.Model): quotedate
Given a sequence of objects (I'll use strings in this example for simplicity) I'd
Given a sequence of eithers Seq[Either[String,A]] with Left being an error message. I want
Given sequence : [1,A,B,C,2,F,K,L,5,6,P,I,E] The numbers represent items that I identify as headers, whereas
Given a sequence of data (it may have duplicates), a fixed-sized moving window, move
I would like to know if anyone sees a pattern in the sequence given
Given the following sequence diagram, how to express the equivalent in a UML communication

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.