Giter Club home page Giter Club logo

lab3's Introduction

How to compile the program for question A: make lab3_A How to compile the program for question B: make lab3_B

The discussion of question B: the data recorded in the B_record.out are n = 1000, n = 10000, and n = 100000. The process will carry out for 10001000, 1000010000, 100000100000, 10000001000000 at least respectively.

(1) Insertion sort : belong to O(n^2)
	n = 1000   , insertion_sort(): 0.020977 seconds
	n = 10000  , insertion_sort(): 1.23384 seconds
	n = 100000 , insertion_sort(): 119.397 seconds 
	n = 1000000, insertion_sort(): 10799 seconds
(2) Sort in the algorithm header file : belong to O(nlogn)
	n = 1000   , sort(): 0.000542 seconds
	n = 10000  , sort(): 0.006992 seconds
	n = 100000 , sort(): 0.049793 seconds 
	n = 1000000, sort(): 0.424233 seconds

It is obvious that Sort in the algorithm header file is more effective than Insertion sort, and considered about the CPU clock timing unit that generates, we can compute a approximate ratio that the two different sort process takes.
Suppose that the clock rate of a computer is 1 G 
when n = 1000:
	Insertion_sort(): (1000 * 1000) / 10^9 / 10^3 = 10^(-6)
	Sort(): (1000 * log1000) / 10^9 / 10^3 = 10^(-8)
	10^(-6) / 10^(-8) = 100 (times)
    when n = 10000:
            Insertion_sort(): (10000 * 10000) / 10^9 / 10^3 = 10^(-4)
            Sort(): (10000 * log10000) / 10^9 / 10^3 = 10^(-7)
	10^(-4) / 10^(-7) = 1000 (times)
    when n = 100000:
            Insertion_sort(): (100000 * 100000) / 10^9 / 10^3 = 10^(-2)
            Sort(): (100000 * log100000) / 10^9 / 10^3 = 10^(-6)
	10^(-2) / 10^(-6) = 10000 (times)
when n = 1000000:
            Insertion_sort(): (1000000 * 1000000) / 10^9 / 10^3 = 10
            Sort(): (1000000 * log1000000) / 10^9 / 10^3 = 10^(-5)
            10^(-2) / 10^(-6) = 1000000 (times)

the above mentioned data are all approximate equal to the ratio of the real data.

lab3's People

Contributors

f26401004 avatar

Watchers

James Cloos avatar

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.