Friday , 18 January 2019
Latest Posts
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

#### Question:

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

Data member/instance variable:

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 : www.guideforschool.com
* @Program Type : BlueJ Program - Java
* @Question Year : ISC 2015 (Theory) Question 8
*/

import java.util.*;
{
static Scanner sc = new Scanner(System.in);

{
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)+": ");
}

/*Sorting the array in ascending order */

int temp=0;
for(int i=0; i<99; i++)
{
for(int j=i+1; j<100; j++)
{
{
}
}
}
}

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;
}
{
return binSearch(mid+1,u,v);
}
else
{
return binSearch(l,mid-1,v);
}
}

public static void main(String args[])throws Exception
{
System.out.println("Enter Admission number in ascending order");
ob.fillArray();
System.out.print("Enter an Admission number to search : ");
int v = sc.nextInt();
int f = ob.binSearch(0,99,v);
System.out.println("*****************************");
if(f == 1)
{
}
else
{
}
}
}```

#### Output:

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
*****************************

## How to read an Ammeter – ISC Physics Practical

Solution of ISC 2017 Computer science Paper as provided by the Council for the Indian School Certificate Examinations.

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

• No marks would be deducted for not using StringTokenizer.

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.

Regards,
GFS

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)……..it was given maximum of 20 elements……but then in constructor we were asked to create the WordPile with size as ‘capacity’…..so 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…..:)

• Marks won’t be deducted.

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??

• No. But that is just 1 marks, so relax.

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??

• You will lose your marks.

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

• Every comment first goes to the admin, and after approval it is displayed. So give us time to analyse comments.

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

• Depends on whether everything else was correct or not.

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.

• No issues. No marks would be deducted.

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

• 1-2 marks may 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.

• Not necessary. Marks won’t be deducted for that.

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

• Not necessary. Marks won’t be deducted for not sorting.

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

• Not necessary. Marks won’t be deducted for not sorting.

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?

• If you get a 100 in theory, you get a 100 in practical as well.

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

• No marks would be deducted for not sorting the array.

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.