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
Digiron [165]
3 years ago
13

Mergesort uses the divide-and-conquer technique to sort a list. True False

Computers and Technology
1 answer:
NARA [144]3 years ago
6 0

Answer:

True: Merge Sort sorts a list using divide-conquer approach.

<u>Merge_Sort(B,p,n)</u>  //p is the starting index of array B and n is the last index.

1. if(p<n)

2.        q ← (p+n)/2    //divides the list into two sub-lists

2.        Merge_Sort(B, p, q) //sorts the left half

3.        Merge_Sort(B, q+1, n) //sorts the right half.

4.        Merge(B, p, q, n)

<u>Merge(B, p, q, n)</u>

1.l ← q-p+1.  //no. of elements in left half

2.m ← n-q  //no. of elements in right half.

3.for x ← 1 to l

4.      Left[x] = B[p+x -1] //The elements of left half are copied to Left array

5.for y ← 1 to m.

6.      Right[y]= B[q+y]  //The elements of right half are copied to right array

7. x ← 1, y ←1

8.for z ← p to n.

9.      if( Left[x] ≤ Right[y] ) // to merge the two lists Left and Right, the    //elements are compared.

10.     {   A[z] ← Left[x]   //smaller one comes to the merged list.

11.          x++. }

12.    else

13.      {   A[z] ← Right[y]

14.          y++ }

Explanation:

The Merge_Sort(A, p, n) algorithm first divides the whole array into two halves. Then again divides the sub-lists into it's halves and so on.

Then using merge algorithm it compares the elements of both halves one by one and keep it in sorted order.

You might be interested in
Write a method named lastIndexOf that accepts an array of integers and an * integer value as its parameters and returns the last
evablogger [386]

Answer:

The method is as follows:

public static int lastIndexOf(int [] numbers, int num){

    int lastIndex = numbers[0];

    for(int i =0; i<numbers.length;i+=num){

        lastIndex = numbers[i];

    }

    return lastIndex;

}

Explanation:

This defines the method

public static int lastIndexOf(int [] numbers, int num){

This initializes the lastIndex to the first element of the array

    int lastIndex = numbers[0];

This iterates through every "num" element of the array

    for(int i =0; i<numbers.length;i+=num){

This gets the current index... until the last

        lastIndex = numbers[i];     }

This returns the last

    return lastIndex; }

7 0
2 years ago
In the URL, what is the subdomain and what is the domain name?
timurjin [86]

<u>Answer</u>:

<u>EXAMPLES:</u>

Primary domain name could be “bestwebdesigner.com,”

subdomain to that domain called “blog.bestwebdesigner.com.”

<u>Explanation</u>:

Essentially, a subdomain is a separate part of your website that operates under the same primary domain name.

5 0
3 years ago
Suppose that, even unrealistically, we are to search a list of 700 million items using Binary Search, Recursive (Algorithm 2.1).
damaskus [11]

Answer:

There is also an attachment below

Explanation:

Since we are talking about binary search, let's assume that the items are sorted according to some criteria.

Time complexity of binary search is O(logN) in worst case, best case and average case as well. That means it can search for an item in Log N time where N is size of the input. Here problem talks about the item not getting found. So, this is a worst case scenario. Even in this case, binary search runs in O(logN) time.

N = 700000000.

So, number of comparisions can be log(N) = 29.3 = 29.

So, in the worst case it does comparisions 29 times

7 0
3 years ago
What is the output of the following C++ code?
SVETLANKA909090 [29]

Answer:

Your not including anything in your code.

Explanation:

According to your text all you have is #include. You didn't incldue any directives so you will get a error.

6 0
2 years ago
Which statement best describes network security
Andreyy89
<span>B.network security means all personal information is kept safe the network is not compromised and only authorized users had access 

Im pretty sure they ment has instead of had</span><span />
3 0
2 years ago
Read 2 more answers
Other questions:
  • How to build an arch bridge​
    5·1 answer
  • The use of electronic media, information, and communication technologies to deliver instruction where students are not required
    8·1 answer
  • Windows 1.0 was not considered to be a "true" operating system but rather an operating environment because _____.
    13·1 answer
  • What is the purpose of the .NET Framework Class Library? a. it provides pre-written code that can be used by .NET applications b
    13·1 answer
  • What are the best data structures to create the following items? And why?
    13·1 answer
  • What is Human Dignity
    12·1 answer
  • When targeting customers of the consumer population at market a product, what type of segmentation information would be most hel
    12·2 answers
  • Drag the tiles to the correct boxes to complete the pairs.
    13·1 answer
  • Write an algorithm to verify a number as even​
    9·1 answer
  • In order to view a page break what should you do
    8·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!