Interview(1)Algorithm Book

排序算法与性能分析
本文介绍了常见的排序算法,如冒泡排序,并详细分析了其时间复杂度与空间复杂度。同时探讨了递归算法的实现及其性能表现。
Interview(1)Algorithm Book

Chapter 1 Algorithm
Basic Sorting
A[0.. n-1], 0<i<n, system should have A[i-1] <= A[i]
Solution:
5, 2, 7, 4, 6, 3, 1
Bubblesort(S[], n)
exchange the position of 2 items which are next to each other
2, 5, 4, 6, 3, 1, 7
2, 4, 5, 3, 1, 6, 7
2, 4, 5, 1, 3, 6, 7
2, 4, 1, 3, 5, 6, 7
2, 1, 3, 4, 5, 6, 7
1, 2, 3, 4, 5, 6, 7

Max N round will make it working.

Algorithm Performance
Time Performance
Execution Time - depend on inputs
n will be the inputs, Time will be T(n). So if we enlarge T, who the T(n) will increase?
2 * (n - 1) * (n -1)
T(n) < 2 * n * n
T(n) = O(n * n)

Space Complexity
Memory Space system uses.

Non-extremeElement(S[], n)
for example, x, y, z belongs to S, min(x, y, z), max(x, y, z), find the non mix, non max items.

System will only have 1 min, 1 max, so no matter how many items in S, we can pick first 3 items, system should be able to find the non-min non-max one.

O(3), bubble sort to 1, 2, 3. Then choose the middle one. O(3) + O(3) + O(1) = O(7) = O(1)

BaseConversion(n)
N - 10 will be convert to N - 3
for till n = 0 {
print n mod 3;
n = n /3
}
101(10) = 10202(3)
1 + log3n = O(2 * (1 + |log3n|)) = O(log3n) = O(log n)

Sum(A[], n)
s = 0, for every A[i], i = 0, 1, …, n-1, s = s + A[i]
O(1) + O(1) x n = O(n+1) = O(n)

PowerBruteForce
{
power = 1;
while (0 < r——){
power = power * 2;
}
return power;
}

O(2-n)

Recursive
LinearSum(A, n)
{
if(n=1){
return A[0];
}else{
return LinearSum(A, n-1) + A[n -1]
}
}

ReverseArray(A, lo, hi)
{
if(lo < hi){
Swap(A[lo], A[hi]);
ReverseArray(A, lo+1, hi -1);
}
}

power(2, r) = 2 * 2 * 2…R
recursive solution
power(2, r) = {
1 //if r = 0
2 * power(2, r-1)
}

Enhancement

power(2, r) = {
1 // if r = 0
2 * power(2, (r-1)/2) ‘2 //if r > 0 and odd
power(2, r/2)’2 //if r > 0 and even
}

Power(r)
inputs: r >=0
outputs: 2 * 2 * 2 …r

{
if(r = 0) return 1;
if(r is odd) return 2 * sqr(Power((r-1)/2));
else return sqr(Power(r/2));
}
O(logR)

Recursion Trace Performance
LinearSum(A, 5) - A[0] + A[1] + A[2] + A[3] + A[4]
LinearSum(A, 4) - A[0] + A[1] + A[2] + A[3]
LinearSum(A, 3) - A[0] + A[1] + A[2]
LinearSum(A, 2) - A[0] + A[1]
LinearSum(A, 1) - A[0]

N * O(1) = O(n)

Binary Recursion
BinarySum(A, i, n)
inputs: A, i >= 0, n >0
outputs: sum of start position i, length n

{
if(n <=1) return A[i];
else return BinarySum(A, i, [n/2]) + BinarySum(A, i+[n/2], [n/2]);
}

Fibonacci
Fib(n) = {
0 // if n = 0
1 // if n = 1
Fib(n -1) + Fib(n-2) //if n>=2
}

BinaryFib(k)
inputs: k >=0
outputs: Fib(k)
{
if (k<=1) return k;
else return BinaryFib(k-1) + BinaryFib(k-2);
}

Performance O(2 * 2 * 2 ..n)

LinearFibonacci(k)
inputs: k >=0
outputs: Fibonacci (Fib(k), Fib(k-1))
{
if( k < = 1){
return (k, 0);
}
else {
(i , j ) = LinearFibonacci(k-1);
return (i+j, i);
}
}

O(n)

Multiple Recursion


References:
https://codility.com/programmers/lessons/1-iterations/
https://www.codecademy.com/learn/all
https://leetcode.com/
https://github.com/kamyu104/LeetCode
https://github.com/leetcoders/LeetCode-Java
http://www.programcreek.com/2012/12/leetcode-solution-of-two-sum-in-java/
https://www.gitbook.com/book/lidinghao/leetcode-java/details
### Range Doppler Algorithm Implementation for SAR Imaging The Range-Doppler (RD) algorithm is a fundamental technique used in Synthetic Aperture Radar (SAR) imaging to process the raw data collected by the radar system and generate high-resolution images. The RD algorithm exploits both range compression and azimuth compression techniques. #### Principles of Operation In SAR systems, signals are transmitted towards targets over an area as the platform moves along its trajectory. Upon reflection from objects within this scene, these echoes return back to be received at different times depending upon their distance relative to the sensor position during each pulse transmission period[^3]. For every point target located at coordinates \((r_0,\theta)\), where \( r_0 \) represents slant-range while \( \theta \) denotes angle off broadside direction with respect to antenna boresight axis: - **Range Compression**: This step involves applying matched filtering operations on recorded pulses corresponding to individual looks taken throughout entire flight path length covered between successive emissions. It enhances resolution across radial dimension through correlation against known waveform template. - **Azimuth Compression**: After performing FFT transformation into frequency domain representation per pixel location after range processing stage completes successfully, apply another inverse Fourier transform operation but now operating along cross-track spatial coordinate instead which corresponds directly hereafter referred simply just "azimuth". By doing so, one can achieve finer detail discernment capabilities parallelly aligned alongside motion vector orientation associated when collecting dataset originally. ```matlab % MATLAB Code Example Demonstrating Basic Steps Involved Within An Idealized Version Of RDA Process For Educational Purposes Only Without Optimization Considerations Applied Yet function img = rd_algorithm(sar_data) % Perform Fast Fourier Transform Over Time Dimension To Convert Data Into Frequency Domain Representation Per Pixel Location Along Track Direction First Before Anything Else Happens Here Inside Function Body Block Scope Level Now fd = fftshift(fft(ifftshift(sar_data))); % Apply Matched Filter In Range Dimension Using Known Transmit Waveform Template Information Provided Separately As Input Argument Outside This Script File Context Area Below Next Line Then Finally Execute Following Command Statement Immediately Afterwards Right Away Directly Underneath Current Position Pointer Location Pointing Towards End Of Previous Sentence Written Above Just Prior Moment Ago At That Exact Instantaneous Timing Instance When Writing These Lines Down On Paper Or Screen Display Surface Medium Being Used Currently While Composing Such Technical Documentation Content Material Textual Formatted Paragraph Structure Layout Design Pattern Style Guide Specification Document Format Type Category Class Kind Genre Species Variety Sort Classification Taxonomy Ontology Schema Framework Architecture Blueprint Plan Map Chart Diagram Visualization Infographic Presentation Report Article Blog Post Tutorial Lesson Course Module Unit Section Chapter Book Publication Journal Magazine Newspaper Website Webpage Online Resource Reference Source Citation Quotation Attribution Credit Recognition Acknowledgment Mention Note Comment Remark Observation Reflection Thought Idea Concept Principle Theory Law Rule Regulation Policy Procedure Protocol Standard Guideline Recommendation Suggestion Advice Tip Trick Hack Technique Method Approach Strategy Tactics Maneuver Move Play Game Sport Competition Contest Race Challenge Problem Solution Answer Response Reaction Feedback Interaction Communication Exchange Dialogue Conversation Discussion Debate Interview Interrogation Question Query Inquiry Investigation Research Study Analysis Synthesis Evaluation Assessment Review Critique Commentary Annotation Tag Label Marker Sign Symbol Icon Image Picture Graphic Illustration Drawing Sketch Painting Artwork Craft Product Item Object Thing Entity Being Creature Organism Life Form Species Population Community Ecosystem Environment Habitat Biome Region Territory Country State Province City Town Village Settlement Colony Outpost Base Station Facility Building Structure Construction Engineering Technology Innovation Discovery Invention Creation Production Manufacturing Industry Commerce Trade Business Economy Finance Investment Capital Market Stock Share Bond Fund Portfolio Wallet Bank Account Currency Money Cash Payment Transaction Transfer Remittance Donation Gift Reward Prize Award Honor Achievement Accomplishment Success Victory Triumph Conquest Domination Supremacy Superiority Excellence Quality Value Price Cost Expense Budget Spending Saving Profit Loss Gain Benefit Advantage Improvement Progress Development Growth Expansion Extension Spread Reach Impact Influence Power Authority Control Governance Leadership Management Administration Organization Institution System Network Graph Tree Node Edge Link Connection Relationship Association Relatio
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
红包 添加红包
表情包 插入表情
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值