Q.1. Implement insertion sort using C++ STL with following constrain and write a program : The insertion sort procedure uses searching procedure to find the position of the unsorted array elements in sorted array. This searching procedure can start from the beginning index of the sorted array or ending index of the sorted array. Here your program should consider the searching procedure that should starts from beginning index of the sorted array.

C++ Programming: From Problem Analysis to Program Design
8th Edition
ISBN:9781337102087
Author:D. S. Malik
Publisher:D. S. Malik
Chapter17: Linked Lists
Section: Chapter Questions
Problem 17SA
icon
Related questions
Question

Q.1. Implement insertion sort using C++ STL with following constrain and write a program :

The insertion sort procedure uses searching procedure to find the position of the unsorted array elements in sorted array. This searching procedure can start from the beginning index of the sorted array or ending index of the sorted array. Here your program should consider the searching procedure that should starts from beginning index of the sorted array.

Q.2.  Implement insertion sort using C++ STL with following constrain and write a program :

To find the position of the unsorted-array elements in insertion sort, it is depending on searching procedure. In this procedure it stops at a position after identifying the first occurred element (in sorted-array) which is greater than the element (in unsorted-array). Here the programmer should apply intelligence in such a way that, the position of an element can be identified after finding the closet element in sorted-array.

Example: Let the elements in unsorted array are: 5,2,4,6,1,3

The sorted-array after few iterations of insertion sort is: 2,5,4,6,1,3. Here the elements 2 and 5 are in sorted-array and the elements 4, 6, 1 and 3 are in unsorted-array. While identifying the position of element – 4, we can compare it with element – 5, then it concludes that 5 > 4. So, it will proceeds further and compare with element – 2 in sorted-array. Here 4 is very close to 5 than 2. You need to stop this procedure at element – 5 and perform the rotation to include 4 insorted-array.

Q.3.  Implement insertion sort using C++ STL with following constrain and write a program :

Use binary searching procedure to find the position of the unsorted-array elements in sorted-array. Perform the rotations procedure to insert elements in sorted-array after finding the position using binary search.

Expert Solution
steps

Step by step

Solved in 3 steps with 1 images

Blurred answer
Knowledge Booster
Functions
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
C++ Programming: From Problem Analysis to Program…
C++ Programming: From Problem Analysis to Program…
Computer Science
ISBN:
9781337102087
Author:
D. S. Malik
Publisher:
Cengage Learning
C++ for Engineers and Scientists
C++ for Engineers and Scientists
Computer Science
ISBN:
9781133187844
Author:
Bronson, Gary J.
Publisher:
Course Technology Ptr