subject

You are given as input an array a[1..n], with n entries. also, you know that, the array consists of a series of 0’s followed by a series of 1’s, but you don’t know how many of each there are. your goal is to find the first 1 in the array. there is a cost associated with checking the value of an entry in the array. each time you check a value and it turns out to be 0, you must pay 1 dollar. if value turns out to be 1, you have to pay 1 "famous algorithmist trading card (fatc)". in each of the parts of this question, you will have some number of dollars and some number of fatcs. you must give an algorithm which will return the index of the first (lowest indexed) 1 which works given your resources. for each part write pseudocode and explain why your algorithm works, given your resources.
(a) you have n dollars and n fatc
(b) you have 1 dollars and n fatc
(c) you have 10 log n dollars and 10 log n fatc
(d) you have 2 dollars and 10n.5 fatc
(e) you have k dollars and 10kn+/k fatc, for some constant k.

ansver
Answers: 1

Another question on Computers and Technology

question
Computers and Technology, 22.06.2019 15:00
This is not a factor that you should use to determine the content of your presentation. your audience your goals your purpose your technology
Answers: 1
question
Computers and Technology, 22.06.2019 20:10
Assume the existence of a bankaccount class. define a derived class, savingsaccount that contains two instance variables: the first a double, named interestrate, and the second an integer named interesttype. the value of the interesttype variable can be 1 for simple interest and 2 for compound interest. there is also a constructor that accepts two parameters: a double that is used to initialize the interestrate variable, and a string that you may assume will contain either "simple", or "compound", and which should be used to initialize the interesttype variable appropriately. there should also be a pair of functions getinterestrate and getinteresttype that return the values of the corresponding data members (as double and int respectively).
Answers: 2
question
Computers and Technology, 23.06.2019 02:30
Which component acts as a platform on which application software runs
Answers: 2
question
Computers and Technology, 24.06.2019 08:50
Write a program that will compute the volume of ice cream served in a cone. as you can see in the diagram below, the ice cream is served as a hemisphere of frozen deliciousness on top of a cone, which is also packed with frozen deliciousness. thus, the total volume of ice cream sold is the volume of the hemisphere plus the volume of the cone. the example shows an ice cream cone in which the hemisphere and cone have a radius of 10 inches and the cone has a height of 15 inches. your program must instead prompt for these two values, which are taken from the keyboard as integers: • the hemisphere/cone radius in inches, and
Answers: 3
You know the right answer?
You are given as input an array a[1..n], with n entries. also, you know that, the array consists of...
Questions
question
History, 10.09.2020 01:01
question
Mathematics, 10.09.2020 01:01
question
Social Studies, 10.09.2020 01:01
Questions on the website: 13722361