Portal | Manuals | References | Downloads | Info | Programs | JCLs | Mainframe wiki | Quick Ref

Author Message
Girijesh

New User

Joined: 19 Sep 2008
Posts: 14

 Posted: Sun Apr 05, 2009 4:40 pm    Post subject: Binary Search elements in upper half 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

CICS Guy

Senior Member

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

 Posted: Sun Apr 05, 2009 7:01 pm    Post subject: 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.
enrico-sorichetti

Global Moderator

Joined: 14 Mar 2007
Posts: 10326
Location: italy

 Posted: Sun Apr 05, 2009 8:37 pm    Post subject: Reply to: Binary Search 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 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 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 ...
dick scherrer

Site Director

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

Posted: Mon Apr 06, 2009 3:19 am    Post subject:

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. . .
Girijesh

New User

Joined: 19 Sep 2008
Posts: 14

 Posted: Mon Apr 06, 2009 11:00 am    Post subject: 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.
Anuj Dhawan

Senior Member

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

Posted: Mon Apr 06, 2009 12:27 pm    Post subject:

 Girijesh wrote: Please allow some space here for some non-sense but important questions.
If something is nonsnese, how can it be important. . . . . . may be this question could be posted in "student Forum" . . . just a thought, please don't take it otherwise...
enrico-sorichetti

Global Moderator

Joined: 14 Mar 2007
Posts: 10326
Location: italy

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

 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
Anuj Dhawan

Senior Member

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

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

 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 . . .
Girijesh

New User

Joined: 19 Sep 2008
Posts: 14

 Posted: Mon Apr 06, 2009 3:19 pm    Post subject: Reply to: Binary Search elements in upper half Accepted : not aware with posting rules, good reply, i must appreciate the way you did I'll take care next time
Terry Heinze

JCL Moderator

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

 Posted: Mon Apr 06, 2009 8:53 pm    Post subject: 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?".
 All times are GMT + 6 Hours
 Page 1 of 1

Search our Forum:

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

 © 2003-2017 IBM MAINFRAME Software Support Division
 Job Vacancies | Forum Rules | Bookmarks | Subscriptions | FAQ | Polls | Contact Us