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
AVprozaik [17]
3 years ago
8

Say you have a random, unordered list containing 4096 four-digit numbers. Describe the most efficient way to: sort the list and

then search for 100 elements within the list, and analyze the expected run time for this specific list's sorting and searching.
Engineering
1 answer:
Debora [2.8K]3 years ago
6 0

Answer:

Answer explained below

Explanation:

It is given that numbers are four-digit so maximum value of a number in this list could be 9999.

So we need to sort a list of integers, where each integer lies between [0,9999].

For these given constraints we can use counting sort which will run in linear time i.e. O(n).

--------------------------------------------------------------------------------

Psuedo Code:

countSort(int numList[]) {

int count[10000];

count[i] = 0; for all i;

for(int num in numList){

count[num]+= 1;

}

return count;

}

--------------------------------------------------------------------------------

Searching in this count array will be just O(1).

E.g. Lets say we want to search if 3 was present in the original list.

Case 1: it was present in the original list:

Then the count[3] would have been incremented by our sorting algorithm. so in case element exists then count value of that element will be greater than 0.

Case 2: it was not present:

In this case count[3] will remain at 0. so in case element does not exist then count of that element will be 0.

So to search for an element, say x, we just need to check if count[x]>0.

So search is O(1).

Run times:

Sorting: O(n)

Search: O(1)

You might be interested in
0 - 1"<br> -20<br> -15<br> -10<br> 5<br> 0 1 2 3<br> 0
faust18 [17]

Answer:

#WeirdestQuestionOfAllTime

Explanation:

8 0
3 years ago
A completely reversible heat pump produces heat ata rate of 300 kW to warm a house maintained at 24°C. Theexterior air, which is
Triss [41]

Answer:

Change in entropy S = 0.061

Second law of thermodynamics is satisfied since there is an increase in entropy

Explanation:

Heat Q = 300 kW

T2 = 24°C = 297 K

T1 = 7°C = 280 K

Change in entropy =

S = Q(1/T1 - 1/T2)

= 300(1/280 - 1/297) = 0.061

There is a positive increase in entropy so the second law is satisfied.

6 0
3 years ago
What is the thermal efficiency of this regeneration cycle in terms of enthalpies and fractions of total flow?
irga5000 [103]

Answer:

\eta =\dfrac{(h_3-h_4)-(h_2-h_1)}{(h_3-h_5)}

Explanation:

generally regeneration of cycle is used in the case of gas turbine. due to regeneration efficiency of turbine is increased but there is no effect on the on the net work out put of turbine.Actually in regeneration net heta input is decreases that is why total efficiency  increase.

 Now from T-S diagram

    W_{net}=W_{out}-W_{in}

   W_{net}=(h_3-h_4)-(h_2-h_1)

  Q_{in}=h_3-h_5

  Due to generation (h_5-h_2) amount of energy has been saved.

  Q_{generation}=Q_{saved}

So efficiency of cycle \eta =\frac{W_{net}}{Q_{in}}

  \eta =\dfrac{(h_3-h_4)-(h_2-h_1)}{(h_3-h_5)}

Effectiveness of re-generator

  \varepsilon =\dfrac{(h_5-h_2)}{(h_4-h_2)}

So the efficiency of regenerative cycle

\eta =\dfrac{(h_3-h_4)-(h_2-h_1)}{(h_3-h_5)}

7 0
2 years ago
A bridge hand consists of 13 cards. One way to evaluate a hand is to calculate the total high point count (HPC) where an ace is
son4ous [18]

Answer: Let us use the pickled file - DeckOfCardsList.dat.

Explanation: So that our possible outcome becomes

7♥, A♦, Q♠, 4♣, 8♠, 8♥, K♠, 2♦, 10♦, 9♦, K♥, Q♦, Q♣

HPC (High Point Count) = 16  

4 0
2 years ago
Find the largest number. The process of finding the maximum value (i.e., the largest of a group of values) is used frequently in
salantis [7]

Answer:

See Explanation

Explanation:

Required

- Pseudocode to determine the largest of 10 numbers

- C# program to determine the largest of 10 numbers

The pseudocode and program makes use of a 1 dimensional array to accept input for the 10 numbers;

The largest of the 10 numbers is then saved in variable Largest and printed afterwards.

Pseudocode (Number lines are used for indentation to illustrate the program flow)

1. Start:

2. Declare Number as 1 dimensional array of 10 integers

3. Initialize: counter = 0

4. Do:

4.1 Display “Enter Number ”+(counter + 1)

4.2 Accept input for Number[counter]

4.3 While counter < 10

5. Initialize: Largest = Number[0]

6. Loop: i = 0 to 10

6.1 if Largest < Number[i] Then

6.2 Largest = Number[i]

6.3 End Loop:

7. Display “The largest input is “+Largest

8. Stop

C# Program (Console)

Comments are used for explanatory purpose

using System;

namespace ConsoleApplication1

{

   class Program

   {

       static void Main(string[] args)

       {

           int[] Number = new int[10];  // Declare array of 10 elements

           //Accept Input

           int counter = 0;

           while(counter<10)

           {

               Console.WriteLine("Enter Number " + (counter + 1)+": ");

               string var = Console.ReadLine();

               Number[counter] = Convert.ToInt32(var);

               counter++;                  

           }

           //Initialize largest to first element of the array

           int Largest = Number[0];

           //Determine Largest

           for(int i=0;i<10;i++)

           {

               if(Largest < Number[i])

               {

                   Largest = Number[i];

               }

           }

           //Print Largest

           Console.WriteLine("The largest input is "+ Largest);

           Console.ReadLine();

       }

   }

}

8 0
3 years ago
Other questions:
  • A mass of 0.3 kg is suspended from a spring of stiffness 0.4 N/mm. The damping is 3.286335345 kg/s. What is the undamped natural
    5·1 answer
  • A team member who has been a good worker for many years has recently been doing poor work. You suspect that he may be tired of h
    6·1 answer
  • A simple Rankine cycle coal-fired power plant has given states identified in the following table. The power plant produces 2.1 b
    9·1 answer
  • Please help will give brainliest please answer all 3
    11·1 answer
  • true or false incident reports, such as situation reports and status reports enhance situational awareness and ensure that perso
    12·1 answer
  • A wine aerator is a small, in-bottle, hand-held pour-through or decantor top device using the venturi effect for aerating the wi
    9·1 answer
  • I want to explain what 2000 feet looks like to young children so that they can imagine it in class
    12·1 answer
  • Develop a simple Business plan as an entrepreneur​
    5·1 answer
  • 9. Imagine that you're performing measurements on a circuit with a multimeter. You measure a total circuit
    14·2 answers
  • The percentage modulation of AM changes from 50% to 70%. Originally at 50% modulation, carrier power was 70 W. Now, determine th
    15·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!