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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T00:48:37+00:00 2026-05-20T00:48:37+00:00

Given an array, A, containing, in some order, all but one of the k-bit

  • 0

Given an array, A, containing, in some order, all but one of the k-bit non-negative integers find the missing integer with the following constraint:

You are allowed to do only two things with one of these integers:

  1. Obtain the value of its ith bit
  2. Swap them with one another in the array

For example: if k is 3 the array will contain all but one the integers 0 through 7 inclusive, the task is to find the missing integer.

  • 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-20T00:48:37+00:00Added an answer on May 20, 2026 at 12:48 am

    You should check that each bit (for example, if k = 3 you need to check that all 3 bits) are present 2^k-1 times as 0 & 1.

    If you are sure of the invariant of the list that you outlined (only one number is missing and there are no duplicates) – sure that it always holds – then you could simply check only one, arbitrary bit holds the condition outlined above.

    For example, say that the invariant holds, k = 3, and you have the list [0-7], excluding 6.
    For each number in the list, get its first bit (least significant) and do the following:

    if bit value = 0 then zeroValues++;
    if bit value = 1 then oneValues++;

    zeroValues should equal oneValues and both should equal 2^k-1, in this case 4.

    Edit: Rereading your question, you’re looking for the entire number. In order to find the whole integer value that you are looking for, just do the procedure for all bits. For each bit you do it, you will find either a 0 value or 1 value missing. The missing value is the bit value in the result integer. Doing this for all bits will find the entire bit representation of your integer.

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

Sidebar

Related Questions

Consider this problem: You are given an array containing positive integers. All the integers
Saw this question recently: Given 2 arrays, the 2nd array containing some of the
You're given an array of size n, containing arbitrary boolean values. What is the
This problem is taken from interviewstreet.com Given array of integers Y=y1,...,yn, we have n
Given an array of integers A[1...n-1] where N is the length of array A.
Given an array. How can we find sum of elements in index interval (i,
I'm tring to find the maximum weight subsequence of an array of positive integers
I have an array containing words, some of them with accents. I want to
given an array: array = [16 16 16 22 23 23 23 25 52
Given an Array A of n subArrays Sn, how can I select the Array

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.