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
Anestetic [448]
3 years ago
9

Rewrite the MERGE procedure so that it does not use sentinels, instead stopping once either array L or R has had all its element

s copied back to A and then copying the remainder of the other array back into A.
Computers and Technology
1 answer:
Strike441 [17]3 years ago
4 0

Answer:

Merge sort is a sorting technique based on divide and conquer technique.

Explanation:

MERGE(A, p, q, r)

   n1 = q - p + 1

   n2 = r - q

    L[1..n1] and R[1..n2]   this creates the new array

   for i = 1 to n1

       L[i] = A[p + i - 1]

   for j = 1 to n2

       R[j] = A[q + j]

   i = 1

   j = 1

   for k = p to r

       if i > n1

           A[k] = R[j]

           j = j + 1

       else if j > n2

           A[k] = L[i]

           i = i + 1

       else if L[i] ≤ R[j]

           A[k] = L[i]

           i = i + 1

       else

           A[k] = R[j]

           j = j + 1

You might be interested in
What is a WYSIWYG program?
DanielleElmas [232]
D will be the answer a program that allows you to take a tutorial on html terminology
5 0
2 years ago
Read 2 more answers
Which of the following are peripheral devices?
Fittoniya [83]

Explanation:

I think it's speakers,

7 0
3 years ago
Read 2 more answers
Consider the code fragment below (with nested loops). int sum = 0;for (int i = 1; i < 5; i++) for (int j = 1; j <= i; j++)
sammy [17]

Answer:

Option d is the correct answer for the above question.

Explanation:

  • The first loop of the program has a second loop and then the statement. In this scenario, the second loop executes for the value of the first loop and the statement executes for the value of the second loop.
  • The first loop executes 4 times, Then the second loop or inner loop executes n times for the n iteration of the first loop, for example, 1 time for the first iteration of the first loop, 2 times for the second iteration of the first loop and so on.
  • Then the inner loop executes (1+2+3+4) iteration which gives the result 10 iterations.
  • The sum initial value is 0 and the "sum++", increase the value of the sum by 1.
  • So the value of the sum becomes 10 after completing 10 iterations of the inner for loop.
  • Hence the 10 will be the output. So the Option d is the correct answer while the other is not.
3 0
3 years ago
Given the char * variables name1, name2, and name3, write a fragment of code that assigns the largest value to the variable max
Assoli18 [71]

Answer:

The following code as follows:

Code:

max=name1;   //define variable max that holds name1 variable value.

if (strcmp(name2, max)>0)  //if block.

{

   max=name2;  //assign value to max.

}

if (strcmp(name3,max)>0)   //if block.

{

  max=name3; //assign value to max.

}

Explanation:

In the above code, we define a variable that is max. The data type of max variable is the same as variables "name1, name2, and name3" that is "char". In the max variable, we assign the value of the name1 variable and use if block statement two times. In if block, we use strcmp() function that can be defined as:

  • In first if block we pass two variables in strcmp() function that is "name2 and max" that compare string value. If the name2 variable is greater then max variable value so, the max variable value is change by name2 variable that is "max=name2".
  • In second if block we pass two variables in strcmp() function that is "name3 and max" that compare string value. If the name3 variable is greater then max variable value so, the max variable value is change by name3 variable that is "max=name3".

4 0
3 years ago
Write a python program to read four numbers (representing the four octets of an IP) and print the next five IP addresses. Be sur
sdas [7]

Answer:

first_octet = int(input("Enter the first octet: "))

second_octet = int(input("Enter the second octet: "))

third_octet = int(input("Enter the third octet: "))

forth_octet = int(input("Enter the forth octet: "))

octet_start = forth_octet + 1

octet_end = forth_octet + 6

if (1 <= first_octet <= 255) and (0 <= second_octet <= 255) and (0 <= third_octet <= 255) and (0 <= forth_octet <= 255):

   for ip in range(octet_start, octet_end):

       forth_octet = forth_octet + 1

       if forth_octet > 255:

           forth_octet = (forth_octet % 255) - 1

           third_octet = third_octet + 1

           if third_octet > 255:

               third_octet = (third_octet % 255) - 1

               second_octet = second_octet + 1

               if second_octet > 255:

                   second_octet = (second_octet % 255) - 1

                   first_octet = first_octet + 1

                   if first_octet > 255:

                       print("No more available IP!")

                       break

       print(str(first_octet) + "." + str(second_octet) + "." + str(third_octet) + "." + str(forth_octet))

else:

   print("Invalid input!")

Explanation:

- Ask the user for the octets

- Initialize the start and end points of the loop, since we will be printing next 5 IP range is set accordingly

- Check if the octets meet the restrictions

- Inside the loop, increase the forth octet by 1 on each iteration

- Check if octets reach the limit - 255, if they are greater than 255, calculate the mod and subtract 1. Then increase the previous octet by 1.

For example, if the input is: 1. 1. 20. 255, next ones will be:

1. 1. 21. 0

1. 1. 21. 1

1. 1. 21. 2

1. 1. 21. 3

1. 1. 21. 4

There is an exception for the first octet, if it reaches 255 and others also reach 255, this means there are no IP available.

- Print the result

8 0
3 years ago
Other questions:
  • Queue is the LIFO structure.<br><br> o True<br><br> o False
    8·1 answer
  • Where would the information needed to start a computer be stored
    10·1 answer
  • _____ is the widely used transport layer protocol that most Internet applications use with Internet Protocol (IP).
    9·1 answer
  • Displays are geared for a specific resolution. what is this resolution called?
    15·1 answer
  • Create a class named CarRental that contains fields that hold a renter's name, zip code, size of the car rented, daily rental fe
    13·1 answer
  • The ________ option contains the formatting and placeholders for all of the items that appear on a side.
    11·1 answer
  • What layer of the OSI model describes how data between applications is synced and recovered if messages don't arrive intact at t
    12·1 answer
  • Why are control components necessary in traditional software and generally not required in object-oriented software?​
    11·1 answer
  • True or False, In adversarial searching, agents using the MiniMax algorithm always select the state that has the highest guarant
    15·1 answer
  • When software is purchased, a _____ is being bought that gives the purchaser the right to use the software under certain terms a
    9·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!