Professional Documents
Culture Documents
CSE2100 Assignment 2 (Jude Edwards)
CSE2100 Assignment 2 (Jude Edwards)
ALGORITHMS
Name: Jude Edwards
Course Name: Data Structures & Analysis of Algorithms
Course Code: 2100
Lecturer: Jason Phillips
TABLE OF CONTENTS
01 02 03
CODING /
ALGORIT IMPLEMENTATIO
THEORY HM N
THEORY 01
SHELL
ALGORITHMS
Shell sort is mainly a variation of Insertion Sort. In insertion sort, we move elements
only one position ahead. When an element must be moved far ahead, many
movements are involved. The idea of Shell Sort is to allow the exchange of far items.
In Shell sort, we make the array gap-sorted for a large value of ‘gap’. We keep
reducing the value of ‘gap’ until it becomes 1.
● Can be used when calling a stack overhead or when a recursion exceeds its limit.
ALGORIT
HM 02
SHELL ALGORITHMS (How does it work )
ARR [9] = {80, 156, 90, 568, 25, 62, 8, 4, 185} GAP = 9 / 2 = 4.5 4
FIRST ITERATION
SHELL ALGORITHMS ( How does it work )
ARR [9] = {25, 62, 8, 4, 80, 156, 90, 568, 185} GAP = 4/2 = 2
ARR [9] = {8,
62, 25, 4, 80, 156, 90, 568, 185}
ARR [9] = {8, 4, 25, 62, 80, 156, 90, 568, 185}
ARR [9] = {8, 62, 25, 4, 80, 156, 90, 568, 185}
SECOND ITERATION
SHELL ALGORITHMS ( How does it work )
ARR [9] = {8, 62, 25, 4, 80, 156, 90, 568, 185} GAP = 2/2 = 1
ARR [9] = {8,
25, 62, 4, 80, 156, 90, 568, 185}
ARR [9] = {8, 25, 4, 62, 80, 156, 90, 568, 185}
ARR [9] = {8, 4, 25, 62, 80, 156, 90, 568, 185}
ARR [9] = {4, 8, 25, 62, 80, 90, 156, 568, 185}
ARR [9] = {4, 8, 25, 62, 80, 90, 156, 185, 568} THIRD ITERATION
CODING &
IMPLEMENTAT
ION 03