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

Program for COSC 504- Summer 2018 Write a program that uses the operations defin

ID: 3908297 • Letter: P

Question

Program for COSC 504- Summer 2018 Write a program that uses the operations defined in the queue class to construct operations that do the following to stacks of strings composed of printable characters. Input and output file usage is required Apply all of the previously described programming requirements to this program. Create four queues, Fil each queue with 15 elements from an input file. Write a print function that will print the queues leaving the queues unchanged - Remove the second element from queue one. Print the queue and the element that was removed. The queue is otherwise unchanged Implement the recursive PrintqueueUp procedure that prints the elements from the bottom to the top of a queue. Wnite a function that will create a new queue called the Intersectio queue. It is the-intersection of two queues. Chose the queues from the list and name them. Write a function that will create a new queue composed of the successors of each- of the elements in queue two. The original queue remains unchanged Write a function that will create the Unionqueue. It is the union of two queues. Chose the queues from the list and name them Write a function that will find the number of elements in a queue - Write a function that will determine whether two queues are equal. Choose and name them. Write a function that will find the maximum and minimum string in a queue. Do - not directly compare characters Write a function called delete_entry that will delete every occurrence of a given value stored in the variable, chque. The queue is otherwise unchanged. - Write a function that will delete the last element from queue one. -Write a function that will reverse the elements in a queue. Write a function that will print the bottom element of a queue, leaving the queue- empty - Write a function that will make a copy of a queue Write a function to determine whether one queue is a sub-queue of another queue Write a function that will find the difference between two queues. Choose them and name them. Write a function that will append two queues. Choose them and name them. The solution is a single queue called Appendstk. Write a recursive function that will recursively replace all of the vowels in a queueof strings with the character v that a function works, you must print the queue (s) prior to the actions of the function and after the Note: To prove action(s) of the function. The function has to demonstrate that it gives a true response in the correct situation and a false response Due date: June 26, 2018 in the wrong situation. New queues must also be printed as they are created to show that they exist.

Explanation / Answer

Function to count the number of elements in a queue

Pointer1 = head;

count = 0;

if( Pointer1 != NULL )

{

   count = 1;

   Pointer2 = Pointer1->Next;

   while ( Pointer2 != NULL && Pointer2 != Pointer1 )

   {

     count++;

     Pointer2 = Pointer2->Next;

   }

}

return count;

Program to create queue:

#include <stdio.h>

#define MAX 50

int queue_array[MAX];

int rear = - 1;

int front = - 1;

main()

{

    int choice;

    while (1)

    {

        printf("1.Insert element to queue ");

        printf("2.Delete element from queue ");

        printf("3.Display all elements of queue ");

        printf("4.Quit ");

        printf("Enter your choice : ");

        scanf("%d", &choice);

        switch (choice)

        {

            case 1:

            insert();

            break;

            case 2:

            delete();

            break;

            case 3:

            display();

            break;

            case 4:

            exit(1);

            default:

            printf("Wrong choice ");

        }

    }

}

insert()

{

    int add_item;

    if (rear == MAX - 1)

    printf("Queue Overflow ");

    else

    {

        if (front == - 1)

        /*If queue is initially empty */

        front = 0;

        printf("Inset the element in queue : ");

        scanf("%d", &add_item);

        rear = rear + 1;

        queue_array[rear] = add_item;

    }

} /*End of insert()*/

delete()

{

    if (front == - 1 || front > rear)

    {

        printf("Queue Underflow ");

        return ;

    }

    else

    {

        printf("Element deleted from queue is : %d ", queue_array[front]);

        front = front + 1;

    }

} /*End of delete() */

display()

{

    int i;

    if (front == - 1)

        printf("Queue is empty ");

    else

    {

        printf("Queue is : ");

        for (i = front; i <= rear; i++)

            printf("%d ", queue_array[i]);

        printf(" ");

    }

}

Dr Jack
Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Chat Now And Get Quote