上QQ阅读APP看书,第一时间看更新
Questions and exercises
- Give an example where you can use a composite pattern.
- For an array of 10 elements with a random set of integers, identify the maximum and minimum. Calculate the complexity of the algorithm.
- To manage the state of an object, which structural pattern is relevant?
- A window is sub-classed to add a scroll bar to make it a scrollable window. Which pattern is applied in this scenario?
- Find the complexity of a binary tree search algorithm.
- Identify the submatrices of 2x2 in a 3x3 matrix. What is the complexity of the algorithm that you have used?
- Explain with a scenario the difference between brute force and backtracking algorithms.
- A rules engine uses backtracking to identify the rules affected by the change. Show an example where backtracking identifies the affected rules.
- Draw a flow chart for the algorithm of the calculation of profit-loss given the cost price, selling price, and quantity.
- Write the pseudo code for an algorithm that compares the strings and identifies the substring within a string.