Computer Science, asked by rkdeep2779, 6 months ago

A class Admission contains the admission number of 100 students. Some of the data member/member functions are given below: Data member/ Instance variable Adno[] : Integer array to store admission numbers Member functions/Methods Admission() : Constructor to initialize the array elements. void fillArray() : To accept the elements 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 returns 1if found otherwise returns -1 Specify the class Admission giving details of the constructor, void fillArray() and int binSearch (int,int,int). Define the main() function to create an object and call the functions accordingly to enable the task. ​

Answers

Answered by harneetmakkad27
1

Answer:

sorry I'm not getting your question!

Answered by anthatimedhilesh
1

Answer:

Explanation:

import java.util.*;

class Admission

{

   int Adno[];

   Admission()

   {

       Adno=new int[100];

   }

   voidfillArray()

   {

       System.out.println("enter how many students");

       int n=sc.nextInt();

       System.out.println("enter admission numbers in ascending order");

       for(int i=0;i<0;i++)

       Adno[i]=sc.nextInt();

   }

   int binSearch(int l,int u,int v)

   {

       int m=(l+u)/2;

       if(l>u)

       return -1;

       else if(v==Adon[m])

       return 1;

       else if(v>Adon[m])

       return binSearch(m+1,u,v);

       else

       return binSearch(l,m-1,v);

   }

   void main()

   {

       Admission obj=new Admission();

       obj.fillArray();

       System.out.println("enter the elements to be searched");

       int s=sc.nextInt();

       int ans=obj.binSearch(0.Adno.length-1,s);

   }

}

Similar questions