Merge two sorted arrays into one sorted array. Given two sorted arrays, write a code to merge them in a sorted manner.
Input:
arr1 = { 1, 5, 6, 7}, arr2 = { 2, 5, 8, 9, 11}
Output:
{1, 2, 5, 5, 6, 7, 8, 9, 11}
Given an array consisting of 0s, 1s, and 2s. Write code to sort an array of 0s, 1s, and 2s without using an extra space or a sorting algorithm.
OR
Given an array of size n containing only 0s, 1s, and 2s. Write a code to sort the array in ascending order.
For example:
Input : {0, 1, 1, 0, 1, 2, 0, 1, 2}
Output : {0, 0, 0, 1, 1, 1, 1, 2, 2}
In this example, the input array only consists of 0s, 1s, and 2s in an unsorted order.
In the output array, all the 0s, 1s and 2s are in sorted order.
Given a binary tree, print the level order traversal of its node’s values.
For example:
Given below binary tree, the level order traversal of this binary tree is 7, 6, 5, 4, 3, 2, 1.