about time and space complexities

B

bharath539

how to write programmes which minimizes time and space complexities
let suppose for linked lists related programmes
 
C

Clever Monkey

how to write programmes which minimizes time and space complexities
let suppose for linked lists related programmes
One often has to balance time and space requirements. In your example
you mention a linked list. Well, for some applications a doubly linked
list is faster, but it requires slightly more space.

Most of the old-timers here will tell you to get it correct first, and
only then optimize.
 
M

Mark McIntyre

how to write programmes which minimizes time and space complexities
let suppose for linked lists related programmes

First learn how to write clean code. Unless your code is clean and
easy to read, you will find it hard to optimise.

Then learn how to turn on all your compiler optimisations. The
compiler writer is probably better than you at optimising things.

Then learn how to optimise the algorithms. Note this is nothing to do
with code, its to do with understanding the algorithm and how to make
it more efficient.

Then, if its still not fast enough or small enough for you, profile
the code using specialist tools for your platform.

Then, if and only if you need to, start trying to optimise the code
itself.

Bear in mind that you can have simple, fast or small but rarely all
three at once.
--
Mark McIntyre

"Debugging is twice as hard as writing the code in the first place.
Therefore, if you write the code as cleverly as possible, you are,
by definition, not smart enough to debug it."
--Brian Kernighan
 
U

user923005

how to write programmes which minimizes time and space complexities
let suppose for linked lists related programmes

Singly and doubly linked lists are O(N) in time and space.
An optimization in time (insert is slower but find/update/delete
become log(N)) at a small cost (space becomes N*log(N)) in space is a
skiplist.
A web search will show you all about it.

The way to make improvements in space and time is to alter the
fundamental underlying algorithm and data structure.

Your question is suited to and not
since it has nothing whatsoever to do with the C
language.
 
S

SM Ryan

# how to write programmes which minimizes time and space complexities
# let suppose for linked lists related programmes

Build your code around known efficient algorithm and think deeply.
People are paid to spend years thinking about these things at
universities: if it were easy they wouldn't get their grants
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
474,166
Messages
2,570,907
Members
47,448
Latest member
DeanaQ4445

Latest Threads

Top