Create a second vector object vi and a list object li

Assignment Help Computer Engineering
Reference no: EM131843839

Problem

Compared to an array, a linked list features easier addition and removal of elements but is slower to sort .This raises a possibility: Perhaps it might be faster to copy a list to an array, sort the array, and copy the sorted result back to the list than to simply use the list algorithm for sorting. (But it also could use more memory.) Test the speed hypothesis with the following approach:

a. Create a large vector object vi0, using rand() to provide initial values.

b. Create a second vector object vi and a list object li of the same size as the original and initialize them to values in the original vector.

c. Time how long the program takes to sort vi using the STL sort() algorithm, then time how long it takes to sort li using the list sort() method.

d. Reset li to the unsorted contents of vi0.Time the combined operation of copying li to vi, sorting vi, and copying the result back to li.

To time these operations, you can use clock() from the c time library. As in Listing 5.14, you can use this statement to start the first timing

clock_t start = clock ();

Then use the following at the end of the operation to get the elapsed time:

clock_t end = clock () ;
cout << double) (end - start) / CLOCKS_PER_SEC;

This is by no means a definitive test because the results will depend on a variety of factors, including available memory, whether multiprocessing is going on, and the size of the array or list. (One would expect the relative efficiency advantage of the array over the list to increase with the number of elements being sorted.) Also if you have a choice between a default build and a release build, use the release build for the measurement. With today's speedy computers, you probably will need to use as large an array as possible to get meaningful readings. You might try, for example, 100,000 elements, 1,000,000 elements, and 10,000,000 elements.

Reference no: EM131843839

Questions Cloud

How many stations are required using the longest work : What is the theoretical minimum number of stations? How many stations are required using the longest work element decision rule?
How cultural changes create changes in education : In a short response discuss how cultural changes create changes in education. In your response incorporate answers to the following questions.
Communication of thoughts and ideas : What role will technology play in the communication of thoughts and ideas?
How do you think the issue of an information gap : How do you think the issue of an information gap between generations, cultures, income levels, education can be resolved?
Create a second vector object vi and a list object li : Create a second vector object vi and a list object li of the same size as the original and initialize them to values in the original vector.
How the us mass media help shape arguments : What CNBC news story is presented in a class PowerPoint as a current example of how the U.S. mass media help shape arguments around social and political issues?
What would be the economic order quantity : Joe Henry's machine shop uses 2500 brackets during the course of a year. these brackets are purchased from a supplier 90 miles away.
What are some of the features offered by windows : What are some of the features offered by Windows 2003/2008? What are the advantages and disadvantages of ATM
Cultural differences and personality can impact cooperation : Cultural differences and personality can impact cooperation. Research the importance of teamwork and the impact of personal and cultural differences on team

Reviews

Write a Review

Computer Engineering Questions & Answers

  Mathematics in computing

Binary search tree, and postorder and preorder traversal Determine the shortest path in Graph

  Ict governance

ICT is defined as the term of Information and communication technologies, it is diverse set of technical tools and resources used by the government agencies to communicate and produce, circulate, store, and manage all information.

  Implementation of memory management

Assignment covers the following eight topics and explore the implementation of memory management, processes and threads.

  Realize business and organizational data storage

Realize business and organizational data storage and fast access times are much more important than they have ever been. Compare and contrast magnetic tapes, magnetic disks, optical discs

  What is the protocol overhead

What are the advantages of using a compiled language over an interpreted one? Under what circumstances would you select to use an interpreted language?

  Implementation of memory management

Paper describes about memory management. How memory is used in executing programs and its critical support for applications.

  Define open and closed loop control systems

Define open and closed loop cotrol systems.Explain difference between time varying and time invariant control system wth suitable example.

  Prepare a proposal to deploy windows server

Prepare a proposal to deploy Windows Server onto an existing network based on the provided scenario.

  Security policy document project

Analyze security requirements and develop a security policy

  Write a procedure that produces independent stack objects

Write a procedure (make-stack) that produces independent stack objects, using a message-passing style, e.g.

  Define a suitable functional unit

Define a suitable functional unit for a comparative study between two different types of paint.

  Calculate yield to maturity and bond prices

Calculate yield to maturity (YTM) and bond prices

Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd