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 07:30
Jasper and samantha are in a robotics competition. the guidelines state that the robots should be able to move a 10-gram weight at least 2 meters and turn in a circle. jasper and samantha have already built the robot. which step of the design process should they follow next to decide whether their robot meets the minimum criteria for the competition?
Answers: 1
question
Computers and Technology, 22.06.2019 18:00
When is it appropriate to use an absolute reference
Answers: 1
question
Computers and Technology, 22.06.2019 21:00
Kirk found a local community college with a two-year program and he is comparing the cost with that of an out-of-state two-year school. what is the expected total cost for one year at the local community college if kirk lives at home? what is the expected total cost for one year at the out-of-state school if kirk lives on campus?
Answers: 2
question
Computers and Technology, 23.06.2019 21:10
Asample of 200 rom computer chips was selected on each of 30 consecutive days, and the number of nonconforming chips on each day was as follows: 8, 19, 27, 17, 38, 18, 4, 27, 9, 22, 30, 17, 14, 23, 15, 14, 12, 20, 13, 18, 14, 20, 9, 27, 30, 13, 10, 19, 12, 26. construct a p chart and examine it for any out-of-control points. (round your answers to four decimal places.)
Answers: 2
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
Mathematics, 02.05.2021 21:00
question
Mathematics, 02.05.2021 21:00
question
Social Studies, 02.05.2021 21:00
question
Mathematics, 02.05.2021 21:00
question
Mathematics, 02.05.2021 21:00
question
Mathematics, 02.05.2021 21:00
question
Chemistry, 02.05.2021 21:00
Questions on the website: 13722360