Menu

[Solved]-Trouble Making Numbers Put List Go Order Making Program List Insert 3 Numbers List 3 Numbe Q37222094

I am having trouble making the numbers that I put in the list goin order. I am making a program with a list where I can insert 3numbers into that list. The 3 numbers should be sorted afterinserted but are not. I have added a picture of the code andcurrent output.

#include “OListType.h”#include <iostream>bool OListType::insert(int item) { bool result = false; size_t i = count; if (!full()) { if (empty()) { list[0] = item; } else while (i > 0 && list[i – 1] > item) { list[i] = list[i – 1]; –i; } list[i] = item; ++count; result = true; } return result; }//void OListType::erase(int item) {//}//bool OListType::find(int item) {//}size_t OListType::binsearch(int item) { if (empty()) return count + 1; if (item == list[0]) return 0; if (item == list[count-1]) return count – 1; size_t i = 1, j = count – 2, mid; while (i <= j) { mid = (i + j) / 2; if (list[mid] == item) return mid; if (item < list[mid]) j = mid – 1; else i = mid + 1; }return count;}Y V uick Launch (Ctrl+Q) Piogram4 (Running)-Microset Viaual Studio Gar ett Momson GM nsert Test: Lifecycle Events Thread ProcY V uick Launch (Ctrl+Q) Piogram4 (Running)-Microset Viaual Studio Gar ett Momson GM nsert Test: Lifecycle Events Thread Process 110080 PiqramA exe 1, 2, 3, 4, 5, 6, 7, 8, 9, 16, 11, 12, 13, 14, 15, 16, 17, 18, 19, 28, 21, 22, 23, 24, 25, 26, 27, 29 29, 3, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44. 45, 46, 47, 48, 49 Progrem OLstlype InserL Tesl: possibly, the torest of the output ick 6 numbers that are over 49 to put in the lists ist A insert #1 : 75 ist A insert 2 86 ist A insert t3: 96 ist B insert #1 : 67 ist B insert 82: 59 st B insert 3: 86 his is only needed if there wes sceething aniguous in the rngras specifications snd you were unsble to resolve the Issue. Stste hat the include ciostrea List A: 1, 2, 3. 4, 5, 6, 7, 8, 9, 18, 11, 12, 13, 14, 15, 16, 17, 18, 19, 28, 21, 22, 23, 24, 25, 26, 27, 28 oo1 resalttalse 29, 3%, 31, 32, 33, 34, 35, 36, 37, 38, 39, , 41, 2, 13, 14, 45, 46, 47, 18, 19, 75, 86, 96 if (oepty)) List B 1stie-ites 7, 59, 86 ull Test he list is not full isti ist -11 1 istiitcs: 1count; result-truc rase Value 99 Test: 1, 2, 3, 1, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28 29, 38, 31, 32, 33, 34, 35, 36, 37, 33, 39, 40, 41, 42, 43, 44, 45, 46, 47, 43, 49, 75, 86, 96 wosd OListTyperserasecint iten ull Test 2: list is not tul1 /Phool dListype::find(int itas) izc Test: f (oepty) turn count +1 if くitei–11strel) return e; if (itist[rnt-1)) return count : ind 38 Test ind 101 Test: was not tound Type Test list is not empty All Test: ist A Test 2: list is empty Autos Locas Watch 1 7, 59, 86 u 35 ubiah Show transcribed image text Y V uick Launch (Ctrl+Q) Piogram4 (Running)-Microset Viaual Studio Gar ett Momson GM nsert Test: Lifecycle Events Thread Process 110080 PiqramA exe 1, 2, 3, 4, 5, 6, 7, 8, 9, 16, 11, 12, 13, 14, 15, 16, 17, 18, 19, 28, 21, 22, 23, 24, 25, 26, 27, 29 29, 3, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44. 45, 46, 47, 48, 49 Progrem OLstlype InserL Tesl: possibly, the torest of the output ick 6 numbers that are over 49 to put in the lists ist A insert #1 : 75 ist A insert 2 86 ist A insert t3: 96 ist B insert #1 : 67 ist B insert 82: 59 st B insert 3: 86 his is only needed if there wes sceething aniguous in the rngras specifications snd you were unsble to resolve the Issue. Stste hat the include ciostrea List A: 1, 2, 3. 4, 5, 6, 7, 8, 9, 18, 11, 12, 13, 14, 15, 16, 17, 18, 19, 28, 21, 22, 23, 24, 25, 26, 27, 28 oo1 resalttalse 29, 3%, 31, 32, 33, 34, 35, 36, 37, 38, 39, , 41, 2, 13, 14, 45, 46, 47, 18, 19, 75, 86, 96 if (oepty)) List B 1stie-ites 7, 59, 86 ull Test he list is not full isti ist -11 1 istiitcs: 1count; result-truc rase Value 99 Test: 1, 2, 3, 1, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28 29, 38, 31, 32, 33, 34, 35, 36, 37, 33, 39, 40, 41, 42, 43, 44, 45, 46, 47, 43, 49, 75, 86, 96 wosd OListTyperserasecint iten ull Test 2: list is not tul1 /Phool dListype::find(int itas) izc Test: f (oepty) turn count +1 if くitei–11strel) return e; if (itist[rnt-1)) return count : ind 38 Test ind 101 Test: was not tound Type Test list is not empty All Test: ist A Test 2: list is empty Autos Locas Watch 1 7, 59, 86 u 35 ubiah

Expert Answer


Answer to I am having trouble making the numbers that I put in the list go in order. I am making a program with a list where I can… . . .

OR


Leave a Reply

Your email address will not be published. Required fields are marked *