Write the C++ code to implement the Queue and Node classes a…
Write the C++ code to implement the Queue and Node classes according to the tests. Do not add any public method that is not needed to support the tests below. No need to implement big three except the destructor No points will be given for any functionality other than what is implied through the assertions below. No points will be given for implementations that do not use linked-list data structures. Hint: The CHECK(bool expression); statement will succeed when the bool expression gives true; Thus, CHECK(ids.length() == 2); means we expect that the method call ids.length() to return a value of 2. Assume that all includes of user head files are present. Only implement the class and methods used here, as well as anything required by these methods. Assume that you implement both classes in one pair of hpp/cpp files or a single hpp file. Use comments to show the file names before the file contents if you are using multiple files. test.cpp #define CATCH_CONFIG_MAIN#include “catch/catch.hpp”#include “../my-queue.hpp”TEST_CASE(“Test head operations”){ MyQueue line; line.enqueue(10); line.enqueue(8); CHECK(line.length() == 2); int n = line.dequeue(); CHECK(n == 10); CHECK(line.length() == 1); n = line.peek(); CHECK(n == 8); CHECK(line.length() == 1); n = line.dequeue(); CHECK(n == 8); CHECK(line.length() == 0); n = line.dequeue(); // return -1 when the queue is empty CHECK(n == -1); }
Read DetailsGiven the array {6, 11, 8, 7, 9}, show the results of the ar…
Given the array {6, 11, 8, 7, 9}, show the results of the array after one round of quick partition is performed. Assuming that we are following the algorithm covered in class (Hoare’s). The middle element at index (high + low) / 2 is picked as the pivot value.
Read DetailsGiven a list {2, 34, 17, 12, 6, 10, 50}. If we always select…
Given a list {2, 34, 17, 12, 6, 10, 50}. If we always select the middle element (formula middle = (high + low) / 2) as the pivot. Finish the following: Show the calculation of the middle index and the value of the pivot Show the movement of the low and high cursors and the swaps One round quick partition process finishes when low and high meet, show the returned value as the low index
Read Details