Team Emertxe
Function and Pointer
Basics
Assignment 19
Assignment 19
Assignment 19
Print the values in sorted order without modifying or
copying an array.
Assignment 19
Print the values in sorted order without modifying or
copying an array.
Input:
Assignment 19
Print the values in sorted order without modifying or
copying an array.
Input: Read integer ‘size’ and an array ‘arr[size]’
Assignment 19
Print the values in sorted order without modifying or
copying an array.
Input: Read integer ‘size’ and an array ‘arr[size]’
Output:
Assignment 19
Print the values in sorted order without modifying or
copying an array.
Input: Read integer ‘size’ and an array ‘arr[size]’
Output: Print the values in sorted order.
Assignment 19
Example’s:
Assignment 19
Example’s:
⮚Input: size = 5, arr[5] = {10, 3, 1, 8, -1}
Assignment 19
Example’s:
⮚Input: size = 5, arr[5] = {10, 3, 1, 8, -1}
Output:
Assignment 19
Example’s:
⮚Input: size = 5, arr[5] = {10, 3, 1, 8, -1}
Output: After sorting: -1, 1, 3, 8, 10
Assignment 19
Example’s:
⮚Input: arr[5] = {10, 3, 1, 8, -1}
arr 10 3 1 8 -1
0 1 2 3 4
index
Assignment 19
Example’s:
⮚Assign large and small to arr[0].
arr 10 3 1 8 -1
large & small
0 1 2 3 4
index
Assignment 19
Example’s:
⮚Find out smallest and largest on arr.
arr 10 3 1 8 -1
large small
0 1 2 3 4
index
Assignment 19
Example’s:
⮚Assign sec_small = large.
arr 10 3 1 8 -1
large and sec_small small
0 1 2 3 4
index
Assignment 19
Example’s:
⮚Print the values using ‘small’ value in each iteration and
compare all the elements with ‘small’ and ‘sec_small’.
arr 10 3 1 8 -1
small
large and sec_small
O/p:
-1
0 1 2 3 4
index
Assignment 19
Example’s:
⮚Check arr[0] > small & arr[0] < sec_small, false.
arr 10 3 1 8 -1
small
large and sec_small
0 1 2 3 4
index
Assignment 19
Example’s:
⮚Check arr[1] > small & arr[1] < sec_small, true. So assign
sec_small = arr[1].
arr 10 3 1 8 -1
small
sec_small
large
0 1 2 3 4
index
Assignment 19
Example’s:
⮚Check arr[2] > small & arr[2] < sec_small, true. So assign
sec_small = arr[2].
arr 10 3 1 8 -1
small
sec_small
large
0 1 2 3 4
index
Assignment 19
Example’s:
⮚Check arr[3] > small & arr[3] < sec_small, false.
arr 10 3 1 8 -1
small
sec_small
large
0 1 2 3 4
index
Assignment 19
Example’s:
⮚Check arr[4] > small & arr[4] < sec_small, false.
arr 10 3 1 8 -1
small
sec_small
large
0 1 2 3 4
index
Assignment 19
Example’s:
⮚After all the elements are compared, assign small = sec_small
and sec_small = large and print the small.
arr 10 3 1 8 -1
small
large & sec_small
O/p:
-1
1
0 1 2 3 4
index
Assignment 19
Example’s:
⮚Continue this process to get the sorted order.
arr 10 3 1 8 -1
small
large & sec_small
0 1 2 3 4
index
Assignment 19
Example’s:
arr 10 3 1 8 -1
small
large sec_small
0 1 2 3 4
index
Assignment 19
Example’s:
arr 10 3 1 8 -1
large & sec_small small
O/p:
-1
1
3
0 1 2 3 4
index
Assignment 19
Example’s:
arr 10 3 1 8 -1
large small sec_small
0 1 2 3 4
index
Assignment 19
Example’s:
arr 10 3 1 8 -1
large & sec_small small
O/p:
-1
1
3
8
0 1 2 3 4
index
Assignment 19
Example’s:
arr 10 3 1 8 -1
large, sec_small & small
O/p:
-1
1
3
8
10
0 1 2 3 4
index
Assignment 19
Sample execution:-
Assignment 19
Sample execution:-
Assignment 19
Sample execution:-
Assignment 19
Sample execution:-
Assignment 19
Pre-requisites:-
Assignment 19
Pre-requisites:-
⮚Arrays
Assignment 19
Pre-requisites:-
⮚Arrays
⮚Functions
Assignment 19
Pre-requisites:-
⮚Arrays
⮚Functions
⮚Pointers
Assignment 19
Pre-requisites:-
⮚Arrays
⮚Functions
⮚Pointers
⮚Nested loops
Assignment 19
Pre-requisites:-
⮚Arrays
⮚Functions
⮚Pointers
⮚Nested loops
Objective:-
Assignment 19
Pre-requisites:-
⮚Arrays
⮚Functions
⮚Pointers
⮚Nested loops
Objective:-
To understand the concept of
➢ Arrays
Assignment 19
Pre-requisites:-
⮚Arrays
⮚Functions
⮚Pointers
⮚Nested loops
Objective:-
To understand the concept of
➢ Arrays
➢ Functions
Assignment 19
Pre-requisites:-
⮚Arrays
⮚Functions
⮚Pointers
⮚Nested loops
Objective:-
To understand the concept of
➢ Arrays
➢ Functions
➢ Pointers
Team Emertxe
Thank you

19_sorted_order.pdf