0% found this document useful (0 votes)
27 views3 pages

Array Assignment

The document outlines a lab assignment for ISC - XI students at City Montessori School, focusing on Single Dimension Arrays (SDA). It includes specifications for multiple classes such as Sort, Rearrange, Freq, Array, Merge, DeciOct, PrimeFac, and Counter, detailing their data members and methods. Each class requires students to implement specific functionalities related to array manipulation, sorting, searching, and counting elements.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
27 views3 pages

Array Assignment

The document outlines a lab assignment for ISC - XI students at City Montessori School, focusing on Single Dimension Arrays (SDA). It includes specifications for multiple classes such as Sort, Rearrange, Freq, Array, Merge, DeciOct, PrimeFac, and Counter, detailing their data members and methods. Each class requires students to implement specific functionalities related to array manipulation, sorting, searching, and counting elements.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 3

C ITY MONTESSORI SCHOOL

SECTOR-D, LDA COLONY, KANPUR ROAD, LUCKNOW (INDIA)

LAB ASSIGNMENT (ISC - XI)


Single Dimension Array (SDA)
Each program should be written in such a way that it clearly depicts the logic of the problem. This
can be achieved by using mnemonic names and comments in the program.
In each of the following programs, write the main method to create an object and call the methods.
____________________________________________________________________________________
Q1. A class Sort contains an array of integers. Some of the other members of the class are:
Class name Sort
Data members/instance variables :
arr[ ] integers
len maximum size of the array.
Member functions/methods :
Sort(int max) constructor to assign max to len and create the array.
void input( ) To input integers (no duplicate numbers are to be entered)
void bubsort( ) To sort the array in ascending order using bubble sort tech-
nique and display the sorted list.
void binsearch(int v) To find for 'v' using binary search technique. If found print
its position in the list, otherwise print a suitable message
Specify the class Sort giving details of the constructor and methods.

Q2. A class Rearrange is defined to insert or delete an element from an array. Some of the other members of the
class are:
Class name Rearrange
Data members/instance variables :
a[ ] integer array of 50 elements.
n maximum size of the array.
Member functions/methods :
Rearrange(int size) constructor to initialize maximum size of the array.
void input( ) To enter n integers.
void insert(int x, int p) To insert an element 'x' at position 'p'.
void remove(int p) To delete an element from position 'p'.
void display( ) To display the array.
Specify the class Rearrange giving details of the constructor and methods.

Q3. A class Freq contains an array of 20 integers. Some of the other members of the class are given below:
Class name Freq
Data members/instance variables :
arr[ ] array to store integers
n size of the array.
Member functions/methods :
Freq( ) constructor to initialize size of the array.
void input( ) To input n integers.
int minArr( ) returns the smallest array element.
int maxArr( ) returns the largest array element.
void freqArr( ) To print the occurence of each integer of the array.
Specify the class Freq giving details of the constructor and methods.

(13)
Q4. A class Array is designed as:
Class name Array
Data members/instance variables :
arr[ ] integer array.
size to store the size of the array.
Member functions/methods :
Array(int sz) constructor to initialize size = sz, and create the array.
void accept( ) To accept values in the array.
void arrange( ) To arrange values in ascending order using insertion sort
technique.
void pack( ) To remove duplicate elements from the array.
void display( ) To display the array elements.
Specify the class Array giving details of the constructor and methods. Display the arranged array after removing
duplicate elements from it.

Q5. A class Merge contains some sorted arrays of integers with no duplicate elements. Some of the other members
of the class are:
A class Merge is defined as:
Class name Merge
Data members/instance variables :
a[ ], b[ ], c[ ] integer arrays
m, n maximum size of the arrays a[] and b[] respectively.
Member functions/methods :
Merge(int nm, int nn) constructor to initialize m = nm, n = nn and create the arrays
void input( ) To input integers in a[] and b[] in sorted order.
void mergesort( ) fills the array c[] with integers of a[] and b[] in ascending
order without using any sorting technique.
void display( ) To display the arrays.
Specify the class Merge giving details of the constructor and methods.
Q6. A class DeciOct has been to convert a decimal number to octal using an array. Its details are given as:
Class name : DeciOct
Data members/instance variables :
dec : to store a decimal number in integer
oct[ ] : to store a maximum of 10 octal digits.
n : size of the array after conversion.
Member functions/methods :
DeciOct(int d) constructor to initialize dec = d.
void convert( ) to convert the given decimal number to octal.
void reverse( ) to reverse the array oct[ ].
void display( ) to display the octal number.
WAP to specify the class DeciOct giving details of the member methods.
Q7. A class PrimeFac contains an array of 50 integers. Some of the members of the class are:
Class name : PrimeFac
Data members/instance variables :
num[ ] - array to store integers.
freq[ ] - array to store frequency of prime factors of integers.
Member functions/methods :
PrimeFac( ) constructor to initialize the array elements to 0.
void enter( ) to enter the array num[].
void frefac( ) to store the frequency of prime factors of the numbers in num[]
in freq[]
void display( ) to display both the arrays.
WAP to specify the class PrimeFacgiving details of the constructor and methods.
(14)
Q8.
Given a class Counter with the following description :
Class name : Counter
Data members/instance variables
int count : to store count.
Member functions/methods
Counter( ) constructor to initialize count to 0.
inccount( ) increments count by one.
givecount( ) returns value of count.

WAP to use this class to count the number of ladies, number of gentlemen and the number of children in a guest list.The
guest list is stored as a character type array guest[ ]. It consists of the following codes:
Code Stands for
'g' gentleman
'l' lady
'c' child
The guest list may have codes for 15 people. For example.,
'c' ,'c', 'l', 'g', 'l', 'g', 'l', 'l', 'g', 'c', 'l', 'l', 'g', 'c', 'l'
Output:
Number of ladies :
Number of gentlemen:
Number of children:

(15)

You might also like