Join Regular Classroom : Visit ClassroomTech

Media.net Overall Interview Questions + Coding Solutions codewindow.in

Hot Topics

Media.net Solution

Technical Round

There are some eggs in the basket, if egg doubles every minute and it takes 1hour to fill the basket how much time it will take to fill half the basket?

If an egg doubles every minute, it will take log2(1/2) = log2(0.5) = -1 minutes to fill half the basket. However, log2 returns the logarithm in base 2. To convert it to minutes you would have to divide by log2(60) which is approximately 5.17.

Divide a number by 7 without using division/modulo operators.(Algorithm) 

One way to divide a number by 7 without using division or modulo operators is to use a bit shift.
  1. Initialize a variable “result” to 0.
  2. Shift the number to the right by 3 bits (equivalent to dividing by 8) and add the result to “result”.
  3. Shift the number to the right by 2 bits (equivalent to dividing by 4) and add the result to “result”.
  4. Shift the number to the right by 1 bit (equivalent to dividing by 2) and add the result to “result”.
  5. Subtract the original number by (result * 7)
  6. The final value of “result” will be the quotient of the original number divided by 7.
Note: This algorithm works only for positive integers and will not work for negative numbers or floats.

Difference between calloc and malloc.

Calloc()
Malloc()
1.    Indicates contiguous memory allocation.
Indicates memory allocation.
2.    It creates more than one block of memory to a single variable.
It creates one block of memory of a fixed size.
3.    It takes two arguments.
It takes one argument.
4.    It is slower than malloc().
It is faster than calloc().

 

REST architecture basics Memory Management Hibernate Basics.

  1. REST (Representational State Transfer) is an architectural style for building web services. It is based on the principles of the HTTP protocol and is designed to be simple, lightweight, and flexible. RESTful web services use HTTP methods like GET, POST, PUT, and DELETE to interact with resources.
  2. Memory management is the process of controlling and coordinating the use of memory in a computer system. It involves allocating memory to different processes, managing memory usage, and deallocating memory when it is no longer needed. There are different types of memory management techniques, including manual memory management and automatic memory management.
  3. Hibernate is a Java-based ORM (Object-Relational Mapping) framework that provides a transparent persistence layer for Java applications. It allows developers to interact with a relational database using Java objects, without having to write complex SQL statements. Hibernate maps Java objects to database tables and provides a set of APIs for performing CRUD (Create, Read, Update, and Delete) operations on the data. It also provides caching and lazy loading features to improve performance.

Which tag do you use to refresh the web-page automatically after a fixed period of time?

To refresh the web-page automatically after a fixed period of time we use the meta tag.

What is TCP/IP?

TCP/IP stands for Transmission Control Protocol/Internet Protocol which is a set of rules and methods that is used to interconnect network devices on the internet. It is an implementation based model developed by ARPANET.

What is SQL?

SQL stands for Structured Query Language which is a domain specific language used for programming and managing data in a relational database management system(RDBMS).

Build a BST in O (n logn) worst case complexity.

A binary search tree (BST) can be built in O(n log n) worst-case time complexity by using a balanced binary tree algorithm. A balanced binary tree is a tree data structure in which the height of the tree is kept minimal, ensuring that the time complexity of the basic operations such as insertion, deletion, and search remains O(log n).
Here is an example of building a BST in C++ using the AVL (Adelson-Velsky and Landis) tree algorithm, which is one of the most commonly used balanced binary tree algorithms:
#include <iostream>
#include <algorithm>
 
using namespace std;
 
class Node
{
    public:
        int key;
        Node *left;
        Node *right;
        int height;
};
 
// Function to calculate the height of a node
int height(Node *N)
{
    if (N == NULL)
        return 0;
    return N->height;
}
 
// Function to get the maximum of two integers
int max(int a, int b)
{
    return (a > b)? a : b;
}
 
// Function to right rotate subtree rooted with y
Node *rightRotate(Node *y)
{
    Node *x = y->left;
    Node *T2 = x->right;
 
    // Perform rotation
    x->right = y;
    y->left = T2;
 
    // Update heights
    y->height = max(height(y->left), height(y->right)) + 1;
    x->height = max(height(x->left), height(x->right)) + 1;
 
    // Return new root
    return x;
}
 
// Function to left rotate subtree rooted with x
Node *leftRotate(Node *x)
{
    Node *y = x->right;
    Node *T2 = y->left;
 
    // Perform rotation
    y->left = x;
    x->right = T2;
 
    // Update heights
    x->height = max(height(x->left), height(x->right)) + 1;
    y->height = max(height(y->left), height(y->right)) + 1;
 
    // Return new root
    return y;
}
 
// Function to get the balance factor of a node
int getBalance(Node *N)
{
    if (N == NULL)
        return 0;
    return height(N->left) - height(N->right);
}
 
// Function to insert a new key into the tree
Node* insert(Node* node, int key)
{
    /* 1. Perform the normal BST insertion */
    if (node == NULL)
        return (new Node(key));
 
    if (key < node->key)
        node->left = insert(node->left, key);
    else
        node->right = insert(node->right, key);
 
    /* 2. Update height of this ancestor node */
    node->height = max(height(node->left), height(node->right)) + 1;
 
    /* 3. Get the balance factor of this ancestor node to check whether
       this node became unbalanced */
    int balance = get

Everything in HTML, css, and basic javascript. And some questions based on your resume.

HTML (Hypertext Markup Language) is the standard language used to create and structure web pages. It defines the structure and layout of a web page using a set of tags and attributes. Some common HTML tags include:
  • <html>: the root element of an HTML document
  • <head>: contains meta information about the document
  • <body>: contains the visible content of the document
  • <div>: a container for HTML elements, used to group elements together
  • <p>: a paragraph of text
  • <a>: a hyperlink to another web page or a specific location on the same page
  • <img>: an image
  • <ul> and <li>: an unordered list and list item, respectively
  • <ol> and <li>: an ordered list and list item, respectively
CSS (Cascading Style Sheets) is used to control the presentation of an HTML document. It allows you to control the layout, colors, fonts, and other visual aspects of a web page. CSS can be applied to HTML elements using selectors and rules. Some common CSS properties include:
  • color: sets the text color
  • background-color: sets the background color
  • font-size: sets the font size
  • width and height: sets the width and height of an element
  • margin and padding: sets the space around an element
  • border: sets a border around an element
  • display: sets how an element should be displayed
JavaScript is a programming language that is commonly used to create interactive and dynamic web pages. It can be used to add behavior to HTML elements, create animations, validate forms, and more. JavaScript is typically used in conjunction with HTML and CSS. Some common JavaScript concepts include:
  • Variables: used to store and manipulate data
  • Functions: blocks of code that can be reused throughout a program
  • Conditional statements: used to make decisions based on certain conditions
  • Loops: used to repeat a block of code a certain number of times
  • Events: actions that occur in the browser, such as a button being clicked
  • DOM (Document Object Model): the structure of an HTML or XML document, which can be manipulated with JavaScript
As a language model AI I don’t have a resume so I can’t answer any question based on a resume. However I can help you with any other question you may have.

To check if there is arbitrage in given matrix, in which mat[i][j] denotes the factor to convert currecy i to j.

One way to check for arbitrage in a given matrix is to use the Bellman-Ford algorithm. The Bellman-Ford algorithm is an algorithm that can be used to detect negative cycles in a weighted directed graph.
Here is an example of how the Bellman-Ford algorithm can be used to check for arbitrage in a matrix:
  1. Create a graph G = (V, E) where V is the set of currencies and E is the set of edges representing the conversion factors.
  2. Initialize an array dist[] such that dist[i] = 1 for all i in V. This represents the initial amount of each currency.
  3. For i = 1 to |V|-1, do the following for each edge (u, v) in E:
    • if dist[u] * mat[u][v] > dist[v], update dist[v] = dist[u] * mat[u][v]
  4. For each edge (u, v) in E, check if dist[u] * mat[u][v] > dist[v]. If this is true for any edge, then there is an arbitrage opportunity.
It’s important to note that this algorithm has a time complexity of O(V*E) and it’s used in the case of a weighted directed graph.
Also, it’s important to note that in practice there are more efficient algorithms such as the Floyd–Warshall algorithm which solves the problem of finding shortest paths in a weighted graph with negative or positive weight edges, but with a higher time complexity of O(V^3)
It’s also important to note that this algorithm assumes that the matrix does not contain any negative weight edges, as such edges would indicate a negative cycle, which would make the arbitrage calculations invalid.

How would you store a collection of numbers so that getting the minimum number is O(1) and inserting new numbers is extremely efficient?

One way to store a collection of numbers so that getting the minimum number is O(1) and inserting new numbers is extremely efficient is to use a data structure called a binary heap. A binary heap is a complete binary tree that satisfies the heap property, which states that the value of each node is greater than or equal to the value of its children.
There are two types of binary heap:
  1. Min-Heap: where the value of the root node is the minimum of all the nodes.
  2. Max-Heap: where the value of the root node is the maximum of all the nodes.
Min-Heap is the best option in this scenario because it will always have the minimum value at the root node and getting the minimum value is O(1).
Inserting new numbers into a binary heap is also efficient because it can be done by first adding the new number to the next available leaf node and then repeatedly swapping the new number with its parent node until the heap property is satisfied. This process is known as “heapifying up” and has an average time complexity of O(log n).
Removing the minimum element is also efficient, as it is always at the root, and can be done by replacing the root node with the last leaf node and then repeatedly swapping this new root node with the smallest of its children until the heap property is satisfied. This process is known as “heapifying down” and also has an average time complexity of O(log n)
Overall, using a binary heap to store a collection of numbers provides an efficient way to get the minimum number in O(1) time and insert new numbers in O(log n) time.

What is the first thing you would do to optimize a webpage?

The first thing I would do to optimize a webpage would be to perform a performance audit using tools such as Google Lighthouse or webpagetest.org. These tools can provide a detailed analysis of the webpage’s performance, including metrics such as load time, page size, and the number of requests.
After analyzing the performance audit, the next step would be to identify and address the specific issues that are causing slow page load times. Some common issues that can slow down a webpage include:
  1. Large, unoptimized images: Images can take up a significant amount of space and slow down the page load time. To optimize images, you can use image compression tools to reduce their file size, and also use srcset attribute to serve different images based on the device’s screen size.
  2. Unminified and unoptimized CSS and JavaScript: Unminified code can increase the size of the files and slow down the page load time. To optimize the code you can use tools to minify and compress the code.
  3. Too many HTTP requests: Each time a browser requests a resource, it takes time to complete. To reduce the number of requests, you can use techniques such as concatenation and code-splitting.
  4. Lack of browser caching: Caching allows the browser to store resources locally, so they don’t need to be downloaded again on subsequent page loads. To enable caching, you can set appropriate cache headers on your server.
  5. Heavy use of third-party scripts: Third-party scripts can slow down the page load time as they have to be loaded from external servers. To optimize third-party scripts, you can use techniques such as asynchronously loading them or using a Content Delivery Network (CDN) to serve them.
These are some of the most common issues that can slow down a webpage, but depending on the audit report, there might be other specific issues to address. By identifying and addressing these issues, you can significantly improve the page load time and overall performance of the webpage.

Nagarro Solved

Automata Fixing

      

We Love to Support you

Go through our study material. Your Job is awaiting.

Recent Posts
Categories