Starting Out With C++: Early Objects (10th Edition)
10th Edition
ISBN: 9780135235003
Author: Tony Gaddis, Judy Walters, Godfrey Muganda
Publisher: PEARSON
expand_more
expand_more
format_list_bulleted
Question
Chapter 18, Problem 17RQE
Program Plan Intro
Pseudocode:
Pseudocode is an in-depth yet readable expression of what a computer program or
Stack:
Stack is a linear data structure which follows a set of particular orders in which operations are performed. It follows Last in First out (LIFO) order or First in Last out (FILO). It performs basic operations like push, pop or seek.
Queue:
Queue is an abstract data structure that is similar to stack but is open at both ends. It Follows First In First Out (FIFO) order. It performs basic operation like enqueue and dequeue.
Expert Solution & Answer
Want to see the full answer?
Check out a sample textbook solutionStudents have asked these similar questions
Queue Simulation
Create a java program that will simulate Queue operations using 1-D array representation.Each operation is dependent from each other and it's carried out in the next question in a sequential order.
Given:
A Queue with 10 elements.
This code for:
1) Add five integer values into a queue.
2) Delete the values from the queue then store the popped values in a sorted linked list and print it on the screen
I need details comments for each line ... Thank you.
The code: (Programming Language is C):
#define MAXELEMENTS 5
#define MIN 0
struct queue {
int items[MAXELEMENTS];
int front, rear;
};
struct node {
int data;
struct node *next;
};
typedef struct node *NODEPTR;
void cqinsert(struct queue*,int);
int cqdelete(struct queue*);
void insert(node *head,int);
int main(void) {
struct queue q;
int x;
q.front= q.rear=-1;
for(int i=0;i<5;i++)
{ printf("Enter input Number \n");
scanf("%d",&x);
cqinsert(&q,x);
}
x=cqdelete(&q);
NODEPTR head=(NODEPTR)malloc(sizeof(struct node));
head->data=x;
head->next=NULL;
for(int i=0;i<5;i++)
{ x=cqdelete (&q);
insert(head, x);
}
NODEPTR save = head;
do { printf("%d\n",save->data);
save-save->next;
} while(save!=NULL);
return 0;
}//end of main
int…
java data structure
Queue:
Q4: A program performs the following operations on an empty queue Q:
Q.enqueue(24)
Q.enqueue(74)
Q.enqueue(34)
Q.first()
Q.dequeue()
Q.enqueue(12)
Q.dequeue()
Please show the queue contents at the end of these operations. Clearly show the front of the queue.
Chapter 18 Solutions
Starting Out With C++: Early Objects (10th Edition)
Ch. 18.3 - Describe what LIFO means.Ch. 18.3 - What is the difference between static and dynamic...Ch. 18.3 - What are the two primary stack operations?...Ch. 18.3 - What STL types does the STL stack container adapt?Ch. 18 - Prob. 1RQECh. 18 - Prob. 2RQECh. 18 - What is the difference between a static stack and...Ch. 18 - Prob. 4RQECh. 18 - The STL stack is considered a container adapter....Ch. 18 - What types may the STL stack be based on? By...
Ch. 18 - Prob. 7RQECh. 18 - Prob. 8RQECh. 18 - Prob. 9RQECh. 18 - Prob. 10RQECh. 18 - Prob. 11RQECh. 18 - Prob. 12RQECh. 18 - Prob. 13RQECh. 18 - Prob. 14RQECh. 18 - Prob. 15RQECh. 18 - Prob. 16RQECh. 18 - Prob. 17RQECh. 18 - Prob. 18RQECh. 18 - Prob. 1PCCh. 18 - Prob. 2PCCh. 18 - Prob. 3PCCh. 18 - Prob. 4PCCh. 18 - Prob. 5PCCh. 18 - Prob. 6PCCh. 18 - Prob. 7PCCh. 18 - Prob. 8PCCh. 18 - Prob. 14PCCh. 18 - Prob. 9PCCh. 18 - Prob. 10PCCh. 18 - Prob. 11PCCh. 18 - Prob. 12PCCh. 18 - Prob. 13PCCh. 18 - Prob. 15PC
Knowledge Booster
Similar questions
- Radix Sorting Algorithm In C++, implement the radix sorting algorithm using a queue class.Steps: Create a queue filled with 10 random integers between 1000 and 9999. Next, create a list of 10 empty queues (0-9 digit bins), then dequeue each number from the main queue and enqueue them into the correct digit bin. Dequeue the numbers from each digit bin in order and enqueue them back into the main queue. Repeat the process for every digit (tens, hundreds, thousands, etc.) Finally, print the sorted list.arrow_forwardStructure data : Stacks and queues [see the image]arrow_forwardStack: Stacks are a type of container with LIFO (Last In First Out) type of working, where a new element is added at one end and (top) an element is removed from that end only. Your Stack should not be of the fixed sized. It should be able to grow itself. So using the class made in task 1, make a class named as Stack, having following additional functionalities: bool empty() : Returns whether the Stack is empty or not. Time Complexity should be: O(1) bool full() : Returns whether the Stack is full or not. Time Complexity should be: O(1)int size() : Returns the current size of the Stack. Time Complexity should be: O(1)Type top () : Returns the last element of the Stack. Time Complexity should be: O(1) void push(Type) : Adds the element of type Type at the top of the stack. Time Complexity should be: O(1) Type pop() : Deletes the top most element of the stack and returns it. Time Complexity should be: O(1) Write non-parameterized constructor for the above class. Write Copy…arrow_forward
- Stack Simulation Create a java program that will simulate PUSH() and POP() operations using a 1-D array representation.Each operation is dependent from each other and it's carried out in the next question in a sequential order.Given:Empty STACK with 10 elements.arrow_forwardStack: Stacks are a type of container with LIFO (Last In First Out) type of working, where a new element is added at one end and (top) an element is removed from that end only. Your Stack should not be of the fixed sized. It should be able to grow itself. bool empty() : Returns whether the Stack is empty or not. Time Complexity should be: O(1) bool full() : Returns whether the Stack is full or not. Time Complexity should be: O(1)int size() : Returns the current size of the Stack. Time Complexity should be: O(1)Type top () : Returns the last element of the Stack. Time Complexity should be: O(1) void push(Type) : Adds the element of type Type at the top of the stack. Time Complexity should be: O(1) Type pop() : Deletes the top most element of the stack and returns it. Time Complexity should be: O(1) Write non-parameterized constructor for the above class. Write Copy constructor for the above class. Write Destructor for the above class. Now write a global function show stack which…arrow_forwardQ dynam dequeue operation|arrow_forward
- A queue and a deque data structure are related concepts. Deque is an acronym meaning "double-ended queue." With a deque, you may insert, remove, or view from either end of the queue, which distinguishes it from the other two. Use arrays to implement a dequearrow_forward4) Priority Queue Application Homework • Unanswered Situation: The order in which patients at a certain emergency room are seen by the doctor is based on arrival time minus 10 minutes for each major wound, minus 5 minutes for each minor wound, and plus 3 minutes for each time the patient annoys the nurse. You can assume a maximum wait time of 2 days. If a priority queue is used in the software at the nurses' station, would you use a minimum heap or a maximum heap to implement the priority queue? (Thought-provoker: Do you think if you annoyed the nurse enough, s/he would smack you around enough for you to move to the head of the line?)arrow_forwardNonearrow_forward
arrow_back_ios
SEE MORE QUESTIONS
arrow_forward_ios
Recommended textbooks for you
- C++ Programming: From Problem Analysis to Program...Computer ScienceISBN:9781337102087Author:D. S. MalikPublisher:Cengage Learning
C++ Programming: From Problem Analysis to Program...
Computer Science
ISBN:9781337102087
Author:D. S. Malik
Publisher:Cengage Learning