subject
Computers and Technology, 12.03.2021 15:00 nev322

Chris recently received an array p as his birthday gift from Joseph, whose elements are either 0 or 1. He wants to use it to generate an infinite long superarray. Here is his strategy: each time, he inverts his array by bits, changing all 0 to 1 and all 1 to 0 to get another array, then concatenate the original array and the inverted array together. For example, if the original array is [0, 1, 1, 0], then the inverted array will be [1, 0, 0, 1] and the new array will be [0, 1, 1, 0, 1, 0, 0, 1]. He wonders what the array will look like after he repeat this many many times. He ask you to help him sort this out. Given the original array pp of length n and two indices ,a, b (≪≪,≪(n≪a≪b,≪ means much less than) Design an algorithm to calculate the sum of elements between a and b of the generated infinite array p^, specifically, ∑≤≤p^∑a≤i≤bpi^. He also wants you to do it real fast, so make sure your algorithm runs less than ()O(b) time.

Required:
Explain your algorithm and analyze its complexity.

ansver
Answers: 3

Another question on Computers and Technology

question
Computers and Technology, 23.06.2019 04:31
Jennifer has to set up a network in a factory with an environment that has a lot of electrical interference. which cable would she prefer to use? jennifer would prefer to use because its metal sheath reduces interference.
Answers: 1
question
Computers and Technology, 25.06.2019 08:10
Memory aids that organize information for encoding are
Answers: 3
question
Computers and Technology, 25.06.2019 19:00
Abusiness wants to centralize its administrative tasks. at the same time, it wants the existing systems to manage and sustain the growing amount of work in a capable manner. which technology will the business meet its goals?
Answers: 1
question
Computers and Technology, 25.06.2019 22:30
If you were working on a mainframe, which of the following operating systems would you most likely be using?
Answers: 1
You know the right answer?
Chris recently received an array p as his birthday gift from Joseph, whose elements are either 0 or...
Questions
question
Mathematics, 23.06.2019 17:00
Questions on the website: 13722360