Draft:Difference array
This article, Draft:Difference array, has recently been created via the Articles for creation process. Please check to see if the reviewer has accidentally left this template after accepting the draft and take appropriate action as necessary.
Reviewer tools: Preload talk Inform author |
This article, Draft:Difference array, has recently been created via the Articles for creation process. Please check to see if the reviewer has accidentally left this template after accepting the draft and take appropriate action as necessary.
Reviewer tools: Preload talk Inform author |
An array that takes a sequence of numbers and stores the differences between each element in the array. More generally an array where . The difference array of a sequence can be denoted as . Commonly a difference array is use to make a series of range queries with constant time complexity:[1][2]
Properties
[edit | edit source]Inverse Function
[edit | edit source]A difference array can be undone using a prefix sum array. Here the prefix sum array is denoted as where is an arbituary constant prepending the prefix sum array. Given that is by plugging into the prefix sum function .[2]
Uniqueness of Difference Arrays
[edit | edit source]only has a single difference array . If no additional inputs are given uses the elements of to form the difference array. The non-communativity of subtraction only allows for single way to represent a given difference array.[2]
Usage
[edit | edit source]Range Queries
[edit | edit source]Range queries are an array modifying operation that add a value to a defined range of values
- Left and right indices of the range of elements to edit (inclusive).
- Value to add to the elements within .
Difference arrays are used to update arrays that are modified using range queries within constant time.[3] initially the difference array has each element set to 0. Difference arrays when modified using a range query only require changes to the elements that lie on the bounds of the range query. So given a range query of the elements of will remain unchanged except for at index and . This allows for the entire range query to be expressed by modifying and rather than updating each element between.[4][1]
By performing a prefix sum on , once added to in where each matching index is added to the others, the resulting array will be as if each query was performed. This allows for any number of queries to to be performed within a single iteration.[3]
Proof
[edit | edit source]The relative differences of the values that lie within the range will remain unchanged after a range query is performed. However the elements and will have their relative differences change. Since each element within is increasing by element will be greater than the previous entry, similarly element will be x less than the next entry in the array.
Thus the middle x cancels out showing that has no effect on the differences of the middle values.
Steganalaysis
[edit | edit source]Methods of JPEG base steganography can be detected using difference arrays. It has been shown that Markov features that were extracting from zigzag intra-block and inter-block difference array improve steganography detection substantially. By calculating difference arrays along the horizontal and vertical directions of the JPEG's data array, then applying a Markov matrix to these difference arrays intra-block features are able to be constructed.[5]
References
[edit | edit source]- ^ a b Lua error in Module:Citation/CS1/Configuration at line 2172: attempt to index field '?' (a nil value).
- ^ a b c Lua error in Module:Citation/CS1/Configuration at line 2172: attempt to index field '?' (a nil value).
- ^ a b Lua error in Module:Citation/CS1/Configuration at line 2172: attempt to index field '?' (a nil value).
- ^ Lua error in Module:Citation/CS1/Configuration at line 2172: attempt to index field '?' (a nil value).
- ^ Lua error in Module:Citation/CS1/Configuration at line 2172: attempt to index field '?' (a nil value).