473,396 Members | 2,151 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

about time and space complexities

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

Jun 21 '07 #1
4 1351
bh********@gmail.com wrote:
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.
--
clvrmnky <mailto:sp******@clevermonkey.org>

Direct replies will be blacklisted. Replace "spamtrap" with my name to
contact me directly.
Jun 21 '07 #2
On Thu, 21 Jun 2007 14:13:12 -0000, in comp.lang.c ,
"bh********@gmail.com" <bh********@gmail.comwrote:
>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
Jun 21 '07 #3
On Jun 21, 7:13 am, "bharath...@gmail.com" <bharath...@gmail.com>
wrote:
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 news:comp.programming and not
news:comp.lang.c, since it has nothing whatsoever to do with the C
language.

Jun 21 '07 #4
"bh********@gmail.com" <bh********@gmail.comwrote:
# 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

--
SM Ryan http://www.rawbw.com/~wyrmwif/
The whole world's against us.
Jun 24 '07 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

75
by: projecktzero | last post by:
I know this might not be the correct group to post this, but I thought I'd start here. A co-worker considers himself "old school" in that he hasn't seen the light of OOP.(It might be because...
24
by: Xah Lee | last post by:
in computer languages, often a function definition looks like this: subroutine f (x1, x2, ...) { variables ... do this or that } in advanced languages such as LISP family, it is not uncommon...
3
by: Edg Bamyasi | last post by:
This Is A Late Cross Post from comp.lang.python. It seems the mistery is deeper then i expected. What is the running time of conactination on character strings. i.e. >> joe="123" >>...
77
by: nospam | last post by:
Reasons for a 3-tier achitecture for the WEB? (NOTE: I said, WEB, NOT WINDOWS. DON'T shoot your mouth off if you don't understand the difference.) I hear only one reason and that's to switch a...
81
by: Matt | last post by:
I have 2 questions: 1. strlen returns an unsigned (size_t) quantity. Why is an unsigned value more approprate than a signed value? Why is unsighned value less appropriate? 2. Would there...
33
by: Lalatendu Das | last post by:
Dear friends, I am getting a problem in the code while interacting with a nested Do-while loop It is skipping a scanf () function which it should not. I have written the whole code below. Please...
8
by: Jamie | last post by:
Hello Newsgroup: This is my little rant about security and why we have home directories. You may choose to ignore it or disagree with it, that is your perogative and I won't care, but... this...
20
by: Steven D'Aprano | last post by:
Am I the only one who finds that I'm writing more documentation than code? I recently needed to write a function to generate a rank table from a list. That is, a list of ranks, where the rank of...
6
by: parag_paul | last post by:
Suppose I have a struct typedef struct atype{ int a; int b; } at; main(){ static at* j= 0;
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.