InterviewSolution
This section includes InterviewSolutions, each offering curated multiple-choice questions to sharpen your knowledge and support exam preparation. Choose a topic below to get started.
| 1. |
The Golomb sequence is a non-decreasing integer sequence in which the n-th term equals the number of times the letter n appears in the sequence. The first few numbers are 1, 2, 2, 3, 3, 4, 4, 4, 5, 5, 5, 5, 5,...... |
|
Answer» Definitions of a few terms: If n is a POSITIVE integer, SOLVE for it. The goal is to discover the first n Golomb sequence terms. To determine the nth term of a Golomb sequence, use the following recurrence relation:
The following is the Dynamic Programming implementation: void findGolomb(int N){ int dp[N + 1]; // BASE case dp[1] = 1; // Calculating and displaying the first // N terms of Golomb Sequence. for (int i = 1; i <= N; i++) { dp[i] = 1 + dp[i - dp[dp[i - 1]]]; cout << dp[i] << " "; }}Useful Interview Resources
|
|
| 2. |
Implement the Sieve of Eratosthenes in 0(n) time complexity. |
|
Answer» For any i where i ranges from 2 to N-1, examine the number to SEE if it is prime. If somehow the number is prime, it should be placed in the prime array. For each prime number j less than or equal to the lowest prime factor p of i, the following formula is used:
|
|
| 3. |
Find the order of characters in an alien language using a sorted dictionary (array of words). |
|
Answer» Input: words[] = {"baa", "abcd", "abca", "cab", "cad"} Output: Order of characters is 'b', 'd', 'a', 'c' Because "baa" comes before "abcd" in the specified language, 'b' appears before 'a' in the result. Other orders can be found in the same way. The goal is to make a character graph and then figure out how to order it topologically. The detailed steps are listed below.
|
|
| 4. |
Given an n-element array with elements ranging from 0 to n-1, any of these integers can occur whatever number of times. Using just constant memory space, find those repeating numbers in O(n). |
|
Answer» The array's numbers vary from zero to n-1, and also the input array is n bytes long. As a result, the input array could be transformed into a HashMap. If an element 'a' is discovered while navigating the array, raise the value of a%nth element by n. By DIVIDING the a%nth element by n, you can get the frequency. // C++void findDupEle (int NUM[], int n){ for (int i = 0; i < n; i++) { num[num[i] % n] = num[num[i] % n] + n; } cout << "The duplicate elements are : " << endl; for (int i = 0; i < n; i++) { if (num[i] >= n * 2) { cout << i << " " << endl; } } RETURN;}
|
|
| 5. |
How can you delete a value from a linked list if you have a pointer to it? It's important to note that no other node, not even the head, is provided with a pointer. |
|
Answer» The approach is to copy the DATA from the next NODE to the node that will be erased, then delete the node that will be deleted. void delNode(ListNode* ptr){ // If the node to be deleted is the // last node of linked list if (!ptr->next) { free(ptr); // this will simply make the node_ptr NULL. return; } // if node to be deleted is the first or // any node in between the linked list. ListNode* temp = ptr->next; ptr->val = temp->val; ptr->next = temp->next; free(temp);}It's vital to keep in mind that this method will only operate if the given reference does not point to the last node. Because you don't have the following node to copy the INFO from if it's the last node. We can make the final node a DUMMY node to make this solution work. However, the programs/functions that use this function should be CHANGED as well. |
|
| 6. |
Multiply two numbers using bitwise operators. |
|
Answer» The Russian peasant algorithm is an intriguing method. The goal is to keep doubling the first number while HALVING the second until the second number NEVER becomes 1. Then add the first number to the RESULT anytime the second number becomes odd during the OPERATION (result is initialised as 0). // C++unsigned int multiply(unsigned int x, unsigned int y){ int ans = 0; // initialise the ans variable // While the second number is not equal to 1 while (y > 0) { // If second number is odd, we will add the first number to ans if (y & 1) ans = ans + x; // then multiply the first number by 2 and divide the second number by 2 x = x << 1; y = y >> 1; } return ans;}
If y is even, the value of x*y is (x*2)*(y/2); otherwise, the value is ((x*2)*(y/2) + x. We keep multiplying 'x' by 2 and dividing 'y' by 2 in the while loop. We add 'x' to 'ans' if 'y' is odd in the loop. The ANSWER is obtained when the value of 'y' equals 1, and the value of 'ans' + 'x' equals 1. When 'y' is a power of two, the 'ans' remains 0 and the multiplication is done by 'x'. |
|
| 7. |
What is the advantage of a ternary search tree over trie? |
|
Answer» In contrast to the trie(STANDARD) data structure, which has 26 pointers for its offspring, every node in a ternary search tree only has three:
Aside from the three-pointers mentioned above, every node has a field for indicating data (character in the case of a dictionary) and a field for indicating the end of a string. One advantage of employing ternary search trees over attempts is that ternary search trees take up less space (only three-pointers each node in comparison to 26 in standard tries). In addition, ternary search trees can be utilised in any situation where a hashtable is used to hold strings. Tries are appropriate whenever there is a balanced mix of words throughout the alphabets, ALLOWING for the most efficient use of space. Aside from that, ternary search trees are preferable. Whenever the strings to be MAINTAINED all have the same prefix, ternary search trees are the most economical (in terms of space). |
|
| 8. |
The company is in need of storage. How can HCI assist the company in this situation? |
|
Answer» Data is rising at a rate of 50% or more each year, and it is being stored on the block, FILE, or object storage systems. New visibility and CONTROL requirements are putting more pressure on storage managers. And cloud storage has grown in importance to the point where it must be incorporated in whatsoever storage ARCHITECTURE. Legacy storage infrastructure, on the other hand, is unable to meet the demands imposed by these new realities. It's compartmentalised, which adds to the COMPLEXITY, inhibits flexibility, and lowers usage. Legacy infrastructure does not provide enough data visibility to fulfil the new compliance or control requirements. It was created before the cloud, making the deployment of cloud-like capabilities extremely challenging. HCI dismantles silos and CONSOLIDATES all assets into a single, easy-to-manage resource. The more "invisible" infrastructure there is, the greater, and HCI expands that invisibility to storage. With HCI, you may create a cluster with a range of nodes depending on your needs at the time—storage-heavy nodes whenever you need storage, CPU-heavy nodes whenever you need computation, and so on. |
|
| 9. |
What do you know about hyperconverged infrastructure? Why should the company consider it for its own infrastructure? |
|
Answer» By integrating x86-based server resources with INTELLIGENT software in a unified software-defined solution, hyperconverged infrastructure simplifies the deployment, management, and scaling of data centre resources. To develop an agile data centre that scales with your business, separate servers, storage networks, and storage arrays can all be replaced with only a single hyperconverged system. It dismantles 3-tier infrastructure's outdated storage silos, reducing complexity and enabling better performance and resilience. HCI is made up of only two main components: two planes.
The company should consider it for the following reasons:
|
|
| 10. |
What types of applications are available in the enterprise cloud? |
|
Answer» From legacy software to new cloud-native apps provided on mobile devices, Enterprise Cloud is well-suited to run the applications that businesses have grown to rely on. The following are some of the most prevalent applications that run in the Enterprise Cloud:
|
|
| 11. |
Is the enterprise cloud software-based or hardware-based? |
|
Answer» It's all about the software in this case! Multi-Cloud operations are made possible by the software. REGARDLESS of the hardware you choose, WHETHER it is Nutanix, HP, Dell, Cisco, Lenovo, or IBM, ENTERPRISE Cloud software converges private, public, and distributed clouds, GIVING more simplicity to infrastructure and application management. |
|
| 12. |
What is the difference between a public cloud and an enterprise cloud? |
|
Answer» An enterprise CLOUD is a unified IT operating environment that combines private, public, and distributed clouds, allowing administrators to manage infrastructure and applications in any cloud from a single location. For both cloud OPERATORS and consumers of cloud-delivered services and apps, the enterprise cloud provides a consistent, high-performance, and seamless experience. The enterprise cloud is a concept for IT infrastructure and a PLATFORM service that combines the benefits of public cloud services with the value of private DATA centre SETTINGS for enterprise applications. |
|
| 13. |
Discuss OutOfMemoryError Exception in Java. |
|
Answer» OutOfMemoryError exception is usually thrown whenever the Java VIRTUAL Machine runs out of memory and cannot allocate an object. The trash collector was unable to release any more memory. OutOfMemoryError frequently indicates that you're doing something incorrectly, such as holding on to objects for too long or processing too much data at once. It can also suggest an out-of-control issue, as in a third-party library that caches strings or perhaps an application server that doesn't clear up after deployments. And it doesn't always have anything to do with the items on the HEAP. When a native allocation cannot be satisfied, the java.lang.OutOfMemoryError exception can be thrown by native library code (for example, if swap space is low). Let's look at some of the scenarios in which the OutOfMemory issue can occur.
|
|
| 14. |
Explain the reference counting mechanism in context to Garbage Collection. |
|
Answer» From the beginning, the REFERENCE counting MECHANISM has been a very old Garbage Collection technique. Each object in the reference counting approach has a track of the number of pointers to it from various OBJECTS and the stack. When a new item refers to it, the counter is increased by one. When an object's reference is lost, the counter is decremented by one. When the count hits '0,' the garbage collector can de-allocate the object. When allocating to a new object, the main advantage of the reference counting approach has been the low amount of work per memory write. HOWEVER, it has SERIOUS difficulty with data cycles. When the first object is referred to by the second object, and the second object is referred to by the first (cyclic references), the count never reaches 0, and the objects are never garbage collected. |
|
| 15. |
List some of the most commonly used LINUX commands. |
|
Answer» Linux is one of the most commonly used operating systems, with a variety of applications and advances. Knowing the appropriate command to use when working on Linux saves a lot of time and effort. The most common LINUX networking commands are as follows:
|
|
| 16. |
What are the different types of virtualization? |
|
Answer» The different types of virtualization are:
|
|
| 17. |
What do you understand by the term “virtualization”? What are its benefits? |
|
Answer» The procedure of running a virtual instance of a COMPUTER system in a layer separate from the actual hardware is known as virtualization. It usually refers to running multiple operating systems on the same computer at the same time. It may appear to applications running on top of the virtualized machine that they are on their own dedicated computer, with their own operating system, libraries, and other programmes that are unrelated to the HOST operating system that sits underneath it. Hypervisor software separates physical resources from virtual environments or the entities that use those resources. HYPERVISORS can run on top of an operating system (like on a laptop) or be installed directly on the hardware (as on a SERVER), as most businesses do. Hypervisors divide up your physical resources so that virtual environments can access them. From the real environment to the multiple virtual environments, resources are partitioned as needed. Within the virtual environment, users interact with it and execute computations (typically called a guest machine or virtual machine). The virtual machine is a single data file that runs. And, like any other digital file, it can be transferred from one computer to another, opened in either, and expected to function correctly. When a user or program issues an instruction that requires additional resources from the physical environment while the virtual environment is running, the hypervisor relays the request to the physical system and caches the changes—all at near-native speed (especially if the request is sent through an open-source hypervisor based on KVM). Benefits of virtualization:
|
|
| 18. |
Define encapsulation in context to OOPS. |
|
Answer» The concept of encapsulation (or OOP Encapsulation) in object-oriented computer programming (OOP) languages REFERS to the bundling of data and the functions that OPERATE on that data into a single unit. Encapsulation is commonly used in the form of classes in several programming languages. A class is a type of program-code template that allows programmers to design objects with both variables (data) and behaviours (functions or methods). In computer science, a class is an example of encapsulation since it consists of data and procedures that have been bundled into a single unit. Encapsulation can also refer to a mechanism that prevents users from directly accessing specific components of an object, such as state values for all of the object's variables. Data members as well as data functions or methods linked with an instantiated class or object can be hidden via encapsulation. There are a few fundamental advantages of encapsulation in programming. These are some of them:
|
|
| 19. |
Define OSI Model and its seven layers. |
|
Answer» The Open Systems Interconnection Model (OSI Model) is a theoretical framework for describing the functions of a networking system. In order to facilitate interoperability between diverse devices and applications, the OSI model describes computing functions into a universal set of rules and standards. The connections between computing systems are divided into seven abstraction levels in the OSI reference model: Physical, Data Link, Network, Transport, Session, Presentation, and Application. The International Organisation for Standardisation (ISO) developed the OSI model in 1984, and it is now used as an architectural paradigm for inter-computer communications. It is a reference model that specifies how information from one computer's software application passes through physical media to another computer's software application. The seven layers of the OSI Model are
|
|
| 20. |
What is the difference between a MAC address and an IP address? |
|
Answer» Some of the key DIFFERENCES between a MAC address and an IP address are:
|
|