Giter Club home page Giter Club logo

bop2_lab10's Introduction

Task 1

Implement the missing functions in String.cpp and test your code execution with the debugger.

Aside from the constructor, you don't need to handle memory directly. All functions can be implemented using the already existing functions. You don't need to write more than 3-5 lines of code for any of the functions. Try to figure out the most elegant solution instead of manually handling characters.

Task 2

Implement quicksort as a template function that works on arbitrary types. Test it on different arrays. Use at least one built-in type such as int or double and at least one custom type such as Complex, Rational or Vector. Demonstrate your results via printing (i.e. overload operator<< if necessary).

Example usage:

int* t[4];
t[0] = new int(1);
t[1] = new int(-1);
t[2] = new int(10);
t[2] = new int(22);
quicksort(t, 4);

for (int i=0; i<4; i++) std::cout << t[i] << " ";

Complex* c[3];
c[0] = new Complex(0, 0);
c[1] = new Complex(1, -4);
c[2] = new Complext(3, 3);
quicksort(c, 3);

for (int i=0; i<3; i++) std::cout << c[i] << " ";

How do I use my old quicksort that worked with start and end?

You can wrap it in a new quicksort:

void quicksort(int** array, int size) {
    old_qsort(array, size, 0, size-1);
}

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.