X

Level - 1  Questions

View By:

Q1 SDET Interview

1) Print All k size subset of given array of size n

Reverse the adjacent nodes in a linked list If the nodes of a linked list are as follows 1 -> 2 -> 3 -> 4 -> 5 -> 6 -> 7 -> 8 -> 9 then after reverse they should be 2 -> 1 -> 4 -> 3 Here the number of entries are odd hence the last link is not reversed. If number of nodes are even then last node should also be reversed.

Q3 Print the binary tree using Breadth First Traversal but reverse the elements of every nth breadth

Imagine we have a binary tree having following structure. Please see the structure at following link

![http://mathworld.wolfram.com/images/eps-gif/CompleteBinaryTree_1000.gif]

We need to print the tree using breadth first traversal but need to reverse the elements of every nth breadth from a provided starting point. I have used additional stack with queue to get the desired functionality. It will be more easier for users to understand the problem after running the code and seeing the output.

Q4 Discount on Pizza

The 8" pizza sells for \$ 3.99 at my favorite pizza store. The store claims they have a great deal on the large 12" pizza, which is specially priced at \$ 6.73. What is the per cent discount the store is offering?

Ans - let height be same for both pizza volume of 8" pizza is: pi * (8 * 8) * h, where h is height of pizza and pi is constant value = pi * 64 * h volume of 12" pizza is: pi * (12 * 12) * h, where h is height of pizza and pi is constant value = pi* 144 * h

so price of 12" pizza is - (pi * 144 * h * 3.99) / (pi * 64 * h) = 8.97 approx discount given - 8.97 - 6.73 = 2.24

so percentage of discount = 2.24 * 100 / 8.97 = 25 % approx

Q5 Octa to Decimal Conversion

eg 12 in octa is 10 in deci

Q6 How to add two integers without using arithmetic operators?

Write a function Add() that returns sum of two integers. The function should not use any of the arithmetic operators (+, ++, –, -, .. etc).

Q7 check sign of two numbers

Detect if two integers have opposite signs

Given two signed integers, write a function that returns true if the signs of given integers are different, otherwise false. For example, the function should return true -1 and +100, and should return false for -100 and -200. The function should not use any of the arithmetic operators.

Q8 QuickSort

Quicksort

Q9 Print the Pascal triangle.

If you choose the number of rows as 3, the output will be

1 121 1331

Q10 Sting lower to upper case and vice versa

How to change the case of the string.