## Akamai Interview Questions

- 0of 0 votes
I have one output as bellow:

NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT

abc 202:0 0 7.9G 0 disk

`-xvda1 202:1 0 7.6G 0 part /

efg 202:16 0 54.2G 0 disk /mnt/

ijk 202:32 0 75.2G 0 disk

Now I want to get only those name which does not have any mount point. i.e., I want output as bellow:

abc

ijk

How can i achieve this using bash script?

- 0of 0 votes
Given N natural numbers A1, A2, A3 . . . AN, you have process Q queries of following two types:

1 i j: Perform the operation Ai = j.

2 L R: Print the LCM of the elements AL, AL+1, AL+2 . . . AR.

Here LCM stands for lowest common multiple. Please help Shil to open the lock.

Input

First line will contain integer N.

Second line will contain N natural numbers denoting array A.

Third line will contain number of queries Q.

Then next Q lines will contain either query of Type 1 or 2.

Output

For each query of Type 2 output the required answer. Since LCM can be very large output it modulus 109+7.

- 0of 0 votes
How would you implement virtual functions in C?

- 0of 0 votes
There are two string pattern P and searching Expression Ex.. Ex is regular expression contains only # which stand for any character latest one length..

P:- ABABABA Ex:- A#B#A P and Ex are similar so its true.

example2. P: ABACBCB Ex:- A#B result:- true

Example:- P: ABCABCCE Ex:-A#C# result:- true, as P contains the expression as Ex

P: ABCABCCE Ex:-A#C false: P is doesnot contains the express like A#C

# --- means at least one or more character. In java language you have write the algorthim

- 0of 0 votes
There are two string pattern P and searching Expression Ex..

Ex is regular expression contains only # which stand for any character latest one length..

P:- ABABABA

Ex:- A#B#A

P and Ex are similar so its true.

example2.

P: ABACBCB

Ex:- A#B

result:- true

Example:-

P: ABCABCCE

Ex:-A#C#

result:- true, as P contains the expression as Ex

P: ABCABCCE

Ex:-A#C

false: P is doesnot contains the express like A#C

#--- means at least one or more character.

- 0of 0 votes
There are two string pattern P and searching Expression Ex..

Ex is regular expression contains only # which stand for any character latest one length..

P:- ABABABA

Ex:- A#B#A

P and Ex are similar so its true.

example2.

P: ABACBCB

Ex:- A#B

result:- true

Example:-

P: ABCABCCE

Ex:-A#C

false: P is doesnot contains the express like A#C

#--- means at least one or more character.

- 0of 0 votes
Most efficient way to check whether a number is Prime or not.

- 0of 0 votes
`struct node { int data; struct node* left; struct node* right; }; void Postorder(struct node* root,struct node** leaf) { if (root == NULL) return; if(root->data%2==0) *leaf->left=root; //WHY I'M GETTING PROBLEM IN THIS LINE //[Error] request for member 'left' in '* leaf', which is of non-class type 'node*' Postorder(root->left,leaf); Postorder(root->right,leaf); } int main() { struct node *root = newNode(1); root->left = newNode(2); root->right = newNode(3); struct node* leaf=root; Postorder(root,&leaf); getchar(); return 0;`

}

- 0of 0 votes
given a binary tree, assign a new next pointer to each node, such that next pointer points to any node which is right side of the node(ie it may point to its sibling right node , or a left node of next subtree).

if no node on right or if the node itself if right most, the next points to null`6`

`/ \`

`7-------->2`

`/ \ / \`

`1 - ->5-->4 ->13`

- 0of 0 votes
Look at the following pseudo-code, which computes the n-th Fibonacci number:

int fibonacci(int n)

{

if (n == 0)

{

print(0)

return 0

}

if (n == 1)

{

print(1)

return 1

}

return fibonacci(n - 1) + fibonacci(n - 2)

}

If one calls fibonacci(3), then the following will happen:

* fibonacci(3) calls fibonacci(2) and fibonacci(1) (the first call).

* fibonacci(2) calls fibonacci(1) (the second call) and fibonacci(0).

* The second call of fibonacci(1) prints 1 and returns 1.

* fibonacci(0) prints 0 and returns 0.

* fibonacci(2) gets the results of fibonacci(1) and fibonacci(0) and returns 1.

* The first call of fibonacci(1) prints 1 and returns 1.

* fibonacci(3) gets the results of fibonacci(2) and fibonacci(1) and returns 2.

In total, 1 will be printed twice and 0 will be printed once.

We want to know how many times 0 and 1 will be printed for a given integer N.

INPUT

The first line contains an integer T, denoting the number of test cases.

The next T lines contain an integer N.

OUTPUT

For each test case, print one line of output which contains 2 integers separated by a space. The first integer is the number of times 0 is printed. The second integer is the number of times 1 is printed.

CONSTRAINTS

1 <= T <= 50

0 <= N <= 40

SAMPLE INPUT

2

0

3

SMAPLEOUTPUT

1 0

1 2

- 0of 0 votes
If you look at the following pseudo-code, which computes the n-th Fibonacci number:

int fibonacci(int n)

{

if (n == 0)

{

print(0)

return 0

}

if (n == 1)

{

print(1)

return 1

}

return fibonacci(n - 1) + fibonacci(n - 2)

}

If one calls fibonacci(3), then the following will happen:

* fibonacci(3) calls fibonacci(2) and fibonacci(1) (the first call).

* fibonacci(2) calls fibonacci(1) (the second call) and fibonacci(0).

* The second call of fibonacci(1) prints 1 and returns 1.

* fibonacci(0) prints 0 and returns 0.

* fibonacci(2) gets the results of fibonacci(1) and fibonacci(0) and returns 1.

* The first call of fibonacci(1) prints 1 and returns 1.

* fibonacci(3) gets the results of fibonacci(2) and fibonacci(1) and returns 2.

In total, 1 will be printed twice and 0 will be printed once.

We want to know how many times 0 and 1 will be printed for a given integer N.

INPUT

The first line contains an integer T, denoting the number of test cases.

The next T lines contain an integer N.

OUTPUT

For each test case, print one line of output which contains 2 integers separated by a space. The first integer is the number of times 0 is printed. The second integer is the number of times 1 is printed.

CONSTRAINTS

1 <= T <= 50

0 <= N <= 40

SAMPLE INPUT

2

0

3

SMAPLEOUTPUT

1 0

1 2

- 1of 1 vote
The way a Knight

Given a chessboard, consisting of n×n cells, several of them are cut. Find the path of minimum length for a Knight from one cell to another. The Knight can’t go through cut cells.

Specifications

Input

The first row is set to the number n (2 ≤ n ≤ 50). Each of the next n lines contains n symbols. The symbol # denotes the cut cell, the point - not cut cell, the symbol @ denotes the initial and final cell of the Knight's path (the chessboard contains two such characters).

Output If the path can not be constructed, print "Impossible". Otherwise display the same map as the input, but check all Knight intermediate positions with symbol @.

Example

Example input

5

.....

.@@..

.....

.....

.....

5

@..@.

..##.

.....

.....

.....

5

@....

..#..

.#...

.....

....@

Example output

Sample 1

...@.

.@@..

....@

.....

.....

Sample 2

@..@.

..##.

.@..@

..@..

@....

Sample 3

Impossible

- 0of 2 votes
There is an sorted array suppose 10 20 30 40 50 60 70 80 90. If we rotate it n times(suppose n = 3 in my case). The array will be 70 80 90 10 20 30 40 50 60. The total no of values which are not in right position 3(in this case which are 70 80 90) so we have to make a generalized solution. I was able to answer this in O(n) but he wants something which is lesser than O(n).

- 0of 0 votes
Which one you prefer and why?

Vector of pointer,reference and object. which one you will prefer.

- 0of 0 votes
you have given a post-fix of a binary try in which either you have 0 child(leaf node) or 2 child(internal node).

one more condition that all internal node are denoted via "i" and leaf node via "l".

we have to create this binary tree with this posfix.

- 1of 1 vote
How can I store objects of differing types in a C++ container?

- 1of 1 vote
You are given a long list of integers, so long that you can not fit the entire list into memory, implement an algorithm to get the max 100 elements in the list.

- 0of 0 votes
For each subject topic(like Maths,Physics,Java,Sql), I have some urls.

In each url,I have a list of questions.

Now on each click(lets say Physics),I shall hit all urls(which could be in thousands) and then parse through them to get all the questions and persist them to DB.

Please tell me what can be the high levl and low level design for this in Java(Explain patterns that cn be used,Threads etc...)

- 0of 0 votes
Write an algorithm to scan all anagrams in a word doc.

This should be done in minimum time possible.

- 0of 0 votes
Write a program to find the (n-3)rd element in a singly linked list of unknown length in a single pass...

- 0of 0 votes
Write a program to find the middle element in a singly linked list of unknown length in a single pass...

- 0of 0 votes
how do you create a duplicate of a DoublyLinkedList in which the .next is okay but .prev can point to any node in the link list

- 0of 0 votes
u have a video file. the user watches some part of it. he may seek forward, backwards or watch same part again and again. you have given the intervals which he watched. find the fraction of the video he watched.

for e.g. 1-7, 10 -15, 5-11, 20-25 with total length of video being 50.

ans should be 2/5 or 0.4

- 0of 0 votes
u have an array of n integers. rotate it left by k positions. time complexity linear.

without using extra array.

- 0of 0 votes
you have given a function rand(3) which when called returns values 1,2,3 with equal probability. Derive a function rand(9) using rand(3) which returns values 1 to 9 with equal probability.

- 0of 0 votes
random(0,1) is a function that generates integers 0 and 1 randomly ... using this function how woud you design a function that takes two integers a,b as input and generates random integers including a and b...

- 0of 0 votes
What happens behind the scene when we typ an url in browser and hit enter?

- 0of 0 votes
hey..can any1 plz tell me diff btw super key,candidate key,composite key....was asked in in interview..i was confused...also need an explanation for super key

- 0of 0 votes
You have a array of random numbers and you are given a number k. Find the 2 elements in the array which sum up to k.

e.g: If my array is {2,5,3,1,8,7,5,4} and k=6.

Then 2 numbers that sum up to 6 are 5 and 1.

- 0of 0 votes
Difference between XML and HTTP.