This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Q.1 If we get maximum sum from left-subtree and and right subtree, Should we include the root node also? | |
| ANS: It is not compulsory to always include root node. For example: If root node is negative. | |
| Q.2 For a binary tree, Would the value of maximum sum will always greater than 0. | |
| ANS:NO, the value of maximum sum can also be negative. | |
| Q.3 What faith will be build to find Maximum Path Sum In Between Two Leaves Of Binary Tree? |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Q.1 Why to use stringBuilder in place of string? | |
| ANS: Because it is much faster and consumes less memory. | |
| Q.2 What will get updated , while iterating over the value of 'k' ? | |
| ANS: total will get updated to spart (total=part) | |
| previous calls will get updated to new calls. | |
| Q.3 What will happen if new_call is 0 and prev_call is also '0'? |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Q.1 Why the brute force approach won't work for the constraint(length of array<=20000)? | |
| ANS: The time-complexity for brute-force method will be O(n* 2^n). which will go beyond the array range for integers. | |
| Q.2 What is the width for the array? | |
| ANS: Width is the difference between the maximum and minimum element. | |
| Q.3 How the sorting wont affect finding the width for subsequence? |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Q.1 List the possible combination for performing XOR operation. | |
| ANS: 0 ^ 0 = 0 | |
| 0 ^ 1 = 1 | |
| 1 ^ 0 = 1 | |
| 1 ^ 1 = 0 | |
| Q.2 What is the brute-force method "to count all pairs with XOR in a range"? | |
| ANS: Firstly traverse the given array and generate all possible pairs from the given array and for each pair, check if bitwise XOR of the pair is less than or equal to 'high' and greater than or equal to 'low'. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Q.1 What does the search() function do in a trie? | |
| ANS: It searches for the given string ('key') in O(l) time complexity where 'l' is the length of the 'key'. | |
| Q.2 What does the startsWith() function do in a trie? | |
| ANS: It is somewhat similar to search() function. It searches for the string that starts with the given key ('prefix') | |
| Q.3 What is the difference between search() and startsWith() function? |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Q.1 Why we need to traverse level-order wise? | |
| ANS: Because we are finding width at each level using its left-most and right-most node indexes. | |
| Q.2 What is the role of queue in this? | |
| ANS: In the queue we are putting the position of each node, along with the node, so we will use that position to find the width(i.e. length between left-most node and right-most node) | |
| Q.3 How we will get the indexes of leftmost and rightmost node at each level? |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Q.1 Discuss the role of 'node-to-root path'. | |
| ANS: The nodes present in 'node-to-root path' will print the nodes present " 'k' 'k-1' 'k-2' ..... 1, 0 levels down" | |
| Q.2 How we are using print 'k' levels down function to print all the nodes at distance 'k' from a given 'node'? | |
| ANS: We are finding the node-to-root path. Let the nodes present in node to root path are (node,node1, .....root) then we will use print 'k' levels down to print node ('k' ,'k-1',.... '0') levels down respectively. | |
| Q.3 Why we are blocking the node while calling function print 'k' levels down? |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Q.1 Why we are creating arraylist? | |
| ANS: To store the sum of all nodes present at each diagonal level where the index of arraylist represent the diagonal level indexing of binary tree. | |
| Q.2 What we will store in queue? | |
| ANS: Queue will contain all the left child of elements added in arraylist. | |
| Q.3 What will the queue store at initial level? |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Q.1 What is the use of finding width of the binary tree? | |
| ANS: The width of the binary tree will decide the total no. of vertical levels present and also the size of arraylist. | |
| Q.2 Why we are creating arraylist? | |
| ANS: To store the sum of all nodes present at each vertical level where the index of arraylist represent the vertical level indexing of binary tree. | |
| Q.3 What we will store in queue? |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Q.1 What methodology is implemented to print Left View Of A Binary Tree. | |
| ANS: Level Order Traversal on the tree is implemented . | |
| Q.2 Why are we using queue? | |
| ANS: Queue is used over here to keep the track of point where we are changing the levels in the tree | |
| Q.3 Discuss the Time Complexity to print Left View Of A Binary Tree. |
NewerOlder