I asked this question for general transpositions and it seemed too hard, I only got one answer which didn't seem to give a guaranteed asymptotic speed-up. So suppose we apply a sequence of adjacent transpositions to a numeric array (an adjacent transposition swaps two adjacent numbers) and we want to maintain the solution of the maximum sum subinterval after each adjacent transposition. We could repeat Kadane's linear time solution from scratch on the entire array after every adjacent transposition. So that is what I want to beat. Can this be done in sublinear time per adjacent transposition, say if we do N or N^2 adjacent transpositions for an array of size N, and we are allowed to do preprocessing as long as the amortized preprocessing time is sublinear for the entire set of applied transpositions?
Updating maximum sum subinteral in an array in sublinear time when an adjacent transposition is applied
420 Views Asked by user2566092 At
1
There are 1 best solutions below
Related Questions in ARRAYS
- Two different numbers in an array which their sum equals to a given value
- how to fill out the table with next values in array with one button
- How to sort a multi-dimensional array by the second array in descending order?
- Looping over defined array elements in Fortran
- Array appending after each onclick and loop in javascript
- PHP : How can I check Array in array?
- store numpy array in mysql
- Java Assign a Value to an array cell
- Saving FileSystemInfo Array to File
- Notice: Undefined offset: 1, but there is such offset
- How can I determine the index of the same set of characters between two strings that are of different lengths?
- Caused by: java.lang.ArrayIndexOutOfBoundsException: length=8; index=8
- Pull out first occurrences from array
- How to read a file then store to array and then print?
- C++ won't read in scientific notation data from a .txt file
Related Questions in ALGORITHM
- Two different numbers in an array which their sum equals to a given value
- Given two arrays of positive numbers, re-arrange them to form a resulting array, resulting array contains the elements in the same given sequence
- Time complexity of the algorithm?
- Find a MST in O(V+E) Time in a Graph
- Why k and l for LSH used for approximate nearest neighbours?
- How to count the number of ways of choosing of k equal substrings from a List L(the list of All Substrings)
- Issues with reversing the linkedlist
- Finding first non-repeating number in integer array
- Finding average of an array
- How to check for duplicates with less time in a list over 9000 elements by python
- How to pick a number based on probability?
- Insertion Sort help in javascript -- Khan Academy
- Developing a Checkers (Draughts) engine, how to begin?
- Can Bellman-Ford algorithm be used to find shorthest path on a graph with only positive edges?
- What is the function for the KMP Failure Algorithm?
Related Questions in DYNAMIC-PROGRAMMING
- Dynamic programming algorithm and recurrence relation
- Recursively divide a list that each iteration divides into two parts to get the closest sum overall
- Arrangements with the following conditions
- Finding longest common subsequence in O(NlogN) time
- Wagner–Fischer algorithm
- How do I keep track of path in TSP?
- Find the total number of distinct Non decreasing arrays possible
- Ways to fill a hole of length L with sticks of lengths s and t
- At most k adjacent 1s (Maximum Value limited neighbors)
- Maximum xor of a range of numbers
- Compute DP[n][m] faster
- Minimum difference between sum of two numbers in an array
- Knapsack with unbounded items
- Unbounded knapsack/coin change with optimal solution for non-standard coins
- coin change recurrence solution
Related Questions in AMORTIZED-ANALYSIS
- Asymptotic complexity of binary heaps implemented with sets vs. priority queues
- Find the amortized complexity of a Hash function
- Understanding Amortized Time and why array inserts are O(1)
- Doubling and incremental strategy while implementing stack using linked list and arrays?
- Create a potential function for an abstract queue data structure to show constant amortized-time complexity
- Equivalent data structures with same bounds in worst case (vs. amortized)
- Questions on the design and analysis of Fibonacci heaps
- Amortized worst case complexity of binary search
- Can an operation that takes O(1) amortized time have worst-case O(n^2) time?
- How can I ensure amortized O(n) concatenation from Data.Vector?
- How to loop through a list of loans in Python to generate amortization schedule?
- Amortized cost of insert/remove on min-heap
- Amortized Time Calculation in AVL tree
- Big-O: Getting all of the keys in a Java HashMap
- Updating maximum sum subinteral in an array in sublinear time when an adjacent transposition is applied
Trending Questions
- UIImageView Frame Doesn't Reflect Constraints
- Is it possible to use adb commands to click on a view by finding its ID?
- How to create a new web character symbol recognizable by html/javascript?
- Why isn't my CSS3 animation smooth in Google Chrome (but very smooth on other browsers)?
- Heap Gives Page Fault
- Connect ffmpeg to Visual Studio 2008
- Both Object- and ValueAnimator jumps when Duration is set above API LvL 24
- How to avoid default initialization of objects in std::vector?
- second argument of the command line arguments in a format other than char** argv or char* argv[]
- How to improve efficiency of algorithm which generates next lexicographic permutation?
- Navigating to the another actvity app getting crash in android
- How to read the particular message format in android and store in sqlite database?
- Resetting inventory status after order is cancelled
- Efficiently compute powers of X in SSE/AVX
- Insert into an external database using ajax and php : POST 500 (Internal Server Error)
Popular Questions
- How do I undo the most recent local commits in Git?
- How can I remove a specific item from an array in JavaScript?
- How do I delete a Git branch locally and remotely?
- Find all files containing a specific text (string) on Linux?
- How do I revert a Git repository to a previous commit?
- How do I create an HTML button that acts like a link?
- How do I check out a remote Git branch?
- How do I force "git pull" to overwrite local files?
- How do I list all files of a directory?
- How to check whether a string contains a substring in JavaScript?
- How do I redirect to another webpage?
- How can I iterate over rows in a Pandas DataFrame?
- How do I convert a String to an int in Java?
- Does Python have a string 'contains' substring method?
- How do I check if a string contains a specific word?
This answer describes a "double-ended" variant of Kadane that can be used as the basis for an algorithm with O(log n)-time updates. This variant is useful also for parallelization.
Recall that Kadane's algorithm maintains two quantities:
max(a.k.a.max_so_far), the maximum subarray sum, andmax_right(a.k.a.max_ending_here), the maximum sum of a subarray that extends from the right boundary. Double-ended Kadane computes two more quantities:max_left, the maximum sum of a subarray that extends from the left boundary, andmax_left_right, the maximum sum of a subarray that extends from the left and right boundaries (i.e., the sum of the array). Store this information in the following structure.Now given result structures for two arrays, we can compute a result structure for their concatenation. The correctness proof should be easy if you understand Kadane and I haven't screwed up :)
For completeness, compute a result structure for zero and one elements.
Now, put all of these result structures in a segment tree. Whenever you update one of the values at a leaf, recompute the result structures for its ancestors and read off the
maxfield at the root. As a practical optimization, if you detect that one of the recomputations had no effect, you can skip the subsequent ones for that update.