Q2: a) Create a function void print() in QueueArray class that prints the elements from first to last. b) Create a function void reverseK(QueueArray q, int k) that reverse the first k elements in the q. if k = 0, it does nothing (return ;) else it reverses the first k element as: If the q [1,2,3,4] reverse(q,3) makes the q to be [3,2,1,4] If the q [7,8,2,14,5] reverse(q,4) makes the q to be [14,2,8,7,5] Test your functions in the main driver

C++ Programming: From Problem Analysis to Program Design
8th Edition
ISBN:9781337102087
Author:D. S. Malik
Publisher:D. S. Malik
Chapter17: Linked Lists
Section: Chapter Questions
Problem 5PE
icon
Related questions
Question
In c++
Q2: a) Create a function void print() in QueueArray class that prints the elements from first to last.
b) Create a function void reverseK(QueueArray<int> q, int k) that reverse the first k elements in
the q. if k = 0, it does nothing (return ;) else it reverses the first k element as:
If the q [1,2,3,4] reverse(q,3) makes the q to be [3,2,1,4]
If the q [7,8,2,14,5] reverse(q,4) makes the q to be [14,2,8,7,5]
Test your functions in the main driver
Transcribed Image Text:Q2: a) Create a function void print() in QueueArray class that prints the elements from first to last. b) Create a function void reverseK(QueueArray<int> q, int k) that reverse the first k elements in the q. if k = 0, it does nothing (return ;) else it reverses the first k element as: If the q [1,2,3,4] reverse(q,3) makes the q to be [3,2,1,4] If the q [7,8,2,14,5] reverse(q,4) makes the q to be [14,2,8,7,5] Test your functions in the main driver
Expert Solution
steps

Step by step

Solved in 2 steps with 1 images

Blurred answer
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
C++ Programming: From Problem Analysis to Program…
C++ Programming: From Problem Analysis to Program…
Computer Science
ISBN:
9781337102087
Author:
D. S. Malik
Publisher:
Cengage Learning