could you help me please
Posted: Thu Jun 02, 2022 7:41 am
could you help me please
Q4: An array of size MAX_SIZE is used to implement a circular queue. Front, Rear, and count are tracked. Suppose front is 0 and rear is MAX_SIZE -1. How many elements are present in the queue? a) 0 b) MAX_SIZE-1 c) MAX_SIZE d) 1 Q5: A simple queue, if implemented using an array of size MAX_SIZE, gets full when: a) rear=MAX_SIZE-1 b) B. front (rear+1)%MAX_SIZE c) C. front-rear+1 d) D. rear= (rear+1)%MAX_SIZE Q6: Given the following data structures: 1. Singly linked list with only head pointer 2. Singly linked list with head and tail pointers 3. Doubly linked list with head and tail pointers Which can efficiently represent a stack and which for a queue? Explain your answer. Q7: Assume that you have an empty circular queue (array-based implementation) which can hold only four elements. What are the array indices of the back and the front elements after executing this series of queue operations: enqueue ("a"), enqueue("b"), getFront (), enqueue(“c"), enqueue("d"), dequeue (), dequeue (), dequeue (), enqueue("a"), enqueue ("b"), enqueue ("c"), dequeue (), getFront (), enqueue ("d"), dequeue ()
Q8: What is the sequence of popped out values if the following sequence of operations are performed on a stack: push(1), push(2), push(1), pop, push(2), pop, pop, pop, push(2), pop Q9: Consider the algorithm described in the following pseudocode. What would be the output for the input "goodluck"? 1 declare a stack of characters 2 while there are more characters in the word to read ) { 3 read a character 4 push the character on the stack 5} 6 while the stack is not empty ) { 7 pop a character off the stack 8 write the character to the screen 9 } Q10: What does the following code fragment do to the queue? 1 Stack stack = new Stack(); 2 while (!queue.isEmpty()) 3 stack.push(queue.dequeue ()); while (!stack.is Empty()) 4 5 queue. enqueue (stack.pop());
Q4: An array of size MAX_SIZE is used to implement a circular queue. Front, Rear, and count are tracked. Suppose front is 0 and rear is MAX_SIZE -1. How many elements are present in the queue? a) 0 b) MAX_SIZE-1 c) MAX_SIZE d) 1 Q5: A simple queue, if implemented using an array of size MAX_SIZE, gets full when: a) rear=MAX_SIZE-1 b) B. front (rear+1)%MAX_SIZE c) C. front-rear+1 d) D. rear= (rear+1)%MAX_SIZE Q6: Given the following data structures: 1. Singly linked list with only head pointer 2. Singly linked list with head and tail pointers 3. Doubly linked list with head and tail pointers Which can efficiently represent a stack and which for a queue? Explain your answer. Q7: Assume that you have an empty circular queue (array-based implementation) which can hold only four elements. What are the array indices of the back and the front elements after executing this series of queue operations: enqueue ("a"), enqueue("b"), getFront (), enqueue(“c"), enqueue("d"), dequeue (), dequeue (), dequeue (), enqueue("a"), enqueue ("b"), enqueue ("c"), dequeue (), getFront (), enqueue ("d"), dequeue ()
Q8: What is the sequence of popped out values if the following sequence of operations are performed on a stack: push(1), push(2), push(1), pop, push(2), pop, pop, pop, push(2), pop Q9: Consider the algorithm described in the following pseudocode. What would be the output for the input "goodluck"? 1 declare a stack of characters 2 while there are more characters in the word to read ) { 3 read a character 4 push the character on the stack 5} 6 while the stack is not empty ) { 7 pop a character off the stack 8 write the character to the screen 9 } Q10: What does the following code fragment do to the queue? 1 Stack stack = new Stack(); 2 while (!queue.isEmpty()) 3 stack.push(queue.dequeue ()); while (!stack.is Empty()) 4 5 queue. enqueue (stack.pop());