Skip to main content

2 posts tagged with "internship"

View All Tags

· One min read
Sujith

First Round

i was asked one dsa question which is zigzag conversion of string https://leetcode.com/problems/zigzag-conversion/

Second Round

A Node is defined as a directory or file. If its a directory it can have sub-directories and files inside it. Write a function `deleteNode` which deletes the node and its childern recursively Given to you three functions/methods
  1. isDirectory which returns if the node is a directory or not
  2. getChildren if the node is a directory, and not empty returns all the contents inside it
  3. delete deletes the node if its a file or if an empty directory

· 10 min read
Sujith

Whole test was divided into 2 sections and given 1 hour to complete both the sections. section 1: 10 MCQs and two coding questions - 50 minutes section 2: 2 personality questions - 10 minutes

Section 1.1 - MCQs

Q1. Stacks
Suppose you've stack based implementation of the infix to postfix conversion algorithm. Which of the following input expressions would require maximim memory to hold the elements (operators and paranthesis) that the algorithm would push onto the stack during the conversion process? on stack during conversion process?

Pick ONE option:
Q2. Selection Sort
Given:


def selection_sort(arr):
n = len(arr)
for i in range(n):
min_idx = i
for j in range(i+1, n):
if arr[min_idx] > arr[j]:
min_idx = j
arr[i], arr[min_idx] = arr[min_idx], arr[i]


What is the role of inner loop in the given code?
Pick ONE option:
Q3. AVL Tree
Which of the following are true about AVL tree?
i) For large data sets, insertion takes same amount of time for AVL tree and Red-Black tree
ii) An AVL tree is an optimised binary search tree
iii) A Red-Black tree can be used as input for all applications of AVL tree
iv) Search operations are massievely faster on the AVL tree than on Red-Black tree

Pick ONE option:
Q4. Binary Search Tree - Preorder
What is the preorder traversal of the BST created by following numbers:
8, 3, 10, 1, 6, 14, 4, 7, 13


Pick ONE option:
Q5. Safe Sequence

Here P0, P1, P2, P3 are processes and R1, R2, R3 are resources R1 has 2 instances, R2 has 3 instances and R3 has 2 instances

If link is between resource and process then it means that resource is needed by that process
If link is between resource instances and process then it means that resource instance is allocated to that process



Consider the following snapshot of a system with 4 processes and 3 resource types. Which of the following is a safe sequence?
Pick ONE option:
Q6. Dinner Menu
Aryan plans to host a dinner for his friends at a restaurant. He deecides to keep 1 starter and 2 main course dishes for lunch. From the menu he realizes that there are only 25 ways to fulfill his requirement.

What can be the total number of dishes available on the menu?
Pick ONE option:
Q7. Hoffman Coding
Given the frequencies of letters in a message
LetterFrequency
A15
B19
C22
D23
E26
F45

After using Hoffman coding, how many bits will saved in the messagePick ONE option:
Q8. Number problem
Number of 5 digit numbers N > 50000 with exactly one 6 and one 9, with 9 always to the left of 6 are
How many such numbers are there?Pick ONE option:
note

I don't remember the options for the question, Need to be updated later

info

Questions 9 & 10 are on OOPs concepts and I forgot the questions and options will update them later

Section 1.2 - Coding

An NxN matrix is filled with only X and Ys alternatively. Top-left corner indexed as (1,1) is X and then every alternate row and column is filled with X and Y respectively. If N = 4

XYXY
YXYX
XYXY
YXYX

There are three query types

  1. X a b - Change the value at (a,b) to X
  2. Y a b - Change the value at (a,b) to Y
  3. C a b - Count the number of Xs and Ys in the submatrix from (a,b) to bottom-right corner and print them separated by a space

Input Format: The first line of input contains an integer, N, the size of the matrix. The next line contains an integer, Q, the number of queries. The next Q lines contain a query of the form X a b or Y a b or C a b where a and b are the row and column indices of the matrix.

Sample Input:

5
3
X 1 1
C 1 1
Y 1 1

Sample Output:

5 4
info

function was in the format

void solve(int N, int Q, char q[], int a[], int b[]) {
// Your code here
}
note

No need to take input or anything, we just need to complete the given function

Section 2 - Subjective

This section was given last 10 minutes with word limit of 200 per question.

You've undertaken one challenging project with your friend. Till now it's going well and on time. Due to some urgent work, your friend has to leave the project. You have to complete the project alone. What will you do? How will you manage the project? What will you do to complete the project on time?