Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Problem: Read the code and explain each of the functions using pseudo-codes: #de

ID: 3640746 • Letter: P

Question

Problem:
Read the code and explain each of the functions using pseudo-codes:

#define false 0
#define true 1
typedef unsigned char int8bit;
#define int8bit boolean
/*declare a constant of Assumed Size of the queue = 65536.*/
static const AssumedQSize = 65536;
/*... Insert Codes that the type of a queue element, QElType*/;
class QueueElArray {
private:
/*Define three numbers, qhead, qtail and qsize of the queue.
The qsize means the number of elements in a queue. The qtail
means the last element. Any new inserted element will be at the qtail.
Any deleted element will be from the qhead*/
unsigned short qhead, qtail, qsize; unsigned short qfull;
boolean headerEnable, trailingEnable, CirQuEnable, PolyQuEnable;
unsigned short headerNumByte, trailingNumByte, CirQuNumByte, PolyQuBlockNum;
boolean headerFlag, trailingFlag, CirQuFlag, PolyQuFlag;
void incCirc(int&item); /*inserting and deleting the element at the increasing indices circularly*/
QueueElArray (const QueueElArray & Qelement); /* Prevent calling a queue element using Qelement*/
/*Define Queue Error Handling variable and function*/
boolean volatile Qerrorflag;
static void interrupt ISR_Qerror (volatile boolean Qerrorflag, unsigned short[]);};
public:
/* A constructor for the QueueElArray*/
QueueElArray (QElType *QelementsArray, unsigned short maxSize = AssumedQSize); /*
the function delete in C++ is equivalent to function free in C. A destructor for the QueueElArray */
~QueueElArray {delete [] QueueElArray;};
/* An operator for the QueueElArray */
const QueueElArray & operator = (const QueueElArray & Qelement);
boolean isQNotEmpty () const {return (qsize > 0);};
void Qempty();
void QElinsert (const QElType & item); /* A function for inserting an element at tail*/
boolean isQNotFull () const {return (qsize < qfull);};
QElType QElReturn (); /* A function for returning an element from head*/
};/* End of class Queue*/
/********************************* Constructor for Queue *********************************/
QueueElArray (QElType * QelementsArray, unsigned short maxSize) {qfull = maxSize; Qerrorflag = false;
Qempty (); /* Construct Empty Queue*/
QelementsArray = new QElType [maxSize];
/*Now handle the errors */
if (QelementsArray == NULL) {Qerrorflag = true; ISR_Qerror (Qerrorflag, "Error! Queue Space Not Available");
}
/**************************************************************************/
void QueueElArray :: Qempty() {qhead = 1; Qtail = 0; qsize = 0;}
/**************************************************************************/
void QueueElArray :: QElinsert (const QElType & item){
if (isQNotFull()){
qsize++;
incCir (qtail);
QelementsArray [qtail] = item; Qerrorflag = false;}
else {Qerrorflag = true; ISR_Qerror(Qerrorflag, "Error! Queue Found Full");};
}/*End of insertion into the QueueElArray*/
/***************************************************************************/
QElType QueueElArray :: QElReturn(){
QElType = temp;
if (isQNotEmpty ()) {temp = QelementsArray [qhead]; qsize -; incCir (qhead); Qerrorflag = false;
return (Qelement);}
else {Qerrorflag = true; ISR_Qerror (Qerrorflag, "Error! Queue Found Empty);};/*
}/*End of a deletion from the QueueElArray*/
/**************************************************************************/
void QueueElArray :: incCirc(unsigned byte & item){
if (++item = =qfull) {item = 0;};
} /* End of incCir and Next Queue Element pointer back to start*/
/******************************************************************************/


Explanation / Answer

first four line is just define the declaration

when ever see the /* is just a comment . so dont panic about that

as the above one is just some declaration for the value.
middle one is just some formula to calculate the respective result.
Dont panic about the function using just careful trace the flow you will understand
more better.

There is some detail comment at beside of the coding
it is easy to understand what the program are about,
just basically declaration, formula to calculate the respective result using function to process, outputting the result.

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote