Question

In: Computer Science

Suppose that you have a list containing the following 10 letters: A C E G L...

Suppose that you have a list containing the following 10 letters: A C E G L M P S T Y. Binary search is applied for the following questions.

A)   What is the maximum number of comparisons needed to find if any letter in the alphabet is in the list?
B)   How many comparisons would it take to find if A is in the list? If K is in the list?

Solutions

Expert Solution


___________________________________________________________________

  
  





___________________________________________________________________

___________________________________________________________________

Note: If you have queries or confusion regarding this question, please leave a comment. I would be happy to help you. If you find it to be useful, please upvote.


Related Solutions

Python programming question: Suppose i have a list like: ['a:10', 'b:9', 'c:8', 'd:7', 'e:6', 'f:5', 'g:4',...
Python programming question: Suppose i have a list like: ['a:10', 'b:9', 'c:8', 'd:7', 'e:6', 'f:5', 'g:4', 'h:3', 'i:2', 'j:1', 'k:0'] How do i trans form this into a dictionary or something i can plot a graph with using these keys and value pairs? thanks.
Language C: Suppose you are given a file containing a list of names and phone numbers...
Language C: Suppose you are given a file containing a list of names and phone numbers in the form "First_Last_Phone." Write a program to extract the phone numbers and store them in the output file. Example input/output: Enter the file name: input_names.txt Output file name: phone_input_names.txt 1) Name your program phone_numbers.c 2) The output file name should be the same name but an added phone_ at the beginning. Assume the input file name is no more than 100 characters. Assume...
Consider a 5.00-L tank containing 375 g of Ar at a temperature of 25 °C. (a)...
Consider a 5.00-L tank containing 375 g of Ar at a temperature of 25 °C. (a) Calculate the pressure in the tank using both the ideal gas law and the van der Waals equation. (b) Which correction term, a(n/V)2 or bn, has the great- est influence on the pressure of this syste
4 -letter words'' are formed using the letters A, B, C, D, E, F, G. How...
4 -letter words'' are formed using the letters A, B, C, D, E, F, G. How many such words are possible for each of the following conditions? (a) No condition is imposed. Your answer is : (b) No letter can be repeated in a word. Your answer is : (c) Each word must begin with the letter A. Your answer is : (d) The letter C must be at the end. Your answer is : (e) The second letter must...
12. Assume that we randomly choose from the letters {A, B, C, D, E, F, G,...
12. Assume that we randomly choose from the letters {A, B, C, D, E, F, G, H, I, J, K, L} (without replacing the letters), until they have all been taken. (a) Find the probability that the letters A and K are chosen successively in the given order. (b) Find the probability that the letters G, H, I, are chosen successively in the given order. c) Find the probability that the string "LAI" appears somewhere in the sequence of letters....
Suppose you have 1.00 L of an aqueous buffer containing 60.0 mmol acetic acid (pKa =...
Suppose you have 1.00 L of an aqueous buffer containing 60.0 mmol acetic acid (pKa = 4.76) and 40.0 mmol acetate. The pH of this buffer is 4.58. What volume of 4.00 M NaOH would be required to increase the pH to 4.93?
Suppose you have 1.00 L of an aqueous buffer containing 60.0 mmol benzoic acid (pKa =...
Suppose you have 1.00 L of an aqueous buffer containing 60.0 mmol benzoic acid (pKa = 4.20) and 40.0 mmol benzoate. Calculate the pH of this buffer. What volume of 5.00 M NaOH would be required to increase the pH to 4.93?
Suppose you have the following reaction at equilibrium:                   C(s) + 2H2(g) = CH4(g),  ΔH = −74.8 kJ       .
Suppose you have the following reaction at equilibrium:                   C(s) + 2H2(g) = CH4(g),  ΔH = −74.8 kJ        What changes are expected to occur if the pressure of the system was increased? You may select multiple answers. The temperature would increase above the expected temperature increase resulting from the increased pressure.   The concentration of H2(g) would decrease   The amount of C(s) present would decrease             The concentration of CH4(g) would increase No change in the equilibrium would occur.   The concentration of CH4(g) would...
28 g of ice at -10⁰C is dropped in an insulated 75-g aluminum calorimeter cup containing...
28 g of ice at -10⁰C is dropped in an insulated 75-g aluminum calorimeter cup containing 140 g of water at 30⁰C. (a) Calculate the equilibrium temperature of the container. Specific heats of liquid water, ice and aluminum are 4186 J/(kg ⁰C), 2090 J/(kg ⁰C) and 910 J/(kg ⁰C)respectively. Latent heat of fusion for ice is 3.33 x 105 J/kg. (b) What if, find the final temperature if 68 g of ice had been dropped.
In how many ways can you rearrange the letters A, B, C, D, E?
In how many ways can you rearrange the letters A, B, C, D, E?
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT