C++: Sorting Elements by Frequency

We are going to write a program to sort the elements of an array by Frequency. If two elements have the same frequency of occurrence, then they are sorted in increasing order.

For eg. an array has { 2, 3, 2, 4, 5, 12, 12, 3, 4, 3 }

Then the output will be

3 3 3 2 2 4 4 12 12 5

Top 10 Web Sites Every Programmer Should Visit Daily

Computer programming is one of the fastest growing field. If you are a programmer then you can be hired by a top tech company or you can also work as a freelancer and earn decent amount. So the question arises, how to learn to code ? Initially it was very difficult to learn programming. As there was no internet and you have to relay on books or your colleagues’ code. Now you can find tons of material on the internet. You can learn any computer programming language you want. I am going to tell you some sites which you should visit regularly. 

C++: STL Iterators

Iterators arepointer like object which are used to point at the memory addressess of STL containers.

Properties of Iterator 

We can dereference an iterator in order to access the value towhich itrefers. That is, if p is an iterator, *pis defined.

We can assign one iterator to another. That is, if p and q areiterators, theexpression p = qis defined.

We can compare one iterator to another for equality. That is, if p and q are iterators, the expressions p == q and p != qare defined.

We can move an iterator through all the elements of a container. This canbe satisfied by defining ++p and p++ for an iterator p .

C++: Queue implementation using Linked List (Data Structure)

We have already learnt about Queue int the post C++: Implementation of Queue using Array (Data Structure). Now we are implementing Queue using Linked List which we have learnt in C++: Singly Linked List using Template (Data Structure).

Here is the C++ program for implementing Queue using Linked List.

C++: Stack implementation using LinkedList (Data Structure)

We have already learnt about Stack in the post C++: Implementation of Stack using Array (Data Structure).  Now we are implementing Stack using Linked List which we have learnt in C++: Singly Linked List using Template (Data Structure). The C++ program for implementing Stack using Linked List is very simple. For push() and pop() function we have to use insert() and deleteNode() function from Linked List program.