Zensar Technologies interview prep
9 practice questions on the topics candidates reported from Zensar Technologies interviews, with answers. The questions are ours; each one links to the interview report that names its topic.
Practise them as a timed round34 roles open at Zensar Technologies
DSA 1
-
B is the array A = [1, 2, 3] repeated forever: 1, 2, 3, 1, 2, 3, ... Counting from position 1, what is the sum of B from position 2 to position 7?
- 11
- 13
- 12
- 14
Show the answer
C. 12
Positions 2 to 7 hold 2, 3, 1, 2, 3, 1, which add to 12. For huge ranges, use prefix sums of A: the sum up to position p is (p / n) full copies times sum(A) plus the prefix of the remaining p mod n elements, and the range is the difference of two such sums, O(1) per query.
This topic is named in a candidate’s interview report: Junior software engineer on-campus interview, 2021, on Code360.
DBMS and SQL 5
-
In a data warehouse, what is a star schema?
- A schema where every table references every other table
- A fully normalised schema in third normal form
- A table with a star (*) in every column
- One central fact table of measurements, such as sales, joined to dimension tables such as date, product and store
Show the answer
D. One central fact table of measurements, such as sales, joined to dimension tables such as date, product and store
The fact table holds the numbers and foreign keys; the denormalised dimensions describe them. Queries then need few joins. Normalising the dimensions further gives a snowflake schema.
This topic is named in a candidate’s interview report: Software developer interview, 2021, on Code360.
-
Which query returns the third-highest distinct salary in emp without LIMIT or TOP?
- SELECT MAX(salary) FROM emp WHERE salary < (SELECT MAX(salary) FROM emp);
- SELECT DISTINCT salary FROM emp e1 WHERE 3 = (SELECT COUNT(DISTINCT e2.salary) FROM emp e2 WHERE e2.salary > e1.salary);
- SELECT DISTINCT salary FROM emp e1 WHERE 2 = (SELECT COUNT(DISTINCT e2.salary) FROM emp e2 WHERE e2.salary > e1.salary);
- SELECT salary FROM emp ORDER BY salary DESC;
Show the answer
C. SELECT DISTINCT salary FROM emp e1 WHERE 2 = (SELECT COUNT(DISTINCT e2.salary) FROM emp e2 WHERE e2.salary > e1.salary);
The correlated subquery counts how many distinct salaries are larger than each row's. The third highest has exactly two above it. Counting 3 above gives the fourth highest, and the MAX below MAX gives the second. With window functions, DENSE_RANK() = 3 says the same thing.
This topic is named in a candidate’s interview report: Junior software engineer on-campus interview, 2021, on Code360.
-
emp has (1, Asha), (2, Ravi), (3, Meena) as (id, name), and pay has (1, 50000) and (3, 42000) as (emp_id, amount). What does this return?
SELECT e.name, p.amount FROM emp e LEFT JOIN pay p ON p.emp_id = e.id;- 3 rows, with NULL as Ravi's amount
- 2 rows; Ravi is missing
- 3 rows, with 0 as Ravi's amount
- 6 rows
Show the answer
A. 3 rows, with NULL as Ravi's amount
A LEFT JOIN keeps every row of the left table. Ravi has no pay row, so his amount comes back NULL, not 0. An INNER JOIN would drop him, and COALESCE(p.amount, 0) would show 0 if that is what the report needs.
This topic is named in a candidate’s interview report: Junior software engineer on-campus interview, 2021, on Code360.
-
How does OLAP differ from OLTP?
- They are two names for the same workload
- OLTP is only for data warehouses
- OLAP is always faster than OLTP
- OLTP runs many short transactions that insert and update a few rows (orders, payments); OLAP runs fewer, heavy read queries that aggregate history for analysis
Show the answer
D. OLTP runs many short transactions that insert and update a few rows (orders, payments); OLAP runs fewer, heavy read queries that aggregate history for analysis
An OLTP schema is normalised for fast, safe writes. A warehouse for OLAP is usually denormalised into fact and dimension tables (a star schema) so large aggregations read fewer joins, and it is loaded from the OLTP systems by ETL.
This topic is named in a candidate’s interview report: Software developer interview, 2021, on Code360.
-
In a data warehouse, a customer moves city. Which kind of slowly changing dimension keeps the old city for the orders placed before the move?
- Type 1: overwrite the city
- Type 0: refuse the change
- Type 2: close the old row and insert a new row for the customer, with validity dates or a current flag
- Delete the customer and insert them again
Show the answer
C. Type 2: close the old row and insert a new row for the customer, with validity dates or a current flag
Type 2 keeps every version as its own row with its own surrogate key, so old facts still point at the old city. Type 1 loses history; Type 3 keeps only a "previous value" column. Type 2 is the usual choice when reports must stay true to the past.
This topic is named in a candidate’s interview report: Software developer interview, 2021, on Code360.
Machine learning 1
-
How does a random forest overfit less than one deep decision tree?
- It uses gradient descent to prune the tree
- It limits every tree to a depth of one
- It averages many trees, each trained on a bootstrap sample and random subsets of features
- It trains a single tree on more data
Show the answer
C. It averages many trees, each trained on a bootstrap sample and random subsets of features
Each deep tree overfits in its own way. Training them on different samples and features makes their errors less correlated, and averaging cancels much of the variance.
This topic is named in a candidate’s interview report: Software developer interview, 2021, on Code360.
Software engineering 2
-
In integration testing, what is the difference between a test stub and a test driver?
- They are the same thing
- Drivers are only used in black-box testing
- A stub is a real module, a driver is a fake one
- A stub stands in for a module that the unit under test calls; a driver stands in for the caller and invokes the unit under test
Show the answer
D. A stub stands in for a module that the unit under test calls; a driver stands in for the caller and invokes the unit under test
Top-down integration tests high-level modules first, so missing lower modules are replaced by stubs returning canned answers. Bottom-up integration tests low-level modules first, so a driver feeds them inputs in place of the callers that do not exist yet.
This topic is named in a candidate’s interview report: Software engineer (testing) interview, 2021, on Code360.
-
What is black-box testing?
- Testing that reads every line of the code
- Testing done only after release
- Testing the behaviour from inputs and expected outputs without looking at the code, using techniques such as equivalence partitioning and boundary values
- Testing the hardware only
Show the answer
C. Testing the behaviour from inputs and expected outputs without looking at the code, using techniques such as equivalence partitioning and boundary values
White-box testing designs cases from the code's structure (branches, paths). Black-box testing designs them from the specification, so it catches missing features and wrong behaviour that code-based coverage can miss.
This topic is named in a candidate’s interview report: Software engineer (testing) interview, 2021, on Code360.