Advertisements
Advertisements
The keyword used by a class to acquire the properties of an interface is:
Concept: undefined > undefined
State the principle by which the stack data structure works.
Concept: undefined > undefined
Advertisements
A Queue is a linear data structure in which the operations are performed based on FIFO (First In First Out).
Define a class Queue with the following details:
Class name | Queue |
Data member/instance variable: | |
dat[ ] | array to hold the integer elements |
cap | stores the maximum capacity of the queue |
front | to point the index of the front |
rear | to point the index of the rear |
Member functions/methods: | |
Queue(int max) | constructor to initialize the data member cap = max, front = rear = 0 and create the integer array |
void add_dat(int v) | to add integers from the rear index if possible else display the message(“Queue full”) |
int pop_dat( ) | to remove and return elements from front, if any, else returns -999 |
void display() | to display elements of the queue |
Specify the class Queue giving the details of void add_dat(int) and int pop_dat( ). Assume that the other functions have been defined.
The main( ) function and algorithm need NOT be written.
Concept: undefined > undefined
A double ended queue is a linear data structure which enables the user to add and remove integers from either ends i.e., from front or rear.
The details for the class deQueue are given below:
Class name | deQueue |
Data members/instance variables: |
|
Qrr[] | array to hold integer elements |
lim | maximum capacity of the dequeue |
front | to point the index of the front end |
rear | to point the index of the rear end |
Methods/Member functions: |
|
deQueue(int 1) | constructor to initialise lim = 1, front = 0 and rear =0 |
void addFront(int v) | to add integers in the dequeue at the front end if possible, otherwise display the message “OVERFLOW FROM FRONT” |
void addRear(int v) | to add integers in the dequeue at the rear end if possible, otherwise, display the message “OVERFLOW FROM REAR” |
int popFront() | removes and returns the integers from the front end of the dequeue if any, else returns — 999 |
int popRear ( ) | removes and returns the integers from the rear end of the dequeue if any, else returns — 999 |
void show( ) | displays the elements of the dequeue |
Specify the class deQueue giving details of the function void addFront(int) and int popFront(). Assume that the other functions have been defined. The main() function and algorithm need NOT be written.
Concept: undefined > undefined
Differentiate between a stack and a queue.
Concept: undefined > undefined
int Toy(int n)
{ return (n<=0)? 1: n%10 + Toy(n/10); }
With reference to the program code given above, what will the function Toy() return when the value of n = 56?
Concept: undefined > undefined
Give one reason, why iteration is better than recursion.
Concept: undefined > undefined
Differentiate between direct recursion and indirect recursion.
Concept: undefined > undefined
The keyword that allows multi-level inheritance in Java programming is ______.
Concept: undefined > undefined
The following function task() is a part of some class. Assume ‘m’ and ‘n’ are positive integers greater than 0. Answer the questions given below along with dry / run working.
int task(int m, int n)
{ if(m=n)
return m;
else if (m>n)
return task(m-n, n);
else
return task(m, n-m)
}
- What will the function task() return when the value of m=30 and n=45?
- What function does task() perform, apart from recursion?
Concept: undefined > undefined
Draw the logic circuit for a 4 :1 multiplexer and explain its working.
Concept: undefined > undefined
A linked list is formed from the objects of the class given below:
class Node
{
doubel sal;
Node next;
}
Write an Algorithm OR a Method to add a node at the end of the an existing linked list. The method declaration is as follows:
void addNote(Node ptr, double ss)
Concept: undefined > undefined
Assertion: For proposition ∼A=> B, its contrapositive is B =>∼A
Reason: Contrapositive is the converse of inverse for any proposition.
Concept: undefined > undefined
The complement of the Boolean expression (P' • Q) (R • S') is ______.
Concept: undefined > undefined
An array ARR [ -5 .....15, 10.....20] stores elements in Row Major Wise with each element requiring 2 bytes of storage. Find the address of ARR [10] [15] when the base address is 2500.
Concept: undefined > undefined
Draw the logic gate diagram for 2-input OR gate using NAND gates only. Show the expression at each Step.
Concept: undefined > undefined
Write the canonical form of the cardinal terms, m3 and M5 for F (A, B, C, D).
Concept: undefined > undefined
A class Ins Sort contains an array of integers which sorts the elements in a particular order.
Some of the members of the class are given below.
Class name | InsSort |
arr[ ] | stores the array elements |
size | stores the number of elements in the array |
Methods/Member functions: | |
InsSort(int s) | constructor to initialise size= s |
void getArray( ) | accepts the array elements |
void insertionSornt( ) | sorts the elements of the array in descending order using the in descending order using the Insertion Sort technique |
double find( ) | calculates and returns the average of all the odd numbers in the array |
void display( ) | displays the elements of the array in a sorted order along with the average of all the odd numbers in the array by invoking the function find( ) with an appropriate message |
Specify the class InsSort giving details of the constructor(), void getArray( ), void insertionSort( ), double find() and void display(). Define a main( ) function to create an object and call all the functions accordingly to enable the task.
Concept: undefined > undefined
Design a class Coding to perform some string related operations on a word containing alphabets only.
Example: Input: "Java"
Output: Original word: Java
J=74
a=97
v= 118
a=97
Lowest ASCII code: 74
Highest ASCII code: 118
Some of the members of the class are given below:
Class name | Coding |
Data members/instance variables: | |
wrd | stores the word |
len | stores the length of the word |
Methods/Member functions: | |
Coding() | constructor to initialise the data members with legal initial values |
void accept( ) | to accept a word |
void find() | to display all the characters of 'wrd' along with their ASCII codes. Also display the lowest ASCII code and the highest ASCII code, in 'wrd' |
void show() | to display the original word and all the characters of 'wrd' along with their ASCII codes. Also display the lowest ASCII code and the highest ASCII code in 'wrd', by invoking the function find() |
Specify the class Coding giving details of the constructor( ), void accept( ), void find( ) and void show(). Define a main() function to create an object and call all the functions accordingly to enable the task.
Concept: undefined > undefined
CardGame is a game of mental skill, built on the simple premise of adding and removing the cards from the top of the card pile.
The details of the class CardGame are given below.
Class name | CardGame |
Data members/instance variables: | |
cards[] | array to store integers as cards |
cap | to store the maximum capacity of array |
top | to store the index of the topmost element of the array |
Methods/Member functions: | |
CardGame(int cc) | constructor to initialise cap=cc and top= -1 |
void addCard(int v) | to add the card at the top index if possible, otherwise display the message “CARD PILE IS FULL” |
int drawCard( ) | to remove and return the card from the top index of the card pile, if any, else return the value -9999 |
void display( ) | to display all the cards of card pile |
- Specify the class CardGame giving details of the functions void addCard(int) and int drawCard( ). Assume that the other functions have been defined.
The main() function and algorithm need NOT be written. - Name the entity described above and state its principle.
Concept: undefined > undefined