1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
olchik [2.2K]
3 years ago
14

In this problem you will test and analyze the following sorting algorithms: Selection, Bubble, Insertion, Merge, and Quick. You

can use the code provided in the lecture slides after modifying it to meet the following requirements: 1. Analyze the algorithms by sorting, in ascending order, arrays of 1000 integers (i.e., no need to use template functions as in the lecture slides). 2. Create three arrays of 1000 integers: BST, AVG, and WST. Where a. BST has 1000 integers already sorted in ascending order (e.g., 10, 20, 30, ...etc.). b. AVG has 1000 randomly generated integers, where each integer is between 0 and 100,000. c. WST has 1000 integers sorted in reverse order (e.g., 1000, 990, 980, ...etc.). 3. Test the five sorting algorithms with three 1000‐integer arrays: tBST, tAVG, and tWST. Before testing each algorithm, these three arrays (tBST, tAVG, and tWST) must be re‐initialize as copies from BST, AVG, and WST respectively (you can write a function to carry out the copy task). This is to make sure that all algorithms are tested with an identical set of arrays.
Computers and Technology
1 answer:
Tpy6a [65]3 years ago
5 0

Answer:

1) Selection, bubble and insertion sort requires no moves in the sorted array because there will be n comparisons in the array and no swapping would take place after each comparison so zero moves.

2) Bubble and insertion sort result in 999 comparisons as we are required to iterate only one time over the array. this can be easily explained from the diagram as in bubble sort all the elements will be in their sorted position so each element will be encountered only once.

3) In selection sort, any element is compared with all the elements and accordingly smaller is paced first so in the reverse sorted array there will be at least n^2 comparisons so n^2 moves.

4) in merge sort an array is always divided into n nos of parts and then sorted so in worst case as well as best case the array will be divided so same numbers of moves.

You might be interested in
Assume that nextWord is a String variable that has been given a String value consisting entirely of letters. Write some Java cod
wel

Answer:

The code example is given below with explanation in c++ language.

Explanation:

Comments will explain what's going on in the code. Below code is already compiled and tested.

#include <time.h>

#include <iostream>

#include <sstream>

using namespace std;

int main(void)

{

//defining start and end time variable

// which will be used to break the infinte loop

   time_t endwait;

   time_t start = time(NULL);

   time_t seconds = 3; // end loop after this time has elapsed

cout<<"Input your number :";

long userNum;

cin>> userNum;

// initializing end time by adding seconds with start time

   endwait = start + seconds;

   // defining outputString which will concatenate all the  

   // divisible numbers in loop

string outputString="";

// bool isCompleted will use to check whether our  

// loop breaks successfully or time is expired.

bool isCompleted=true;

// iterate loop until it comes to 1. as in loop

// the program already displayed the 1 value.

   while (userNum>1)

   {  

  // checking start and end time comparison to  

  // break the infinite loop after some seconds

    if(start >= endwait){

     cout<< "Program end never reached.";

     isCompleted=false;

     break;

 }

 

    userNum=userNum/2;

   // defining stringstream to convert from long to string

    stringstream longToString;

    longToString<<userNum;

  // concatenating all the values

    outputString = outputString + longToString.str()+" ";

   // re initializing the start time with current time.

       start = time(NULL);

   }

   

  // check if while loop breaks successfully then print the

   // series of numbers here.

   if(isCompleted) {

    cout << outputString;

}

   return 0;

}

8 0
3 years ago
The physical parts of Computer are kwon as<br>​
Anna35 [415]

Answer:

Computer hardware

Explanation:

Computer hardware includes the physical parts of a computer, such as the case,central processing unit (CPU), monitor, mouse, keyboard, computer data storage, graphics card, sound card, speakers and motherboard.

3 0
2 years ago
What type of html list will automatically place a list marker, or bullet point, indicator in front of each item? group of answer
scZoUnD [109]

Main Answer:What type of html list will automatically place a list marker, or bullet point, indicator in front of each item? group of answer choices description l <u>unordered list</u>

Sub heading:

How many types of html list and explain?

Explanation:

1.There are three types

unordered list

ordered list

description list

2.unordered list: is used to group a set of related items in no particular order.

Reference link:

https://brainly.com

Hashtag:

#SPJ4

3 0
2 years ago
An IT security threat is anything that might cause serious harm to a computer system.
Blababa [14]

Answer:

True

Explanation:

this is true because a threat can endanger the computer and its system

5 0
2 years ago
An email address contains the @ character. Write a program that takes asks for an email address input from the user and determin
Dvinal [7]

Answer:

Input: [email protected]

Output: the word is not an email adress

Explanation:

7 0
3 years ago
Other questions:
  • When was unicode invented?
    13·1 answer
  • You can use this effect to break a color into a percentage of its full strength.
    13·1 answer
  • You need to delegate AD RMS responsibilities to a junior administrator. You don't want to give the administrator more permission
    14·1 answer
  • What do you call an unsolicited email message that masquerades as coming from a legitimate sender, and attempts to get you to di
    11·1 answer
  • What are the pasting options in Outlook 2016? Check all that apply.
    10·2 answers
  • What are attribute grammars used for?
    8·1 answer
  • Given an integer n and an array a of length n, your task is to apply the following mutation to an: Array a mutates into a new ar
    5·1 answer
  • Tradegy deals with _____
    14·1 answer
  • Explain the<br>4 ways<br><br>ways of arranging icons.<br><br>​
    6·1 answer
  • In which drawer do you find blocks that allow you to use the A and B buttons on your micro:bit?
    13·2 answers
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!