Question

In: Computer Science

Consider the following structure definitions and fill in the blanks for the enqueue function:

Consider the following structure definitions and fill in the blanks for the enqueue function:

    typedef struct queue queue_t;
    typedef struct node node_t;
    struct node {
        node_t *next;
         void *val; };
    struct queue {
        node_t *head;
        node_t *tail;};
/* add val at the tail of the queue q */
void enqueue (queue_t *q, void *val) {
    if (q->head == NULL) {
        _______________ = _______________ = malloc(sizeof(_______________));
        _______________ = NULL;
    } else {
        _______________ = _______________ = malloc(sizeof(_______________));
        _______________ = NULL;
    }
    q->tail->val = val;
}

Solutions

Expert Solution

typedef struct queue queue_t;
    typedef struct node node_t;
    struct node {
        node_t *next;
         void *val; };
    struct queue {
        node_t *head;
        node_t *tail;};
/* add val at the tail of the queue q */
void enqueue (queue_t *q, void *val) {
    if (q->head == NULL) {
        q->head = q->tail = malloc(sizeof(struct node));
        q->head->next = NULL;
    } else {
        q->tail = q->tail->next = malloc(sizeof(struct node));
        q->tail->next = NULL;
    }
    q->tail->val = val;
}

Related Solutions

Fill in the blanks: Consider the following equilibrium and fill in the blanks with either increase...
Fill in the blanks: Consider the following equilibrium and fill in the blanks with either increase or decrease. I2(s) + 5F2(g) ⇌ 2IF5(g) A decrease in volume results in a Blank 1 in pressure which will Blank 2 the amount of IF5.
Fill in the blanks on the following table
 Fill in the blanks on the following tableE&pshareholder basisdistributiondividendreturn of capitalcapital gain20,000300,00080,000120,00010,000170,000220,000100,000170,00020,000080,000<20,000>50,000170,000
Fill in the blanks in each of the following statements
Fill in the blanks in each of the following statementsa) --------- allows you to build JavaFx GUIS using drag and drop techniques.b) The elements in the scene graph are called --------------c) A(n) ----------- file contains the description of a JavaFX GUI.d) The method ---------------- is called by FMXLLoader before the GUI is displayed
Fill in the blanks with an appropriate suggestion for the following.
Fill in the blanks with an appropriate suggestion for the following.(i) If there is no trade-off involved when we get a good, then it is called a _______________ good.(ii) If expected future price falls for a good, it's current demand _____________________ .(iii) Pencil and erasers are a pair of ___________________goods for consumers
Fill in the blanks to complete the following table.
Fill in the blanks to complete the following table.SymbolIon FormedNumber of Electrons in IonNumber of Protons in IonF__________9Te_____54_____II−_______________Mg2+_____12Part AComplete the first column of the table.Express your answer as a chemical symbol.Part BComplete the second column of the table.Express your answer as ions. Enter your answers in order given in the table, from top to bottom, separated by a comma.Part CComplete the third column of the table.Express your answer as integers. Enter your answers in order given in the table, from...
C++ Fill in the blanks please You are required to fill in the blanks in this...
C++ Fill in the blanks please You are required to fill in the blanks in this program. Consider that: -In main, the variables price and quantity were given the names of p (double) and q (int), respectively. -In the getData function, the parameters associated with the main variables p and q were called pp and pq, respectively. // Prototype: Do not include the names // of the variables in the prototype void getData (FILLTHEBLANK , FILLTHEBLANK); int main () {...
Problem: Consider each of the following situations independently. Fill in the blanks with the appropriate information....
Problem: Consider each of the following situations independently. Fill in the blanks with the appropriate information. 1. selling price per unit Variable cost percentage number of units sold total contribution margin Total fixed costs Net Income (Loss) $90.00 20,000 $750,000 ($30,000) 2. Number of Units sold Total Variable Cost Variable Cost percentage Total Contribution Margin Total Fixed Costs Net Income (Loss) 1,800 30% $756,000 $54,000 3. Selling Price per unit Total Sales Number of Units Sold Variable Cost per unit...
Fill in the blanks in each of the following statements: 1. Each function definition can specify...
Fill in the blanks in each of the following statements: 1. Each function definition can specify __________________ that represent additional information the function requires to perform its task correctly. 2. Declaring data members with access modifier __________________ is known as information hiding. 3. The initial value of a string is the __________________which does not contain any characters. 4. Variables declared in the body of a particular function are known as __________________and can be used only in that function. 5. Each...
Contribution Margin approach Problem: Consider the following situation independently. Fill in the blanks with the appropriate...
Contribution Margin approach Problem: Consider the following situation independently. Fill in the blanks with the appropriate information. number of units sold total sales number of units sold variable cost per unit contribution margin percentage total fixed costs net income return on sales (NI/Sales) $20.00 58% $80,000 8%
Fill in the blanks with the following numbers, not the words, for this and all the...
Fill in the blanks with the following numbers, not the words, for this and all the questions that follow. Jot them down so you won't have to keep scrolling up to the top to see what they are: Demand = 1 Supply = 2 Right = 3 Left = 4 Up = 5 Down = 6 QUESTION 6 Suppose the dollar were to strengthen in international currency markets. That is, the price of the dollar, in terms of other national...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT