Relevel by Unacademy Phase - I Answers

Frontend Development Test | Round 1

Back to Basics                                              Duration: 45 min | Max Marks - 150

#Programming Fundamentals - 18 Min

This round consists of 30 questions wherein the candidate is tested on the soundness of their knowledge of computer science fundamentals. The candidate can expect questions around the core concepts of computer science like computer networks, operating systems, basic programming, databases, etc...

relevel_by_unacademy_front_end_test_chaitu_info_blogs
Relevel by Unacademy Front-End Development Test


1. What is the functionality of the following piece of code?

public void display()
{
           if(size == 0)
                      System.out.println("underflow")
           else
           {
                      Node current = first
                      while(current != null)
                      {
                                System.out.println(current.getEle())
                                current = current.getNext()
                       }
            }
}

Options

1. reverse the list
2. display the list -> Answer
3. display the list excluding top-of-the-stack-element
4. reverse the list excluding top-of-the-stack-element

2. Which of the following data structure is required to convert arithmetic expression in infix to its equivalent postfix notation?

Options

1. Queue
2. Linked list
3. Binary search tree -> Answer
4. None

3. Consider the program and find the subsequent output.

var x=0
      for(x;x<5;x++)
            console.log(x)

Options

1. 0 -> Answer
2. a
3. 5
4. 12345

4. Consider the program and find the subsequent output.

intger main()
{
           print integer,10?0?5:11:12
           return 0
}

Options

1. 11
2. 12
3. 15
4. 10 -> Answer

5. Which constructor will be called from the object created in the code below?

class A
{
        integer i;
        A()
        {
                   i=0; Print literals i;
         }
        A(integer x=0)
        {
                   i=x; Print literals I;
         }
};
A obj1;

Options

1. Default constructor
2. Parameterized constructor
3. Compile time error -> Answer
4. Run time error

6. What will be the firstname and aliasname of the following JavaScript code?

var book1 =
{
       "main title": "computer",
        'sub-title': "The Programming Adventure",
       "for": "all audiences",
       author: {
                          firstname: "Luis",
                          aliasname: "Phillip"
                     }
};

Options

1. Property values
2. Property names -> Answer
3. objects
4. properties

7. Smaller page tables are implemented as a set of __________.

Options

1. queues
2. registers -> Answer
3. stacks
4. counters

8. What observation can you make in the following JavaScript code snippet?

var CountOne = [1,,3];

Options

1. Omitted value becomes a random integer value
2. Omitted value becomes "undefined" -> Answer
3. It throws an exception
4. Throws an error

9. What is the maximum of classes that can be defined in a program?

Options

1. Not more than 100
2. Not more than 1000
3. Not more than 999
4. As many as we want -> Answer

10. Consider the program and find the subsequent output.

void convert(int n) {
       if(n <= 0)
       print(n)

       else {
       convert(n/8)
       print(n%2)
       }
}

Main() {
    convert(72)
}

Options

1. 0111
2. 0110 -> Answer
3. 0100
4. 0101

11. A binary tree can easily be converted into a 2-tree through which of the following methods.

Options

1. By submitting every empty subtree with a replacement internal node
2. By inserting an interior node for a non-empty node
3. By inserting an external node for a non-empty node
4. By substituting every empty subtree with a replacement external node -> Answer

12. The postfix expression corresponding to the infix expression a + b * c - d ^ e ^ f

Options

1. abc * + def ^ ^ -
2. abc * + de ^ f ^ - -> Answer
3. ab + c * d - e ^ f ^
4. - + a * bc ^ ^ def

13. Consider the program and find the subsequent output.

      void main()
      {
            int data = 3 + 4 + 3 * 5 / 3 - 5
            print(data)
      }

Options

1. 5                             2. 6
3. 7 -> Answer           4. 8

14. What is the ascending heap property?

Options

1. A[Parent(i)] = A[i]                                 2. A[Parent(i)] <= A[i] -> Answer
3. A[Parent(i)] >= A[i]                               4. A[Parent(i)] > 2 * A[i]

15. The degree of a vertex is given by

Options

1. Number of edges incident on it -> Answer
2. Total Number of edges in the graph
3. Number of edges that can be formed using that vertex
4. Number of self-loops

16. A simple graph can contain which of the following?

Options

1. Self-loop 2. Infinite edges
3. Parallel edges                                    4. A disconnected vertex -> Answer

17. The seven elements P, Q, R, S, T, U, and V are pushed onto reverse order starting from V. The stack is popped five times and every element is inserted into a queue. Three elements are deleted from the queue and pushed back to the stack. Now one element has popped from the stack. The popped item is

Options

1. Q                                                        2. R
3. T -> Answer                                       4. S

18. In a time-sharing operating system, when the time slot given to a process is completed, the process goes from the running state to the

Options

1. Blocked state                                       2. Ready state -> Answer
3. Suspended state                                   4. Terminated state

19. Which of the following page replacement algorithms suffers from Belady's anomaly?

Options

1. FIFO                                                    2. LRU -> Answer
3. Optimal Page Replacement                 4. Both LRU and FIFO

20. A page will be viewed on a bunch of different devices during the testing phase. A test case has been given to you that to have a responsive navbar using flex. Which of the following is the best way to determine the user device and experience?

Options

1. Set conditions on the orientation of the page
2. Using media query -> Answer
3. Write a CSS code for a large screen and a small screen
4. Using responsive data view

21. The events that are not directly tied to a specific input device are _______________.

Options

1. User interface events                                 2. Device-independent events -> Answer
3. Device-dependent events                          4. Stage event change

22. Which of these containers would be best to store distinct elements?

Options

1. map                                                          2. set -> Answer
3. stack                                                        4. queue

23. If your class contains a data member which is dynamically allocated, which of the following must be done?

Options

1. Call destructor implicitly                             2. Free the storage via delete
3. A default constructor should be defined      4. Pass by value to the index -> Answer

24. Which of the following is correct with respect to data encapsulation in code?

Options

1. The modification of the code can cause difficulty
2. Member functions can be used for modifying the data type of data members. -> Answer
3. The data type of data member cannot be modified.
4. The data types of the member functions can be easily modified without making any major changes in the code

25. Client-side Js code is embedded within HTML documents in ________. Choose the most appropriate option.

Options

1. A URL that uses the special javascript: encoding
2. A URL that uses the special javascript: Stack
3. A URL that uses the special javascript: protocol -> Answer
4. A URL that uses the special javascript: code

26. Which of the following is not the default CSS styling for paragraph tag?

Options

1. margin                                               2. content -> Answer
3. display                                               4. indent

27. The only state transition that is initiated by the user process itself is :

Options

1. block ->Answer                                 2. wakeup
3. dispatch                                             4. none of  the mentioned

28. Give the output of the following pseudo code?

struct student
{
     char name[20]
}std;
char * fun(struct student *tempStd)
{
     strcpy(tempStd->name,"Thomas")
     return tempStd->name
}

int main()
{
     strcpy(std.name,"Mike ")
     print(std.name,fun(&std))
}

Options:

1. Mike Thomas                                     2. Mike Mike
3. ThomasThomas->Answer                 4. ThomasMike

29. Consider a real life example where two trains come in front of each other on a single track and none of them are able to move forward: Which operating System concept does the above example resemble?

Options:

1. Deadlock->Answer                            2. Thrashing
3. Multithreading                                   4. Semaphores

30. The undo and redo operations must be ________ to guarantee correct behavior, even if a failure occurs during recovery process.

Options:

1. idempotent                                         2. easy
3. protected                                            4. all of the mentioned->Answer

Frontend Development Test | Round - 2

Assess your algo - 250 Marks             #Data Structures and Algorithms - 90 Min

A DSA round with two problems to test your coding skills in a high-pressure situation

Question 1 IDE Submission

Tomato, Carrot, Beetroot
Your current stamina is 1 you have N days to increase the stamina, You are given 3 arrays
T[i](1<=i<=N), C[i](1<=i<=N) and B[i](1<=i<N) if you eat a carrot on ith day your stamina will be multiplied by C[i], if you eat Tomato on ith day, your stamina will get multiplied by T[i]and if you eat Beetroot on ith day your stamina is multiplied by C[i] you need to eat exactly one of carrot, beetroot, and tomato each day. And you can not eat the same vegetable on consecutive days (i.e if you eat tomato on ith day you have to eat either beetroot or carrot on i+1th day) If you make poor choices and your stamina is minimum of what could have been obtained, what is your stamina
Input Format
The first line contains an integer X denoting the number of test cases the first line of each test case contains an integer denoting N The Next N lines contain 3 space-separated integers denoting T[i], C[i] and B[i](1<=i<=N) respectively
Output Format
Print an integer denoting the minimum stamina you can obtain.
Constraints
1<=X<=1000
1<=N<=30
-4<=T[i],B[i],C[i]<=4
Sample Input
1
2
-1 4 -3
-1 1 2
Sample Output
-4
Explanation
Eat carrot on day 1 so your stamina becomes 1*4=4 Eat tomato on day 2 so your stamina becomes 4*-1=-4

Things to Note for the Candidate:
You can use your own IDE like Visual Studio Code, Eclipse, or any other IDE that you are comfortable with to build your solution code. The IDE provided on the platform is purely for submission. Avoid using the IDE for coding out the solution. Test against any custom input in your own IDE provided on the platform, you cannot pass custom test cases and see the output. Use standard input and standard output in your program for the IDE to run the test cases smoothly against your code. We are giving a sample problem statement along with a solution that will pass the test cases in the IDE. Sample problem Statement (Right Click and Open in New Tab to view.)

Question 2 IDE Submission

Un Special
Numbers 

UN SPECIAL
NUMBERS

Problem Statement:
You are given an array A of N integers. You are also given M unspecial integers. You have to tell the longest possible length of a subarray of array A which contains at most K unspecial integers.
Note:
Each occurrence of a unspecial integer is counted separately. See sample test case for more clarity on the question.
Input Format
The first line contains three space-separated integers denoting N, M, and K.
Next line contains N space-separated integers denoting elements of array A.
Next line contains M space-separated integers denoting the unspecial integers.
Output Format
Print the longest possible length of a subarray of array A which contains at most K unspecial integers.
Constraints
1<=N,M<=105
1<=K<=N
1<=Ai<=109
1<=Unspecial integers<=10All Unspecial integers are distinct from each other.
Sample Input 1
5 2 2
1 2 3 2 5
3 2
Sample Output1
3
Explanation of Sample 1
Take Subarray A3..5=[3,2,5] it has 2 unspecial integers 3 and 2. Note that we cannot take the entire array as there are two occurrences of 2 in it and one occurrence of 3. Hence the count of unspecial integers in the entire array = 2+1 =3.