Portal | Manuals | References | Downloads | Info | Programs | JCLs | Mainframe wiki | Quick Ref
IBM Mainframe Computers Forums Index
 
Register
 
IBM Mainframe Computers Forums Index Mainframe: Search IBM Mainframe Forum: FAQ Memberlist Profile Log in to check your private messages Log in
 
Binary Search elements in upper half

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> Mainframe Interview Questions
View previous topic :: :: View next topic  
Author Message
Girijesh

New User


Joined: 19 Sep 2008
Posts: 14

PostPosted: Sun Apr 05, 2009 4:40 pm    Post subject: Binary Search elements in upper half
Reply with quote

Hi , i was asked a question in CSC:
Binary search divides a table in 2 halves, how many elements in upper half and how many in lower half, if there are :
1. 25 elements, and
2. 26 elements
i am unable to find answer, please let me know

____________________________
Thanks
Back to top
View user's profile Send private message

CICS Guy

Senior Member


Joined: 18 Jul 2007
Posts: 2150
Location: At my coffee table

PostPosted: Sun Apr 05, 2009 7:01 pm    Post subject:
Reply with quote

I wonder.....
If you created a table with 25/26 entries consisting of two fields, a key and a sequence number and did a binary search that hit on the first attempt you could find which was the middle yourself.
I'd think that even if the keys were identical the search would always start in the middle.
Back to top
View user's profile Send private message
enrico-sorichetti

Global Moderator


Joined: 14 Mar 2007
Posts: 10326
Location: italy

PostPosted: Sun Apr 05, 2009 8:37 pm    Post subject: Reply to: Binary Search
Reply with quote

this is a mainframe collection of forums not a MATH one
the question is just nonsense


statistically there will always be a 50% probabilty ( odd and even occurrences per table segment )
that one <half> of the table at any stage will contain one element more than the other one

which one and when
depends on odd/even count and if You consider the delimiting element as part of one of the two <halves>

for 25 elements
the first element checked will be ( 1 + 25 ) / 2 = 13
for 26 elements ....
( 1 + 26 ) / 2 = 13
/ ==> integer division
the element checked will be the same, but...
meditate ... meditate ...
Back to top
View user's profile Send private message
dick scherrer

Site Director


Joined: 23 Nov 2006
Posts: 19270
Location: Inside the Matrix

PostPosted: Mon Apr 06, 2009 3:19 am    Post subject:
Reply with quote

Hwllo,

Quote:
Hi , i was asked a question in CSC:
Suggest one appropriate answer is that when using the built-in binary search function in cobol (SEARCH ALL) it doean't matter. . . It is all automatic. . .

If "they" are basing any hiring decisons on that type of question, i'm rather happy that i do not work there. . .
Back to top
View user's profile Send private message
Girijesh

New User


Joined: 19 Sep 2008
Posts: 14

PostPosted: Mon Apr 06, 2009 11:00 am    Post subject:
Reply with quote

Well thanks to all of you for your effort to answer this.

It really helped me a lot to understand the complexity of this question.
and Mr. Enrico-sorichetti i knew it is a collection of Mainframes not the MATH one , but i searched all the web , manuals and finally diverted here to get best response.
Please allow some space here for some non-sense but important questions.

It really helped to broaden my thought process,amazing ,so thanks again to all.
Back to top
View user's profile Send private message
Anuj Dhawan

Senior Member


Joined: 22 Apr 2006
Posts: 6258
Location: Mumbai, India

PostPosted: Mon Apr 06, 2009 12:27 pm    Post subject:
Reply with quote

Girijesh wrote:
Please allow some space here for some non-sense but important questions.
If something is nonsnese, how can it be important. . . icon_razz.gif . . . may be this question could be posted in "student Forum" . . . just a thought, please don't take it otherwise...
Back to top
View user's profile Send private message
enrico-sorichetti

Global Moderator


Joined: 14 Mar 2007
Posts: 10326
Location: italy

PostPosted: Mon Apr 06, 2009 12:56 pm    Post subject: Reply to: Binary Search elements in upper half
Reply with quote

Quote:
It really helped me a lot to understand the complexity of this question.
just curious, where is the complexity....

also I do not see how You could not find anything,
I just tried googling with binary search algorithm
and I found quite a number of links with exhaustive info on binary search

the first hit
http://en.wikipedia.org/wiki/Binary_search has a very good explanation

but again the question You were asked is just nonsense
Back to top
View user's profile Send private message
Anuj Dhawan

Senior Member


Joined: 22 Apr 2006
Posts: 6258
Location: Mumbai, India

PostPosted: Mon Apr 06, 2009 1:05 pm    Post subject: Re: Reply to: Binary Search elements in upper half
Reply with quote

Quote:
but again the question You were asked is just nonsense
Some times these question come from interviewer side and I met many such individuals.. even in my little experience . . . and as a newbie we feel if some one is interviewing us, he is senior (at least age-wise . . . grin) and asking the right thing . . .
Back to top
View user's profile Send private message
Girijesh

New User


Joined: 19 Sep 2008
Posts: 14

PostPosted: Mon Apr 06, 2009 3:19 pm    Post subject: Reply to: Binary Search elements in upper half
Reply with quote

Accepted : not aware with posting rules, good reply, i must appreciate the way you did icon_evil.gif

I'll take care next time
Back to top
View user's profile Send private message
Terry Heinze

JCL Moderator


Joined: 14 Jul 2008
Posts: 1249
Location: Richfield, MN, USA

PostPosted: Mon Apr 06, 2009 8:53 pm    Post subject:
Reply with quote

I agree with the others who stated this is an inappropriate interview question concerning a binary search. A better question would have been, "Describe briefly the difference between a serial search and a binary search" or "When is one preferable over the other?" or "What are the requirements necessary in order to use a binary search?".
Back to top
View user's profile Send private message
View previous topic :: :: View next topic  
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> Mainframe Interview Questions All times are GMT + 6 Hours
Page 1 of 1

 

Search our Forum:

Similar Topics
Topic Author Forum Replies Posted
No new posts HEX value search in a DB2 query maxsubrat DB2 2 Wed Oct 04, 2017 3:04 pm
No new posts Binary to display characters Roy Ware SYNCSORT 3 Tue Sep 19, 2017 8:46 pm
No new posts Search for a string in many PDS KARTHIGADEVI CLIST & REXX 5 Fri Sep 08, 2017 2:32 pm
No new posts Search utility(3.14) using JCl and Cobol RKS3 COBOL Programming 12 Sat Jun 10, 2017 10:24 pm
No new posts Group elements using ICETOOL Learncoholic DFSORT/ICETOOL 2 Fri Apr 14, 2017 11:01 am

Facebook
Back to Top
 
Job Vacancies | Forum Rules | Bookmarks | Subscriptions | FAQ | Polls | Contact Us