hi everyone
im my computer science degree am doing a module on algorithms

tho we are studying it i am bit behind

my question is
what does n - 1 mean (n minus 1)

what does n/2 mean (n over 2 or n divided by 2)

because stuff like this is being mentioned am soo confused when the being used i need to know what they mean, and why is it being used and when would you use them..

iv looked on wiki and stuff just more complicated good i wish there pdfs or links that really tech's you from the basics but anyways

please can anyone help with my question

Recommended Answers

All 6 Replies

You already know what those things mean. If you're talking about big oh complexity or something of that nature then state your questions more clearly.

Hi Ashok here
See these terms which u mentioned are used in looping statements, and where 'n' is used to represent no.of terms.
And n-1 terms are mostly used in Arrays,
for ex if an array has 10 items then n-1 would give u the size of that array, since index of arrays stars from 0.
n/2 would be 5 in this case
ex: for i=0 to n-1
print a
where a[] is an array;and here we are printing the elements of the array.
if we had given n/2,then we would print only the half of the array elements....

i hope my explanation has helped u.........

my question is
what does n - 1 mean (n minus 1)

That's the same kind of minus as the minus key on your calculator. Just put n - 1 into Mr. Calculator and you'll calculate running time.

what does n/2 mean (n over 2 or n divided by 2)

That's the same thing as n ÷ 2.

because stuff like this is being mentioned am soo confused when the being used i need to know what they mean, and why is it being used and when would you use them..

Yeah, it can get confusing, but you don't need to know this low level stuff. Just use your calculator.

>for ex if an array has 10 items then n-1 would give u the size of that
>array, since index of arrays stars from 0.

I think it should be that if an array has n items then n-1 would give u the highest possible subscript of that array, since in c,c++,python (and other popular languages) index of arrays stars from 0.
When studying about algorithms, array doesn't necessarily 'starts' with a zero. Many author use 1-based array, namely the ``Introduction to Algorithm" by CLRS

To OP:
Please re-frame your question such that it could be understood.

its ok i know wat they mean ans stuff i already did its just i found it confusing when using them

thanks

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.