Problems in Algorithm Design Set I

Write pseudocode for all the problems posed. Assume that any array that you are working with has integer values.

  1. How would you get the second highest number in an array of numbers using just one pass through the array? You may not sort the array. The second highest number is the highest number if you ignore one of the highest numbers.
  2. You are told that there is a common element in three sorted arrays of integers. How do you find that element in the most efficient way?
  3. How do you find the largest partial sum in an array that has both positive and negative numbers in just one pass through the array?
  4. Find the element that occurs the most number of times in a sorted array in one pass through the array.
  5. Find all combinations of 3 elements in an array.