1 votes 1 votes An array of unknown size is filled with special symbols let's say '#'. Time required to find the size of array is 1) O(1) 2) O(logn) 3) O(n) 4) O((logn)2) srivivek95 asked Jan 25, 2018 srivivek95 646 views answer comment Share Follow See all 15 Comments See all 15 15 Comments reply Diksha Aswal commented Jan 25, 2018 reply Follow Share is it 2) ? 0 votes 0 votes hs_yadav commented Jan 25, 2018 reply Follow Share I think... it is O(1)... 0 votes 0 votes Diksha Aswal commented Jan 25, 2018 reply Follow Share how ? 0 votes 0 votes srivivek95 commented Jan 25, 2018 reply Follow Share @Diksha Aswal @ hs_yadav Approach? 0 votes 0 votes Ashwin Kulkarni commented Jan 25, 2018 reply Follow Share I think it would take O(logn) Traverse it exponentially, i.e traverse with modification in Binary search 0 votes 0 votes Diksha Aswal commented Jan 25, 2018 reply Follow Share yes... same approach as Ashwin's 0 votes 0 votes hs_yadav commented Jan 25, 2018 reply Follow Share let S is an array...then...let starting address is 100 and having 5 element of 1 byte...then &S+1 will return 100+5*1=105....now conside.. S=100 calculate....105-100= 5/size of an element ..... and for given question this ia character...therefro we will assume size is 1 byte.. 0 votes 0 votes srivivek95 commented Jan 25, 2018 reply Follow Share 1 -> 2 -> 4 -> 8 -> 16 ->32 ...... -> 1024 Now, If the last element is 513 (OR 1023 OR 768 whichever is the worst case), then how to proceed? 0 votes 0 votes joshi_nitish commented Jan 25, 2018 reply Follow Share yes, it will take O(logn) time. 0 votes 0 votes srivivek95 commented Jan 25, 2018 reply Follow Share @ joshi_nitish how? 0 votes 0 votes shriram s 1 commented Jan 25, 2018 reply Follow Share https://stackoverflow.com/questions/21973619/interview-qgiven-an-input-array-of-size-unknown-with-all-1s-in-the-beginning-a The above is a similar kind of problem where they have mentioned as O(n). 0 votes 0 votes hacker16 commented Jan 25, 2018 reply Follow Share (d) option...?? @srivivek 0 votes 0 votes srivivek95 commented Jan 25, 2018 reply Follow Share No. Answer given is O(logn) But I am not getting it 0 votes 0 votes Diksha Aswal commented Jan 25, 2018 reply Follow Share apply binary search and move towards right ..you will reach to the end i.e. to 'n' in O(logn) time. 0 votes 0 votes srivivek95 commented Jan 25, 2018 reply Follow Share @ Diksha Aswal 1 -> 2 -> 4 -> 8 -> 16 ->32 ...... -> 1024 Now, If the last element(#) is at 513 (OR 1023 OR 768 whichever is the worst case), then how to proceed? 0 votes 0 votes Please log in or register to add a comment.