C++ Program to check if given two trees are mirror or not is given below along with its algorithm and output. Many tech giants including likes of Amazon, DE Shaw has asked this question in their interview.
C++ Program and algorithm to find the first non-repeating character of a string is given below and this question has been already asked in the interviews of many companies including the giants like Amazon , Goldman Sachs etc..
python program for the insertion and deletion operation at the beginning of singly linked list is given below. In this program we have two method. insert_at_beg() to insert the element in the beginning and delete_at_beg() to delete the element at the beginning of the linked list.
Each node object must hold at least two pieces of information. First the data item in the node and the second is reference to the next node. A refrence to None means here that there is no next node. Note in the constructor that a node is initially created with next to None.
C Program tp print the elements of a Linked List along with ouput is given below.
This program will rotate an array to the left by n elements. It will take an input n to which number it will rotate the array to the left. C++ Implementation is here.
In priority scheduling algorithm, a priority is associated with each process and CPU is allocated to the process with the highest priority. If two processes have same priority then they will be execute in first come first serve order.
Trees can also be traversed in level-order. In level order traversal we visit every node of the level before going to the next level. C Program for level Order traversal of Binary tree using recursion is also given below.
Insertion sort, This algorithm repeatedly adds new element to the sorted result. In this algorithm we take first element as the sorted sub-array. Then we take second element and puts it into the first sorted sub-array at its correct position (i.e we do shifting if necessary).