473,396 Members | 2,011 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.

Memory vs. Efficiency ???

3
I have a program which has three main datastructures (linked lists):
1) Molecule [main linked list - a molecule file has several residues]
2) Res - linked list with it's own attributes
4) CloseRes - linked list (each Res has pointers to a structure which keeps track of the res close to this res)

There are two issues :
a) A molecule file (main input file) can have ~500 res [ so 500 node Res linked list]. If I have to process 10 such molecule files at the same time then what is the best way to do so ?
- Extending the molecule linked list is one way - but memory can be an issue here ???
- Writing output for each molecule to a file and then writing another program to process those files is another way -- efficiency seems to be an issue here???

b) For each set of "Close Res - pt 4 above" I have to do a computation for which I need to run a program considering the "CloseRes" and all the other molecule files --
- Should I just write each CloseRes to a file, run the program --repeat ---- not sure if this is the best approach

Given below is a code snippet representing the struct:
I will appreciate your suggestions. Thanks!

Code:

Expand|Select|Wrap|Line Numbers
  1. struct _res_type;
  2. struct _closeres_type;
  3.  
  4. //res for a molecule
  5. typedef struct _res_type
  6. {
  7.   char* resName;
  8.   int resNo;
  9.   float cx, cy, cz;
  10.   float vScore;
  11.   float sEnvScore;
  12.  
  13.   struct _closeres_type* closeres;
  14.   struct _res_type* prev;
  15.   struct _res_type* next;
  16. }res_type;
  17.  
  18. //close_res for a res
  19. typedef struct _closeres_type
  20. {
  21.   res_type* res;
  22.   struct _closeres_type* next;
  23. }closeres_type;
  24.  
  25. //molecule with the res
  26. typedef struct _molecule_type
  27. {
  28.   int noRes;
  29.   res_type* res;
  30.   struct _molecule_type* prev;
  31.   struct _molecule_type* next;
  32. }molecule_type;
  33.  
  34.  
Jun 22 '07 #1
4 1346
weaknessforcats
9,208 Expert Mod 8TB
Are you using C or C++? The answer will be different.
Jun 23 '07 #2
ts4
3
I am using C for this. I will appreciate your response.
Thanks!
Jun 25 '07 #3
weaknessforcats
9,208 Expert Mod 8TB
Your Molecule could be a linked list of 500 linked lists or maybe it is an array of 500 elements where each element is a pointer to a Res linked list.

This would be called a chain-link table. However, the linked list will work if the 500 figure is soft.

So you would have 10 of these tables.

Write a function to process one of these tables.

Write other functions to read/write these table to from/to disc. The read function would build the table in memory.

Your CloseRes would be handle the same way.

As to memory, do a sizeof on all of your structs and multiply out the total. I expect everything will fit in memory.

I see a program that does data acquisition, data processing, and data store/retrieval. Unless you are dealing with hundreds of thousands of lines of code, then probably one program will be the ticket.
Jun 25 '07 #4
ts4
3
Thanks for your response. I did extend my molecule linked list as suggested by you. So, now my molecule linked list has 10(current max) molecule nodes and each molecule node is linked to another linked list with 100-500 nodes.

It works for 100 nodes but I haven't yet tested it for 500 nodes.
Thanks for your help!
Jun 25 '07 #5

Sign in to post your reply or Sign up for a free account.

Similar topics

0
by: kayra | last post by:
Hi all, I want to get your opinions on how to increase available/free memory and performance on a heavy volume database server. I have MySQL 4.0.13 running on RH 7.2 replicated to another RH...
18
by: Tron Thomas | last post by:
Given the following information about memory management in C++: ----- The c-runtime dynamic memory manager (and most other commercial memory managers) has issues with fragmentation similar to a...
8
by: vikram | last post by:
i have series of questions 1.How a c program is loaded in memory i mean the whats is the structure that the code segment?? data segment?? 2.When you say const int *p; where is p...
11
by: Eric A. Johnson | last post by:
Hi, The book I am studying from, which comes from 1994, makes mention of far memory (i.e., that memory beyond 64K). I am under the belief, however, that far memory no longer needs any special...
12
by: ira2402 | last post by:
Hi All, We are developing sw for a small embedded OS and we have limited memory. We are looking for algorithms, links, and articles about this. The goal is efficient utilization of small amount...
13
by: hurry | last post by:
In order to avoid declaring static variables in a function I was asked to write a scratch memory. Reserve a block of memory outside the function and assigning pointers to the memory locations as...
74
by: ballpointpenthief | last post by:
If I have malloc()'ed a pointer and want to read from it as if it were an array, I need to know that I won't be reading past the last index. If this is a pointer to a pointer, a common technique...
9
by: burningsunorama | last post by:
Hi guys! This is maybe a too 'academic problem', but I would like to hear your opinions, something like pros and cons for each approach.... ... Recently we've had at work a little talk about the...
15
by: tom | last post by:
why delete the dynamically allocated memory twice causes an error, see the code below: int _tmain(int argc, _TCHAR* argv) { int *pi = new int(12); cout<<*pi; delete pi; delete pi; }
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
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:
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...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

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.