Category Archives: Arrays

Questions regarding Arrays

Given pairwise sum of n numbers, find the numbers

Pairwise sum of n (where n >= 3) numbers are given in a specified order, find the numbers. The order has pair sum of first and second, then first and third, first and fourth, … second and third, second and fourth, .. and so on. Consider an example: n = 4, let the numbers be… Read More »

XOR of all subarray XORs

Given an array of integers, we need to get total XOR of all subarray XORs where subarray XOR can be obtained by XORing all elements of it. Examples: Input : arr[] = [3, 5, 2, 4, 6] Output : 7 Total XOR of all subarray XORs is, (3) ^ (5) ^ (2) ^ (4) ^… Read More »

Search, insert and delete in a sorted array

In this post search, insert and delete operation in a sorted array is discussed. Search Operation In a sorted array, the search operation can be performed by using binary search. Output: Index: 5 Insert Operation In an unsorted array, the insert operation is faster as compared to sorted array because we don’t have to care… Read More »

Search, insert and delete in an unsorted array

In this post search, insert and delete operation in an unsorted array is discussed. Search Operation In an unsorted array, the search operation can be performed by linear traversal from the first element to the last element. Output: Element Found at Position: 5 Insert Operation In an unsorted array, the insert operation is faster as… Read More »