DAA-Assignments

Questions

  • Take a 10 x 10 matrix (n x n in general) filled with random integer numbers. Trace the longest sorted partition:-
    • in each column of the matrix
    • Trace the longest sorted child of the matrix.
  • Assume a given set of unsorted numbers. You have to perform sorting. However, print the sorted numbers along with their original (initial) locations in the given array. Locate a key in the sorted array. Do the necessary experimentation and analysis with your algorithm.
  • Write an efficient algorithm to achieve the following. Given a set of numbers, find out the smallest and the largest numbers in the list. Swap the smallest with the first element and largest with the last element. Find the second smallest and second largest and swap them with their proper positions. Continue in this way until all the elements are sorted. Track the movement of every element in the list while sorting. Do the necessary experimentation and analysis with your algorithm.
  • Given a set of numbers, write an efficient Heap Sort algorithm to report the required (ascending/descending) sorted sequence. Trace the movement of every element of the Heap during the execution of your algorithm.
  • Write an efficient algorithm which, given an inorder traversal, can construct a corresponding complete binary tree. Do the necessary experimentation and analysis with your algorithm.
  • You are given a 2D array such that elements occur at only certain indices while the remaining array is empty. Write a program to find the location or indices of the elements present in the array by recursively dividing the matrix into 4 parts(quad1, quad2, quad3, quad4) discarding at each step the quads that are clean or empty.
  • There are n engineers and n jobs. Each engineer can get only one job. The respective liking for each job according to each engineer is given. Suggest an allotment such that the average liking of all the jobs is maximized.

Report