Posts

Showing posts from February, 2020

Adobe Questions Collections

C++ 11 features : Lambda Functions, unique pointers and 1-2 more features which I dont remember exactly. Virtual Functions,, How derived class functions can be accessed by pointer to base class. Memory map of Derived Class when it is compiled : I gave vPointer and vTable explanation. He discussed in detail what all things get stored in vTable. Accessing Base Class functions . Memory map of shared pointer object on compilation. How is reference count shared between shared pointers ? What happens when copy constructor of shared pointer called. Then came Mutex, Sempahores and Condition Variables. Wait and Notify purpose. When to use Condition variables. Spurious wake up in case of wait() : This I did not know. He explained the term and its consequences, and why condition wait is in while loop rather than if check. He asked about std::promise() and std::future(). Write code for set() of promise and get() of future and synchronize between them using lock and condition va

Which data structure is used in redo-undo feature?

Explanation:  Stack data structure is most suitable to implement redo-undo feature. This is because the stack is implemented with LIFO(last in first out) order which is equivalent to redo-undo feature i.e. the last re-do is undo first. Consider a situation where a client receives packets from a server. There may be differences in speed of the client and the server. Which data structure is best suited for synchronization? (A)  Circular Linked List (B)  Queue (C)  Stack (D)  Priority Queue Answer:   (B) Explanation:  Since packets need to be processed in First In First Out order, a queue can be used for synchronization. A data structure is required for storing a set of integers such that each of the following operations can be done in (log n) time, where n is the number of elements in the set. o Delection of the smallest element o Insertion of an element if it is not already present in the set Which of the following data structures can be used for this purpose? (

Check duplicates in a stream of strings

Check duplicates in a stream of strings Given an array  arr[]  of strings containing the names of employees in a company. Assuming that the names are being entered in a system one after another, the task is to check whether the current name is entered for the first time or not. Examples: Input:  arr[] = {“geeks”, “for”, “geeks”} Output: No No Yes Approach:  Create an  unordered_set  to store the names of the employees and start traversing the array, if the current name is already present in the set then print Yes else print No and insert it into the set. Below is the implementation of the above approach: // C++ implementation of the approach #include <bits/stdc++.h> using namespace std;     // Function to insert the names // and check whether they appear // for the first time void insertNames(string arr[], int n) {          // To store the names      // of the employees      unordered_set<string> set;      for ( int