Anda di halaman 1dari 4

Introduction

Whether a secretary in an office, people waiting for an ATM, printing out work in a lab or organizing orders in a restaurant, some form of law, order and structure is needed. These three aspects combined form what programmers call a data structure. A data structure is a collection of data or objects that are organized in a certain fashion and contain rules. These rules include rules for adding to the structure, rules for accessing elements and rules for removing from data structure. In programming, common objectives include consistency and efficiency. Using these objectives as criteria, data structures are analyzed, experimented on and concluded about to help make decisions on when to use what. In this report a timing mechanism is used to time three main operations, namely insertion, searching and deletion. Different data structures perform differently in different situations. This is where the rules have the most effect. For the purpose of this report lists or data structures will be taken as sorted and searches performed are linear searches. After this experiment (timing), the results will be used to make conclusions, which will help with decisions and answer questions. Common questions include: What is the best performing data structure and is the performance consistent? Absolute answers might not exist but the experiment will definitely aid in giving a better light on when to use what.

Related Work
Stack
A stack is a simple data structure that uses LIFO (Last in First out) as its rule for access. Or alternatively it uses a First Come Last Served basis (FCLS). (Tokuta, 2008) (Langdon, 1996) It can be visualized as a pile of test papers on a lecturer s desk, the paper on top would be accessed first and the only way to access a specific paper is by going through the pile. Recursion can be simulated by a stack but a stack has performance limitations. One such limitation is the stack overflow limitation. This occurs when too many items are piled onto the stack, which uses quite a bit of memory and causes an overflow of memory. (Your Dictionary) (Mitchell, 2005) Considering the performance of a stack, the space used by the stack is linear whilst the operations run at a constant time (Rajaiah, 2010). Intuitively, inserting onto the top of the stack would be relatively fast because it entails one operation (called Push), same as removing from the top (called Pop). If an operation involves finding a specific item or place in the stack then it would slow performance down, due to the fact that it must create a temporary list, do its operation on the original list and restore everything again from the temporary list onto the original list when done.

Queue
A queue is a data structure that uses FIFO (First in First out) as its rule for access. Or alternatively it uses a First Come First Served basis (FCLS). (Tokuta, 2008) It can be visualized as a line of people waiting for their turn at an ATM, the first person in the line is the first person to get a chance, and new people stand at the back of the line. Most situations which have fairness and order would make use of a queue. It is a very real life related data structure. Considering the performance of a queue, the operations run at a constant time (elemaniaq, 2009). Intuitively, adding an item to the back would be quite fast, because it involves one operation, same as removing from the front. When looking for a specific item or place we make use of the same data structure by swopping front and back items, but this reduces performance because no matter what, if the list is needed in its original order, everything has to be moved.

Priority Queue
A priority queue is a type of queue that removes items (Dequeue s) on priority. It can be used to mimic sorting (Cilliers, 2010). A priority queue can be visualized as a campus print queue that prioritizes the printout according to the position of the person, i.e. lecturers and post grads get serviced before students. Any queue that takes care of items by priority or preference uses this type of data structure. It is also used in computer architecture when servicing I/O requests. Considering the performance of a priority queue, insertion is quick because it involves one operation but items are searched for and removed on priority so that might take longer due to the fact that it must find high priority items first. Certain operations of a priority queue are the same as a queue due to the fact that a priority queue is a subclass of a queue. Insertion is linear on average whilst removal is constant on average. (Goodrich, 2004)

Singly Linked Lists


A singly linked list is a list of items that are logically separated but are linked in one direction. A singly linked list consists of nodes, which contain the object and links, the first node is called the head and the last node is called the tail. A singly linked list can be visualized as orders at a restaurant which are on a separate order but are organized logically. Considering the performance of a singly linked list, it is much faster than the rest because items can be added to the front and the back. Items can also be added in between the list without going through entire list. Its going through operation or searching is fast because it just involves moving through pointers. Adding and removing take a bit longer because it has to modify pointers.

Doubly Linked Lists


A doubly linked list is a list of items that are logically separated but are linked in two directions. It is just as singly linked lists with nodes, head and tail but the only difference is the extra link, namely the back link . A doubly linked list can be visualized as orders in a restaurant but where orders are done iteratively, for the need to go back to an order, and forward to the next order. Considering the performance of a doubly linked list, it is almost same as a singly linked list but can take longer when adding or removing items because it needs to create / remove more pointers. Going through is easy because of the extra back link.

Experimental Method
Programs were coded with a timing mechanism, times were recorded and graphed. A 1000 items were considered. Conclusions were made and information was taken out of them.

Results
0.9000 0.8000 0.7000 0.6000 0.5000 0.4000 0.3000 0.2000 0.1000 0.0000 Stack Queue Pqueue SLL DLL

Insertion Searching Deletion

Bibliography
(n.d.). Retrieved from Your Dictionary: http://computer.yourdictionary.com Cilliers, C. (2010). Lecture Slides. elemaniaq. (2009, May 14). 09. Queues. Retrieved September 2010, from Scribd: http://www.scribd.com/elemaniaq Goodrich, T. (2004). Priority Queues. Retrieved from Scribd: http://www.scribd.com/doc/7359362/Priority-Queues Langdon, W. B. (1996, September 27). Genetic Programming and Data Structures. Mitchell, S. (2005, January). Part 2: The Queue, Stack, and Hashtable. Retrieved September 2010, from MSDN: http://msdn.microsoft.com/en-us/library/ms379571(VS.80).aspx Rajaiah, G. (2010, September 16). Stacks. Retrieved September 2010, from Scribd: http://www.scribd.com/doc/37568448/Stacks Tokuta, A. O. (2008). Data structure. AccessScience .

Anda mungkin juga menyukai