[go: up one dir, main page]

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

Circular Queue

The document describes the implementation of a queue using an array with functions to push and pop elements, including overflow and underflow conditions. It also includes Boolean algebra problems, such as simplifying expressions and finding duals, as well as a class design for counting word frequencies in a user-input sentence. The class 'Frequency' has methods for accepting input, counting specific words, and displaying the results.

Uploaded by

tutor nag
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
15 views3 pages

Circular Queue

The document describes the implementation of a queue using an array with functions to push and pop elements, including overflow and underflow conditions. It also includes Boolean algebra problems, such as simplifying expressions and finding duals, as well as a class design for counting word frequencies in a user-input sentence. The class 'Frequency' has methods for accepting input, counting specific words, and displaying the results.

Uploaded by

tutor nag
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 3

ar 70 12 15 20 40

0 1 2 3 4
f
int front=0;
int rear=-1; push(5)
void push(int v) push(12)
{ push(15)
pop()
if((front==0&&rear==4)||(front>0&&rear==front-1)) push(20)
System.out.println("Queue is overflow\n"); push(40)
else push(70)
{
if(rear==4&&front>0)
{
rear=0;
ar[rear]=v;
}
else
{
rear++;
ar[rear]=v;
}
}
}
void pop()
{
if((front==0)&&(rear==-1))
{
System.out.println("Queue is underflow\n");
}
if(front==rear)
{
ar[front]=0;
rear=-1;
front=0;
}
if(front==4)
{
ar[front]=0;
front=0;
}
else
{
ar[front++]=0;
}
}
ar
0 1 2 3 4

int front=0;
int rear=-1; push(5)
void push(int v) push(12)
{ push(15)
pop()
if((front==0&&rear==4)||(front>0&&rear==front-1)) push(20)
System.out.println("Queue is overflow\n"); push(40)
else push(70)
{
if(rear==4&&front>0)
{
rear=0;
ar[rear]=v;
}
else
{
rear++;
ar[rear]=v;
}
}
}
void pop()
{
if((front==0)&&(rear==-1))
{
System.out.println("Queue is underflow\n");
}
if(front==rear)
{
ar[front]=0;
rear=-1;
front=0;
}
if(front==4)
{
ar[front]=0;
front=0;
}
else
{
ar[front++]=0;
}
}
Simplify the following expression, using Boolean laws: [2]
(X + Z).(X.Y + Y.Z’) + X.Z + Y

Find the dual of: X.Y+X.Y’ = X + 0 [1]


If F(A, B, C) = A’.B’.C’ + A’.B.C’ then find F’ using De Morgan’s Law.

Find the dual of [1]


(A’ + B) . (1 + B’) = A’+B
If F(A, B, C) = A'(BC’ + B’C), then find F’. [1]

Input a sentence from the user and count the number of times, the words “an” and “and” are present in the sentence. Design a
class Frequency using the description given below: [ 10]
Class name: Frequency
Data members/variables:
text: stores the sentence
countand: to store the frequency of the word “and”
countan: to store the frequency of the word “an”
len: stores the length of the string
Member functions/methods:
Frequency(): constructor to initialize the instance variables
void accept(String n): to assign n to text, where the value of the parameter n should be in lower case.
void checkandfreq(): to count the frequency of “and”
void checkanfreq(): to count the frequency of “an”
void display(): to display the number of “and” and “an” with appropriate messages.

You might also like