Wednesday , 21 August 2019
Home » Array Related Programs » [Question 8] ISC 2015 Computer Paper Solved – Binary Search Using Recursion

[Question 8] ISC 2015 Computer Paper Solved – Binary Search Using Recursion

Click here to download the complete ISC 2015 Computer Science Paper 1 (Theory).


A class Admission contain the admission numbers of 100 students. Some of the data members/ member functions are given below:

Class name: Admission

Data member/instance variable:

Adno[ ]: Integer array to store admission numbers

Member functions/methods:

Admission(): constructur to initialize the array elements
void fillArray(): to accept the element of the array in ascending order
int binSearch(int l, int u, int v): to search for a particular admission number(v) using binary search and recursive technique and return 1 if found otherwise returns -1

Specify the class Admission giving details of the constructor, void fillArrray() and int binSearch(int, int, int). Define the main() function to create an object and call the functions accordingly to enable task.

Programming Code:

 * The class Admission searches for an Admission number using Binary Search
 * @author :
 * @Program Type : BlueJ Program - Java
 * @Question Year : ISC 2015 (Theory) Question 8

import java.util.*;
class Admission
    int Adno[]=new int[100];
    static Scanner sc = new Scanner(;

    Admission() // Default constructor
        for(int i=0; i<100; i++)
    void fillArray()throws Exception // Function to accept elements in ascending order
        for(int i=0; i<100; i++)
            System.out.print("Enter Admission no of student "+(i+1)+": ");
            Adno[i] = sc.nextInt();
        /*Sorting the array in ascending order */
        int temp=0;
        for(int i=0; i<99; i++)
            for(int j=i+1; j<100; j++)
                    temp = Adno[i];
                    Adno[i] = Adno[j];
                    Adno[j] = temp;
    int binSearch(int l, int u, int v) // Recursive function implementing binary search
        int mid = (l + u)/2;
        if(u < l) // condition if the search is unsuccessful
            return -1;
        if(v==Adno[mid]) // condition if the search is successful
            return 1;
        else if(v>Adno[mid]) 
            return binSearch(mid+1,u,v);
            return binSearch(l,mid-1,v);
    public static void main(String args[])throws Exception
        Admission ob = new Admission();
        System.out.println("Enter Admission number in ascending order");
        System.out.print("Enter an Admission number to search : ");
        int v = sc.nextInt();
        int f = ob.binSearch(0,99,v);
        if(f == 1)
            System.out.println("Admission Number found");
            System.out.println("Admission Number Not found");


Note: The output has been taken for 5 elements in the array

Enter Admission number in ascending order
Enter Admission no of student 1: 205
Enter Admission no of student 2: 310
Enter Admission no of student 3: 670
Enter Admission no of student 4: 887
Enter Admission no of student 5: 952
Enter an Admission number to search : 887
Admission Number found

Check Also

Infix Postfix Prefix Conversion – Correct Method (ISC Computer Science)

In this video we discuss about the correct way of converting an Infix Expression to Postfix and Prefix.


  1. Sir in Question 10 ,I did not use String tokenizer function. Will any marks be deducted because of this?

  2. ! Why my comment is always blocked ‘sir please reply ?

    • You have been using too many pseudonames and wrong e-mail addresses. Anyone doing that is blocked.

      Points to note for everyone: There are hundreds of e-mails received everyday and hundreds of comments posted daily. We are very thankful to our readers for that. But, we should keep in mind, that the teacher in charge of this website is not always online to reply to everyone’s queries the moment it is posted. The reply is posted when the teacher gets time from his busy schedule of teaching.
      Also if any comment is deemed unnecessary by the admin, then it is removed.


  3. also tell how many marks will be deducted if taken double element as 2bit and rest all things are correct…

  4. Sir,in Question 10th (WordPile)…… was given maximum of 20 elements……but then in constructor we were asked to create the WordPile with size as ‘capacity’… I’ve initialized “ch=new char[capacity]” inside the constructor and wrote a comment..”//Assuming capacity <= 20"…….and nowhere did I initialize the size equal to 20.I hope I will get full marks.Will I?

    And thank you for all the hardwork you did for helping students like me…..your website is a great help to all of us…Thanks a lot…..:)

  5. sir assuming my binary search function to be wrong and rest of the program correct……how many marks will i get out of 10

  6. Sir in Question 3(a),part(3), I wrote simply “factors of X”…will I get marks for that??

  7. sir is writing the comments necessary in programs…plz reply

  8. Sir i have made mistake in doing the binary search portion ..please tell me how many marks will i get if my rest of the program is correct

  9. Sir, in question 3(a)… I printed the values of x instead of y by mistake and wrote that the method is printing factors of x…will the entire answer be cancelled or how much marks will be given??

  10. Sir, in Question 2 (d), how many marks will be deducted for taking the width of double as 4 bytes? Will the entire sum be cancelled out?

  11. Your comment is awaiting moderation.
    what does this mean

  12. Sir, How many marks will be deducted in k-map if the expression derived is not correct.

  13. Sir,in this question as mentioned in the question paper to return -1 if the element is not found.Instead I returned 0.How many marks will be deducted?

  14. Yeah..nice program using recursion

  15. Sir, I did not sort the array in ascending order as it was mentioned in the question to input the elements in ascending order. I mentioned it in a message though, to input in ascending order.

  16. int binSearch(int l, int u, int v) …….sir if I have not written this function correctly how many marks will be deducted????

  17. Sir, do we need to sort the array? As the question doesn’t say so. It just tells us to let the user enter the elements in the ascending order.

  18. Sir was the sorting compulsary to do…what if we gave the message to enter the numbers in ascending order!?

  19. Was sorting required according to the language of question ?

  20. Sir I have done of 100 marks in exam, but teacher told me that I got 99 marks in practical, so how much will I get?

  21. Sir,I did not sort the array.How many marks will be deducted.

  22. Sir i messed up a little bit in a binary search function,,,,,please tell me how many marks will i get if my rest of the program is correct

    • 1-2 marks may be deducted.

      • thankyou sir for replying,,,,sir in section b i attempted all questions
        in concatination one i used in the concat function
        int num=””+n1+n2
        how many marks will be deducted and which of these 2 would be selected
        also sir in question number 3 b part i wrote that it was calculating lcm,,,,,is it correct

        • by these two i mean assuming my one program to be completely correct in section b ,,,,,,which one has the most chance of scoring more marks,,,,,concatination one or binary function one,,,,,also i used string tokenizer in the consonants calculation one ,,,,,is it correct,,,,,,please reply sir i am feeling very nervous

          • Using StringTokenizer is perfectly fine. It is specifically mentioned in the ISC syllabus.
            Regarding which of your answers would be selected, then it depends on the severity of the mistakes done in them.
            Regarding Question 3 (a) part (iii) then it is printing the prime factors of x.

        • I dont think you wont lose marks for using concatenation.
          There is no problem at all. The way to join was not mentioned so it is correct. Using friend number was the proper method though.

Leave a Reply

Your email address will not be published. Required fields are marked *