university-skills

Basic Skills acquired in semesters in Programming

View on GitHub

WEEK 1

Brushing the Basics - 18th February 2022

  1. Bubble Sort
    You have been given an array A of size N . you need to sort this array non-decreasing oder using bubble sort. However, you do not need to print the sorted array . You just need to print the number of swaps required to sort this array using bubble sort

  2. Linear Search
    You have been given an array of size N consisting of integers. In addition you have been given an element M you need to find and print the index of the last occurrence of this element M in the array if it exists in it, otherwise print -1. Consider this array to be 1 indexed.

  3. Binary Search
    You have been given an array A consisting of N integers. All the elements in this array A are unique. You have to answer some queries based on the elements of this array. Each query will consist of a single integer x. You need to print the rank based position of this element in this array considering that the array is 1 indexed. The rank based position of an element in an array is its position in the array when the array has been sorted in ascending order.

  4. Insertion Sort
    You have been given an A array consisting of N integers. All the elements in this array are guaranteed to be unique. For each position i in the array A you need to find the position A[i] should be present in, if the array was a sorted array. You need to find this for each i and print the resulting solution.

  5. Selection Sort
    Consider an Array a of size N Iterate from 1 to N In ith iteration select the i th minimum and swap it with a[i] You are given an array a, size of the array N and an integer x. Follow the above algorithm and print the state of the array after x iterations have been performed.