Question

Instruction: In C++ you are going to apply RadixSort to sort vectors. The input starts with an integer number which indicates the number of vectors to be sorted. Then vectors follow, one vector per line. Each vector consists of 10 numbers where each number has a value in {0, 1, 2, 3}. Entries of a vector are separated by a space.

NOTE: READ THE INSTRUCTIONS PLEASE. DO NOT JUST COPY & PASTE CODE.

Examples of input and output Input 3333322222 2322222222 1300210000 1300220000 2321222222 Output :2 3:3:3:3:3:2:2:2:2:2; 22002 00222 22002 00222 22002 00222 22002 00222 22-22 12222 32222 22223 32001 00123 32002 u00223 33333 it 33333 532112 C 11223

0 0
Add a comment Improve this question Transcribed image text
Answer #1

#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;

int main()
{
    vector<vector<int> > VECT;
    int n, n1;
    cout<<"Enter number of vectors: ";
    cin>>n;
    for(int i = 0; i < n; i++)
    {
        vector<int> vect; // create vector of vectors.
        for(int j = 0; j < 10; j++){
           cin>>n1;
            vect.push_back(n1);
        }
        VECT.push_back(vect); //store vectors into VECTOR
    }
    sort(VECT.begin(), VECT.end());
    cout<<"outPut: \n";
    for(int i = 0; i < VECT.size(); ++i)
    {
        for(int j = 0; j < VECT[i].size(); ++j)
            cout << VECT[i][j]<<";";
        cout << endl;
    }

    return 0;
}

Sh-4.2 main Enter number of vectors: 3 3 3 3 3 111145 ΘΘΘ2344322 outPut: 0,0,0,2,3,4;4;3,2,2; sh-4.2$

Add a comment
Know the answer?
Add Answer to:
Instruction: In C++ you are going to apply RadixSort to sort vectors. The input starts with...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • Please use counting sort. RadixSort In this assignment you will im Input structure You are going...

    Please use counting sort. RadixSort In this assignment you will im Input structure You are going to apply RADIXSORT to sort vectors. The input starts with an integer number which indicates the number of vectors to be sorted. Then vectors follow, one vector per line. Each vector consists of 10 digits where each digit has a value in 0...9. Entries of a vector are separated by a space Output structure Output the sorted sequence of vectors, one per line. Vector...

  • All to be done in C++ no user input is required. Just need to create vectors...

    All to be done in C++ no user input is required. Just need to create vectors and create functions to manipulate them as described. Search 2D Vector - Part 2 Write a C++ program that uses a function to search a 2D vector of floats. The function will have 2 parameters: 1. A 2 dimensional vector of floats, v 2. The floating point number that you are searching for, item Rewrite the Search_2D_Vector function so that it can work with...

  • C language Thank you Jojo is going to a restaurant. There are N foods listed in...

    C language Thank you Jojo is going to a restaurant. There are N foods listed in the menu, and the items are sorted increasingly based on its price. Now Jojo is wondering how many foods are there with price P. As the number of food in the menu can be a lot, Jojo will need your help to answer his questions. Jojo knows you can count really fast, so he will give you M questions. Format Input Input begins with...

  • In C++ language, implement a class that can sort an array of numbers using all three...

    In C++ language, implement a class that can sort an array of numbers using all three algorithms we have seen in this course, but each method updates a “counter” value every time it accesses the array. Have it print this at the end of the sorting process. Store the array values in an “original” array so you don’t have to re-type it for different sorts (since each sort alters the array), and have the sort modify a copy. Note: IF...

  • In C++ language, implement a class that can sort an array of numbers using all three...

    In C++ language, implement a class that can sort an array of numbers using all three algorithms we have seen in this course, but each method updates a “counter” value every time it accesses the array. Have it print this at the end of the sorting process. Store the array values in an “original” array so you don’t have to re-type it for different sorts (since each sort alters the array), and have the sort modify a copy. Note: IF...

  • I want this using while loop This using stringin python Use list or some thing in...

    I want this using while loop This using stringin python Use list or some thing in python Using list in python I want answer as soon as posdible E. Last Number time limit per test: 1 second memory limit per test: 256 megabytes input standard input output standard output You are given a sequence of positive integers aj, , 03, ... Print the last element of the sequence. Input The input consists of multiple lines. The i-th line contains a...

  • //bubble sort implementation// Fig 6.15 with simplified convention for the for loop. #define _CRT...

    //bubble sort implementation// Fig 6.15 with simplified convention for the for loop. #define _CRT_SECURE_NO_WARNINGS //for windows os only #include <stdio.h> #include <stdlib.h> // Fig. 6.15: fig06_15.c // Sorting an array's values into ascending order. #include <stdio.h> #define SIZE 10 // function main begins program execution int main(void) {    // initialize a    int a[SIZE] = { 2, 6, 4, 8, 10, 12, 89, 68, 45, 37 };    printf("Data items in original order");    // output original array    for (int i = 0;...

  • IN C++ PLEASE -------Add code to sort the bowlers. You have to sort their parallel data...

    IN C++ PLEASE -------Add code to sort the bowlers. You have to sort their parallel data also. Print the sorted bowlers and all their info . You can use a bubble sort or a shell sort. Make sure to adjust your code depending on whether or not you put data starting in row zero or row one. Sort by Average across, lowest to highest. The highest average should then be on the last row.. When you sort the average, you...

  • In this assignment you are going to handle some basic input operations including validation and manipulation,...

    In this assignment you are going to handle some basic input operations including validation and manipulation, and then some output operations to take some data and format it in a way that's presentable (i.e. readable to human eyes). Functions that you will need to use: getline(istream&, string&) This function allows you to get input for strings, including spaces. It reads characters up to a newline character (for user input, this would be when the "enter" key is pressed). The first...

  • I need help writing this code in C++ Proj11.cpp is provided as well as the randomdata.txt thank you in advance! Objectives: The main objectives of this project is to introduce you to recursion,...

    I need help writing this code in C++ Proj11.cpp is provided as well as the randomdata.txt thank you in advance! Objectives: The main objectives of this project is to introduce you to recursion, and test your ability to work with some STL functionalities. A review of your knowledge on working with templates, dynamic data structures, as well as manipulating dynamic memory, classes, pointers and iostream to all extents, is also included. Description: For the entirety of this project, you will...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT