## CareerCup Interview Questions

- 0of 0 votes
Implement an algorithm to print all valid (e.g., properly opened and closed) combinations of n-pairs of parentheses.

EXAMPLE:

input: 3 (e.g., 3 pairs of parentheses)

output: ()()(), ()(()), (())(), ((()))

This question is from "Cracking the coding interview" (Fourth Edition) and I think that I found mistake in the answer.

- -3of 3 votes
multiplication of two numbers without actual multiplication ::

Using vedic mathematics

- 1of 1 vote
Deck of cards :

1) Put the first card on the table and next at the bottom of the deck

2) Repeat the above until all the cards are on table.

3) Pick up the cards and repeat steps 1 and 2.

Find after how many iterations the original order is restored.

For Ex ::

1 2 3

1st iteration - 2 3 1

2nd iteration - 3 1 2

3rd iteration - 1 2 3

so after 3 iterations. Find for n.

- 0of 0 votes
What is the output of following program:

`1 #include <stdio.h> 2 3 int r = 1; 4 int numbers[5] = {1, 2, 3, 1, 5 }; 5 6 int main(int argc, char** argv) 7 { 8 #if !defined(_MSC_VER) 9 asm("leal numbers, %esi"); 10 asm("movl $0, %ecx"); 11 asm("movl r, %eax"); 12 asm("label1:"); 13 asm("movl (%esi,%ecx,0x4), %ebx"); 14 asm("imul %ebx, %eax"); 15 asm("addl $1, %ecx"); 16 asm("cmpl $5, %ecx"); 17 asm("jl label1"); 18 asm("mov %eax, r"); 19 #else 20 __asm 21 { 22 LEA ESI, numbers 23 MOV ECX, 0 24 MOV EAX, r 25 label1: 26 MOV EBX, [ESI + ECX * 4] 27 IMUL EAX, EBX 28 ADD ECX, 1 29 CMP ECX, 5 30 JL label1 31 MOV r, EAX 32 } 33 #endif 34 printf("Result= %d\n", r); 35 return 0; 36 }`

- -6of 6 votes
please tell me about a good website data structure in c++???

- 0of 0 votes
given a positive integer n, return an array n x n, and numbers increasing in spiral way using ***recursion***

for ex:

n = 4

return

1 2 3 4

12 13 14 5

11 16 15 6

10 9 8 7

- -1of 1 vote
In the page 90 of Gayle's cracking the coding interview book, there was a method defined which is used to get the bit at particular position. Method goes like this...

boolean getBit(int num, int i) {

return ((num&(1<<i))!=0);

}

Will this works..? if my number is 8 and I want to get the 3rd position, this return a wrong result

- 0of 0 votes
In the CrackingTheCodeInterview book solution, CareerCupLibrary - TreeNode, the isBST method is like this:

`public boolean isBST() { if (left != null) { if (data < left.data || !left.isBST()) { return false; } } if (right != null) { if (data >= right.data || !right.isBST()) { return false; } } return true; }`

But I think this method only checks whether the tree is searchable, it can NOT check whether the tree is balanced. Am I right folks?