Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

what does this logic error mean? And what do i do to fix it. Done in C++ #pragma once #include // std::less #include // std::iterator_traits

what does this logic error mean? And what do i do to fix it. Done in C++

#pragma once

#include // std::less

#include // std::iterator_traits

namespace sort {

// This is C++ magic which will allows our function

// to default to using a

// is unspecified. It uses defines std::less

// for the iterator's value_type.

//

// For example: if you have a vector, the

// iterator's value type will be float. std::less

// will select the

// default comparator.

template

using less_for_iter = std::less::value_type>;

/* Efficiently swap two items - use this to implement your sorts */

template

void swap(T & a, T & b) noexcept { /* TODO */

T temp = std::move(a);

a = std::move(b);

b = std::move(temp);

}

template>

void bubble(RandomIter begin, RandomIter end, Comparator comp = Comparator{}) {

// Random access iterators have the same traits you defined in the Vector class

// For instance, difference_type represents an iterator difference

// You may delete the types you don't use to remove the compiler warnings

using _it = std::iterator_traits;

using difference_type = typename _it::difference_type;

using value_type = typename _it::value_type;

using reference = typename _it::reference;

using pointer = typename _it::pointer;

RandomIter beg = begin;

for(RandomIter i = begin; i

k = i;

for(RandomIter j = beg + 1; j

if(comp(*j,*beg)){

swap(*beg,*j);

}

++beg;

}

}

}

template>

void insertion(RandomIter begin, RandomIter end, Comparator comp = Comparator{}) {

RandomIter beg = begin;

for(RandomIter i = begin + 1; i

if(comp(*i, *(i-1))){

swap(*i, *(i-1));

beg = i - 1;

for(RandomIter j = i - 2; begin

if(comp(*beg,*j)){

swap(*beg,*j); --beg;

}

else{

break;

}

}

}

}

}

template>

void selection(RandomIter begin, RandomIter end, Comparator comp = Comparator{}) {

RandomIter min = begin;

RandomIter j = begin;

for(RandomIter i = begin; i

min = i;

for(j = i + 1; j

if(comp(*j, *min)){

min = j;

}

}

swap(*min, *i);

}

}

}

ERROR IM RECIEVING image text in transcribed

C CMD: 0 ----STDOUT---- make: Entering directory '/autograder/source/tests' gt+ -atd-ct+17 -Wa11 -pedantic -DDebUG - - - rtest/1nc1ude -Iinclude -I../, /aubmission rtest/utils/menhook.cpe -o rteat/utilaembook.e -c g+t -std=ct+17 -Wall -pedantic -DDeguc -g -Irtest/include -Iinclude -I../../submission rtest/utils/xoshiro256.cpp -o rtcst/utils/xoshiro2s6.a -c g++ -stdmet+17 -Nall -pedantic -pDegus -g -Irtest/include -Iinclude I//submission rtest/utils/typegen.cpp 0 rtest/utils/typegen.o c gt+ -std=ct+17 -Wall -pedantic -DDebuG g-Irtent/include -Iinclude -I.././submission rtest/utils/assertions.cpp -a rtest/utila/assertions.a -c [=(] kunning 1 test cases. [ Run ] somT.bubble_comparisons tests/bubble_comparisons.cpp; 36: Failure Expected : true hetual : false [ FAILED ] sORT.bubble_compariaons (82000n8) [=---e-e-e] 1 test cases ran. [ Passed ] D terta. [ FAILed ] 1 tests, listed below : [ FAILED ] SORT.bubble_compariaons rm rtest/utils/menhook.o rtest/utils/xoshiro256.a rtest/utils/typegen.o rtest/utils/assertions.o make: Leaving directory '/autograder/saurec/teste' -- --STDERR--- In file ineluded fron inelude/executable.h:14, fron tests/bubble_comparisons.epp:1: ../../subaission/sorting.ht In funetion 'void sortitbubble(Randomiter, Randoniter, Comparator)'i 34 | using difference_type - typenane _ititdifference_type; ./../submission/sorting-h:35:23: warning: typedef 'using value_type = typename it:syalue_type' locally defined but not used [-Wunused-local-typedefs] 35 | using value_type - typename_1t;ivalue_type; .//../subanisian/sorting.h:36:23: warning: typedef 'using reference = typenane it:lreference' locally defined but not uscd [-Wunused-lacal-typedefs] 36 | using reterence = typename it:treterence; ../../subaission/sorting.hi37:23: warning: typedef 'using pointer - typename _ititpointer' locally defined but not used [-hunused-local-typedefs] 37 | using pointer = typename itilpointer; BRROR; Vector is not sortedl Are you using the Comparator oomp? Your vector; [0.520754,0.599029] Correct vector: [0.599029,0.520754] make: *** [rtestakefile:94: run/bubble_comparisons] Error 1 Test exited with 2 on cmd 'nake -C testa RTEST_SRC_DIR=../../submission j12 run/bubble_comparisons

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Practical Database Programming With Visual Basic.NET

Authors: Ying Bai

1st Edition

0521712351, 978-0521712354

More Books

Students also viewed these Databases questions