Skip to main content
format
Source Link
ryan
  • 4.5k
  • 1
  • 15
  • 41

Given Array A$A$ of size n$n$ that contains all the integer values $[0,n]$ except one.

In this question we assume that the time we need to check one bit $j$ in number $A[i]$ is $O(1)$,and to check the number $A[i]$ is $O(\log n)$.

Find an algorithm that finds the missing number in $O(n)$.

So creating a trivial counter array and searching for a 0 count wouldn't help - it would be $O(\log n)$.

I also thought about counting the bits and finding the missing one, but that wouldn't help either.

Given Array A of size n that contains all the integer values $[0,n]$ except one.

In this question we assume that the time we need to check one bit $j$ in number $A[i]$ is $O(1)$,and to check the number $A[i]$ is $O(\log n)$.

Find an algorithm that finds the missing number in $O(n)$.

So creating a trivial counter array and searching for a 0 count wouldn't help - it would be $O(\log n)$.

I also thought about counting the bits and finding the missing one, but that wouldn't help either.

Given Array $A$ of size $n$ that contains all the integer values $[0,n]$ except one.

In this question we assume that the time we need to check one bit $j$ in number $A[i]$ is $O(1)$,and to check the number $A[i]$ is $O(\log n)$.

Find an algorithm that finds the missing number in $O(n)$.

So creating a trivial counter array and searching for a 0 count wouldn't help - it would be $O(\log n)$.

I also thought about counting the bits and finding the missing one, but that wouldn't help either.

Tweeted twitter.com/#!/StackCompSci/status/467788636734631936

Given Array A of size n that contains all the integer values [0,n]$[0,n]$ except one.

In this question we assume that the time we need to check one bit j$j$ in number A[i]$A[i]$ is O(1)$O(1)$,and to check the number A[i]$A[i]$ is O(log n)$O(\log n)$.

Find an algorithm that finds the missing number in O(n)$O(n)$.

So creating a trivial counter array and searching for a 0 count wouldn't help - it would be $O(\log n)$.

I also thought about counting the bits and finding the missing one, but that wouldn't help either.

Given Array A of size n that contains all the integer values [0,n] except one.

In this question we assume that the time we need to check one bit j in number A[i] is O(1),and to check the number A[i] is O(log n).

Find algorithm that finds the missing number in O(n).

Given Array A of size n that contains all the integer values $[0,n]$ except one.

In this question we assume that the time we need to check one bit $j$ in number $A[i]$ is $O(1)$,and to check the number $A[i]$ is $O(\log n)$.

Find an algorithm that finds the missing number in $O(n)$.

So creating a trivial counter array and searching for a 0 count wouldn't help - it would be $O(\log n)$.

I also thought about counting the bits and finding the missing one, but that wouldn't help either.

Source Link
Gil
  • 287
  • 1
  • 2
  • 10

Find The missing number in range [0,n]

Given Array A of size n that contains all the integer values [0,n] except one.

In this question we assume that the time we need to check one bit j in number A[i] is O(1),and to check the number A[i] is O(log n).

Find algorithm that finds the missing number in O(n).