A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://TheAlgorithms.github.io/C-Plus-Plus/d6/d57/array__right__rotation_8cpp.html below:

TheAlgorithms/C++: operations_on_datastructures/array_right_rotation.cpp File Reference

Loading...

Searching...

No Matches

Implementation for the Array right Rotation algorithm. More...

#include <cassert>
#include <iostream>
#include <vector>

Go to the source code of this file.

void  operations_on_datastructures::print (const std::vector< int32_t > &array)   Prints the values of a vector sequentially, ending with a newline character.
std::vector< int32_t >  operations_on_datastructures::shift_right (const std::vector< int32_t > &array, size_t shift)   Shifts the given vector to the right by the shift amount and returns a new vector with the result. The original vector is not mutated.
void  tests::test1 ()   A Test to check an simple case.
void  tests::test2 ()   A Test to check an empty vector.
void  tests::test3 ()   A Test to check an invalid shift value.
void  tests::test4 ()   A Test to check a very large input.
void  tests::test5 ()   A Test to check a shift of zero.
static void  test ()   Function to test the correctness of shift_right() function.
int  main ()   main function
void  tests::print (const std::vector< int32_t > &array)   Prints the values of a vector sequentially, ending with a newline character.
std::vector< int32_t >  tests::shift_right (const std::vector< int32_t > &array, size_t shift)   Shifts the given vector to the right by the shift amount and returns a new vector with the result. The original vector is not mutated.

Implementation for the Array right Rotation algorithm.

Shifting an array to the right involves moving each element of the array so that it occupies a position of a certain shift value after its current one. This implementation uses a result vector and does not mutate the input.

See also
array_left_rotation.cpp

Definition in file array_right_rotation.cpp.

◆ main()

main function

Returns
0 on exit

Definition at line 172 of file array_right_rotation.cpp.

172 {

174 return 0;

175}

static void test()

Function to test the correctness of shift_right() function.

◆ test()

Function to test the correctness of shift_right() function.

Returns
void

Definition at line 160 of file array_right_rotation.cpp.

160 {

166}

void test1()

A Test to check an simple case.

void test4()

A Test to check a very large input.

void test3()

A Test to check an invalid shift value.

void test2()

A Test to check an empty vector.

void test5()

A Test to check a shift of zero.


RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4