hmm ok
my mistake of reading
On Tue, Aug 23, 2011 at 6:56 PM, saurabh singh wrote:
> Well sir I am fully aware why this is hapening.Kindly reread what I wrote
> .*"what if we are given only the address of the array".*
> I personaly feel anyone who asked the question never expected this to
Well sir I am fully aware why this is hapening.Kindly reread what I wrote
.*"what if we are given only the address of the array".*
I personaly feel anyone who asked the question never expected this to be the
answer.(using sizeof).
On Tue, Aug 23, 2011 at 2:42 PM, sagar pareek wrote:
> @saura
@saurabh
u are getting sizeof(a)/sizeofa[0] =1 coz fiest one is pointer and second
one is integer...both's size is 4
do it
without passing
http://www.ideone.com/8olTP
On Tue, Aug 23, 2011 at 1:28 PM, vikas wrote:
> nopes, you need to know where the hell it ends even if this is a
> string , i
nopes, you need to know where the hell it ends even if this is a
string , it ends with convention of ending 0. in case it is stream ,
we know the data length. in case of array, above mentioned approach
should work. sizeof(arr)/sizeof(arr[0])
if you are given only a pointer and no length, you c
Just a small code to back up my point...
http://www.ideone.com/woRiT
On Tue, Aug 23, 2011 at 7:33 AM, saurabh singh wrote:
> That would take all the fun awaywhat if you are given only the address
> of the array?This wont work in that case
>
>
> On Mon, Aug 22, 2011 at 10:39 PM, asdqwe wrote
That would take all the fun awaywhat if you are given only the address
of the array?This wont work in that case
On Mon, Aug 22, 2011 at 10:39 PM, asdqwe wrote:
> If i am not wrong, the only possible solution can be
> len=sizeof(arr)/sizeof(arr[0])
> i.e. find the length from the array itself
If i am not wrong, the only possible solution can be
len=sizeof(arr)/sizeof(arr[0])
i.e. find the length from the array itself.
On Aug 22, 9:01 pm, saurabh singh wrote:
> @dave or anyone??? response please
>
>
>
>
>
>
>
>
>
> On Sun, Aug 21, 2011 at 12:43 PM, saurabh singh wrote:
> > kkk...
@dave or anyone??? response please
On Sun, Aug 21, 2011 at 12:43 PM, saurabh singh wrote:
> kkk...not sure
> assume no number is greater than 1000(I mentioned There has to be some
> additional constraints to make the problem solvable)
> Now check 1st element if not the desired element ke
kkk...not sure
assume no number is greater than 1000(I mentioned There has to be some
additional constraints to make the problem solvable)
Now check 1st element if not the desired element keep multiplying with 2 the
previous range till either one of these condition is satisfied
*1.An exception
@Saurabh: Here's a challenge for you. Suppose I give you an array of
length 1024 with the first 987 elements in sorted order and the
remaining elements unsorted. Knowing that you can probe any of the
1024 elements, without making explicit use of the fact that you know
that 987 elements are sorted,
@dave may be its a bit offtopic,(and may be stupid) but if the numbers are
in a small range (say 1 to 1000) isn't the probability that the absolute
garbage value would be greater than the array elements(assuming garbage to
be bits of random 0's and 1's)?Assuming we have not entered into some other
thanks for pointing it out
On Sat, Aug 20, 2011 at 12:16 AM, Dave wrote:
> @Sagar: So far so good, but you are not guaranteed to get an
> exception. Example, int a[987] is followed in memory by char
> b[1000], which is a dictionary. You won't detect an exception
> until you get to at least a
@Sagar: So far so good, but you are not guaranteed to get an
exception. Example, int a[987] is followed in memory by char
b[1000], which is a dictionary. You won't detect an exception
until you get to at least a[262144] (2 to the 18th). But you will pick
up plenty of garbage which may throw off
Well in that case additive approach will work.
Sanju
:)
--
You received this message because you are subscribed to the Google Groups
"Algorithm Geeks" group.
To post to this group, send email to algogeeks@googlegroups.com.
To unsubscribe from this group, send email to
algogeeks+unsubscr...@goo
Well
sorry but i forget to mention exceptions in the solution.
Here is the complete solution :-
The key idea here is to simultaneously do a binary search
for the end of the array as well as the key. We try to look for A[2k ] in
the
k-th step and catch exceptions for successive values of k till eit
@Everyone: The problem says that the array is of UNKNOWN length, but
all of the solutions presented assume that the array is of INFINITE
length. Suppose, e.g., that the length is 987, but you don't know
that. Then it will be meaningless to probe at 1, 10, 100, 1000, etc,
or 1, 2, 4, ..., 512, 1024
16 matches
Mail list logo