Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

assume that you are dealing with numbers written in octal notation. Further assu

ID: 3543806 • Letter: A

Question

assume that you are dealing with numbers written in octal notation. Further assume that you are given an octal number that is eight digits long. Finally assume that this number uses eight different octal digits that is, no digit appears more than once

i.e: 70162534


the largest such number that exists is 76543210. The smallest number that exists is 01234567. (note that we allow for leading zero in our numbers.)

write a alogrithm that takes as its input one such number and returns the next highest number that is also one of these numbers. write the algorithm in pseudo-code

example: 74536201

example output: 74536210

Explanation / Answer

while(next such number is not reached){

if ith digit is 7{

make ith digit as 0;

increment the value of i to i+1 (move to the next higher digit)

increment the ith digit

//here the (i+1)th digit simply means next higher digit

}

else{

increment the ith digit by 1

}

}

The loop will terminate when next such number is found