Computers and Technology

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.

answer
Answers: 1

Other questions on the subject: Computers and Technology

image
Computers and Technology, 22.06.2019 11:00, bombbomb2157
Eva has many contacts on the professional networking site she uses which contacts are considered second degree
Answers: 3
image
Computers and Technology, 22.06.2019 11:00, lexhorton2002
The great length of north america causes the climate to be varied. true false
Answers: 2
image
Computers and Technology, 23.06.2019 02:00, mayapril813
Consider the following function main: int main() { int alpha[20]; int beta[20]; int matrix[10][4]; . . } a. write the definition of the function inputarray that prompts the user to input 20 numbers and stores the numbers into alpha. b. write the definition of the function doublearray that initializes the elements of beta to two times the corresponding elements in alpha. make sure that you prevent the function from modifying the elements of alpha. c. write the definition of the function copyalphabeta that stores alpha into the first five rows of matrix and beta into the last five rows of matrix. make sure that you prevent the function from modifying the elements of alpha and beta. d. write the definition of the function printarray that prints any onedimensional array of type int. print 15 elements per line. e. write a c11 program that tests the function main and the functions discussed in parts a through d. (add additional functions, such as printing a two-dimensional array, as needed.)
Answers: 3
image
Computers and Technology, 23.06.2019 03:30, patience233
Many everyday occurrences can be represented as a binary bit. for example, a door is open or closed, the stove is on or off, and the fog is asleep or awake. could relationships be represented as a binary value? give example.
Answers: 1
Do you know the correct answer?
You are given as input an array a[1..n], with n entries. also, you know that, the array consists of...

Questions in other subjects:

Konu
History, 07.12.2021 03:00