Posts

Showing posts from February, 2021

Vector-Sort

Vector-Sort  You are given     integers.Sort the     integers and print the sorted order. Store the   integers in a vector.Vectors are sequence containers representing arrays that can change in size. Declaration: vector<int>v; (creates an empty vector of integers) Size: int size=v.size(); Pushing an integer into a vector: v.push_back(x);(where x is an integer.The size increases by 1 after this.) Popping the last element from the vector: v.pop_back(); (After this the size decreases by 1) Sorting a vector: sort(v.begin(),v.end()); (Will sort all the elements in the vector) To know more about vectors,  Click Here Input Format The first line of the input contains   where   is the number of integers. The next line contains   integers. Constraints , where   is the   integer in the vector. Output Format Print the integers in the sorted order one by one in a single line followed by a space. Sample In...

Abstract Classes - Polymorphism

 Abstract Classes - Polymorphism Abstract base classes in C++ can only be used as base classes. Thus, they are allowed to have virtual member functions without definitions. A cache is a component that stores data so future requests for that data can be served faster. The data stored in a cache might be the results of an earlier computation, or the duplicates of data stored elsewhere. A cache hit occurs when the requested data can be found in a cache, while a cache miss occurs when it cannot. Cache hits are served by reading data from the cache which is faster than recomputing a result or reading from a slower data store. Thus, the more requests that can be served from the cache, the faster the system performs. One of the popular cache replacement policies is: "least recently used" (LRU). It discards the least recently used items first. For example, if a cache with a capacity to store 5 keys has the following state(arranged from most recently used key to least recently used ke...