package com.test;import java.util.Stack;public class PostOrderTraversal {static class Node {int data;Node left, right;Node(int item) {data = item;left = right;}}private void pfIterate(Node root) {Node prev = null;Stackstack = new Stack<>(); stack.push(root);while (!stack.isEmpty()) {root = stack.pop();if (root.left == null && root.right == null) {System.out.print(root.data + " ");prev = root;} else if (prev == root.left || prev == root.right) {System.out.print(root.data + " ");prev = root;} else {stack.push(root);if (root.right != null)stack.push(root.right);if (root.left != null)stack.push(root.left);}}}public static void main(String[] args) {// Let us create trees shown in above diagramNode root = new Node(1);root.left = new Node(2);root.right = new Node(3);root.left.left = new Node(4);root.left.right = new Node(5);root.right.left = new Node(6);root.right.right = new Node(7);new PostOrderTraversal().pfIterate(root);}}
I have given a lot of interviews before however, this one was special. Let me start from the beginning. I got a call from Progress Software and was scheduled for the first telephonic discussion. Next day, I got a call from HR and she asked me questions on Java and a few basic puzzles. After clearing the previous round, I got scheduled for the second telephonic interview. This interview covered Java, design-related problems and algorithms. After a week, I got a call from the HR for the onsite interviews in Hyderabad. This is the first time I googled about Progress Software. I said yes for the onsite interviews. Journey to onsite started not as planned after my flight got delayed. Because of fog-related delay in Delhi, I reached the PSI (Progress Software India) office couple of hours late. HR introduced me to the first interviewer. The interviewer explained the first round. It was a coding round (I am not a big fan of coding rounds), the problem was ...
Comments
Post a Comment