Software engineer iii Interview Questions | Glassdoor.ca

# Software engineer iii Interview Questions

10,025

software engineer iii interview questions shared by candidates

## Top Interview Questions

Sort: RelevancePopular Date

Nov. 3, 2012
 implement sqrt without using math libray9 Answerse^((ln(x))/2)I think exp and ln still require a Math library. How about using Newton's method to find the root of f(x) = x^2 - a, where x is the solution (the sought square root) and where a is the number for which you want to find the square root?I would have implemented either Taylor or MacLaurin series, centered at an integer number that is closest to the number that you want to find the square root for, such that the square root of this integer is clean. So if you wanted to find the square root of 8.5, I would centre the series at 9 (sqrt(9) = 3), then compute the series at that point. I'd probably choose between 8 and 10 terms, as that is what is used in any scientific calculator.Show more responsesActually, to add to that, I wouldn't be able to include 8 - 10 terms, as that would rely on the square root operation itself.... so I'd have to rely on a linear approximation.This is the way to go. Fast inverse square root as used in Quake III. float Q_rsqrt( float number ) { long i; float x2, y; const float threehalfs = 1.5F; x2 = number * 0.5F; y = number; i = * ( long * ) &y; // evil floating point bit level hacking i = 0x5f3759df - ( i >> 1 ); // what the fuck? y = * ( float * ) &i; y = y * ( threehalfs - ( x2 * y * y ) ); // 1st iteration // y = y * ( threehalfs - ( x2 * y * y ) ); // 2nd iteration, this can be removed return y; }For detailed explanation of the algorithm, see http://en.wikipedia.org/wiki/Fast_inverse_square_rootI wouldn't know about this algorithm, but I can think of a (definitely slower than this one) bisection algorithm to find the root of x^2 = number.Often what they are looking for is a programming data structures oriented solution. Such as using binary search to find sq root etc.poop

Sep. 12, 2012

Mar. 19, 2009

### Senior Software Engineer at Amazon was asked...

Aug. 16, 2012
 Write a function that divides one number by another, without using the division operator, and make it better than O(n).7 AnswersThis can be done in a recursive function, the following code is in Python. # get result of a/b without using a "divide" operator def div(a,b): if a < b: return 0 else: return div(a-b, b)+1 This is how human being do the division naturally, however, the running time of this is O(n/m), where n is the size of a, and m is the size of b, which means, O(n/m) is guaranteed to be less than O(n), when m is larger than 1. -MaximThe answer above is still O(n). We can use binary search and find the answer in the interval [1,a] and use multiplication operator.Totally agree with Vasil. Other option: Long Division Algorithm. O(log n) anyway.Show more responseswhy not just a * b^(-1) :-)// Write a function that divides one number by another, without using the division operator, // Assume that x%y = 0 // O(log n) (function() { 'use strict'; var divide = function(x, y) { var xLength = (x + '').length; var i = 0; var result = 0; var xAry = ('' + x).split(); var xStart = ''; for (i = 1; i = y) { xStart -= y; result = parseInt(result, 10) + 1; } } } return result; }; console.log(divide(1000, 4)); })();Use logarithms? O(1) log(x/y) = log(x) - log(y) = log(answer) answer = 10 ^ log(answer)Convert the number to divide into the base of the number that you are dividing with and then shift the 'bits' to the right by 1 then convert back to decimal

Dec. 19, 2013

### Software Engineer at Morgan Stanley was asked...

Feb. 28, 2012
 A few questions on basic command-line syntax in Unix shells: 1. How would you log output and error messages from a command to a file? 2. How would you run the same command on every file in a directory? 3. How would you find the PID of a named process (say if you wanted to kill it)?6 Answers1. command >file 2>&1 2. cd dir; for i in *; do command; done 3. ps | grep processname or ps -C processname#3 I disagree, more like ps aux |awk '\$0 ~ /ProcessName/ && \$0 !~ /awk/ {print \$2}' If you want the PID#3 To find the PID: pgrep -xShow more responses#3 - to find the PID Or simply use: pidofOpps!! there is typo; it should be: pidof1. ./sample.sh &> output.txt :- to capture output and error message suppose sample.sh have below script: #!/bin/bash cat file1 cp file2 file3 lets assume there's no file2 exists in the current directory, returns an error message 2. from any current directory run the below line by line. for i in `find -maxdepth 1 -type f` do cat \$i >> output.txt done in for loop i stores all the files (type f means normal file type) in a current directory (maxdepth 1), suppose you want to consider all subdirectory files remove this part. then redirecting all the files to output.txt 3. ps -ef | grep -i "*process name* ps displays running processes, -e utility here displays all the processing shell processes without ignoring any process, f gives the full text/all info of processes. if you are not sure on the exact process name give * as above by giving part of the process name that you can remember

Jan. 27, 2014

### Software Engineer at Zenefits was asked...

Mar. 21, 2015
 Given a Binary Search Tree with integers at every node and an integer k, write code that decides whether or not there exists two nodes a and b such that a+b=k6 AnswersSomething like this? (Untested) private class Node { public boolean ContainsSum(int k) { return ContainsSum_(k, new ArrayList()); } protected boolean ContainsSum_(int k, ArrayList vals) { for (int i : vals) { if (i + m_val == k) return true; } vals.add(m_val); return (m_right != null && m_right.ContainsSum_(k, vals)) || (m_left != null && m_left.ContainsSum_(k, vals)); } private int m_val; private Node m_left; private Node m_right; }can you please list some more questionsPretty good solution listed aboveShow more responsesThe solution mentioned above is O(n^2), because for every node, it is comparing value with all the nodes in Vals array. We can do better than this because we have BST, which is in sorted order. (For unsorted Binary tree, we should have sorted first in O(nlogn) and then searched O(nlogn). O(nlogn) solution - Traverse the BST with DFS (O(n)). For each node of value 'a' search for node of value "b = k - a". Searching in BST would be O(logn). Thus the solution becomes O(nlogn)HashMap tracker = new HashMap(); public SumPair parseTree(Node node, int sum) { if (node == null) { return null; } SumPair pair = parseTree(node.left, sum); if (pair == null) { pair = parseTree(node.right, sum); } if (pair == null) { if (tracker.containsKey(node.data)) { pair = new SumPair(node, tracker.get(node.data)); } else { tracker.put(sum - node.data, node); } } return pair; }With a node reference to left,right and parent, it can be done in O(n) Start at deep left with 2 node references at lowest node, value L. move one reference in DFS way until it find a node R >= K-L. if equal then we have a L and R then move the first reference to the next value in DFS, until node L > K-R repeat until last node is reached and L + R > K lot of micro-optimization possible (skip a whole node by going direct to parent when the parent is still lower than what we looking for)

### Front End Developer at IBM was asked...

Apr. 10, 2019
 1. To add an HTTP request to the search engine, then log a result depending on the# of pages and requirements. 2. Use DP to implement a Knapsack-like problem. Restrictions on time complexity. 3. Implement a to-do list's delete method on website.5 AnswersDid u get rejected or just not receive an offer yet?To X: Get rejectedDid they request to do a background screening on you before rejecting?Show more responsesNoThanks for replying, it seems they requested to do a background check on me currently

### Software Developer at PokerStars was asked...

Jun. 13, 2014
 Very very hard, they ask you to do a poker project for 8 hours and give no feedback after and ask you to leave5 AnswersWell...I did the project and got onsite 1 day later. Got offer right after the onsite.....it got to be your code really really not good.....80k salary +20k bonusBtw I declined the 100k offerSo it's not 100k + 20k bonus :) Well, to go for full day interview several times they have to attract you with something. I bet you feel great... It's definitely cheating... Honestly, I wouldn't waste my time with such interviews even if they promise you 150K + bonus. It's unprofessional :)Show more responsesI got the job and love it. Again,maybe you did not do as well as you thought.Code test was really fun. I enjoyed it, as it makes you think hard. The interview was real grilling. I managed to answer half of the questions. Got the job. Now I am the one grilling people on interviews. If you are weak - go work for a bank or something.
110 of 10,025 Interview Questions