Path: utzoo!attcan!utgpu!utstat!jarvis.csri.toronto.edu!rutgers!cs.utexas.edu!uunet!portal!cup.portal.com!morris-ng From: morris-ng@cup.portal.com (Yuklung Morris Ng) Newsgroups: comp.sys.amiga Subject: Re: C help (Long) : Dynamic Allocation and Globals Message-ID: <19214@cup.portal.com> Date: 7 Jun 89 21:51:17 GMT References: <23129@srcsip.UUCP> Organization: The Portal System (TM) Lines: 55 re: Dynamical array: try this: struct link { int data; /* or whatever datatype */ struct link *next; }; struct doub_link { struct link *linkp; struct doub_link *next_link; }; when you know how many record you need: var = (struct doub_link *) calloc({how many}, sizeof(struct doub_link)) when you know how much element in size of the record: var1 = (struct link *) calloc({how much}, sizeof(struct link)); You have to develop the function for insertion, deletion, etc. It would be better if you try to link each node to its parent node, and the end point will point to the first node, as it will speed up you algorithm of the functions. If you prefer speed for searching and searching, try Binary search tree. The algorithm is in most data structure books. If you want utimate speed, and doesn't care of portability, try to you amiga specific function instead of calloc(). The above struct I provided looks like that: top_ptr -> ptr1 -> ptr2 -> ptr3 -> ... -> null <- very important! | | | ..... V V V ..... data data data | | | V V V data data NULL | | V V NULL NULL +------------------------------+------------------------------------+ | Morris Y. L. Ng | Usenet: morris-ng@cup.portal.com | | Computer Science & Finance | Portal: Yuklung Morris Ng | | San Jose State University | Home : (###)###-#### (Guess?!) | +------------------------------+------------------------------------+ | "Be my Amiga! And I will be your Amigo!" | +-------------------------------------------------------------------+