our prof. gave us this pseudocode a while ago...and i'm having a hard time with this part
Pseudocode
and the array index value is 14 with 14 string names
Shell_Sort(Arr,N)
{ If(N=1) then
{
Exit
}
Set Interval to N
while(Interval is not 1)
{
Set Interval to ((Interval/3)+1) If(Interval is not a whole number) then <--------- here is the part i'm having trouble with
{
Truncate Interval <------------ and here how can i truncate the interval into a whole number?
}
Set start to 1
while(start <= Interval)
{
Sort()
Increment start
}
}
}
sort()
{
set Unsrt_Indx to (start + interval)
while(unsrt_Indx <= N)
{
if (Arr[Unsrt_Indx - Interval] > arr[unsrt_Indx] then
{
set str_indx to unsrt_indx
set temp to arr[srt_indx]
while((str_indx >start && (arr[str_indx-Interval] > temp))
{
set arr[set_indx] to arr[str_index- interval]
set str_indx to (crt_index - interval)
}
set arr[str_indx] to temp
}
set unsrt_indx to (unsrt_indx + interval)
}
}
how can i use a if statement in determining if it is not whole number??
and how do i use truncate?? truncating it into ones twos or threes.
ex.
4.6666666666667
how can i truncate it into
4.67
4.6
4
something like that.