Queues operate just like stacks, except items are removed from the bottom instead of the top. Some textbooks call this data structure a “push-down stack” or a “LIFO stack”. An analogy to this is a stack of books on a desk: a new book is placed on the top of the stack (pushed) and a book is removed from the top also (popped). If the stack was empty (because nothing had ever been pushed on it, or if all elements have been popped off of it), then X is given the special value of NIL. A command of the form PUSH("A") puts the key "A" at the top of the stack the command “X = POP()” removes the top item from the stack and stores its value into variable X. The rest of this page is an overview of these structures.Ī stack supports two operations: PUSH and POP. Implementation varies by computer language, but for our purposes, they can all be represented as a list of items that might contain duplicates. There are many online resources covering these basic data structures indeed there are many books and entire courses devoted to fundamental data structures. One can only find out or delete the smallest element of the list. A priority queue is used like a binary search tree, except one cannot delete an arbitrary item, nor can one make an arbitrary query. ![]() find out if a particular item is found in the list of items and if not, which item is close to the item in question). A binary search tree is used when one is storing items and needs to be able to efficiently process the operations of insertion, deletion, and query (i.e. This is also known as “first-in, first-out” (FIFO) order. A queue is usually used to process items in the order in which requests are generated a new item is not processed until all items currently on the queue are processed. Items are processed in a “last-in, first-out” (LIFO) order. Questions will cover these data structures and implicit algorithms, not specific to implementation language details.Ī stack is usually used to save information that will need to be processed later. This category concentrates on four of the most basic structures: stacks, queues, binary search trees, and priority queues. The bigger the data sets, the more important data structures are in various algorithms. It is hard to separate these two items, for data structures are meaningless without algorithms to create and manipulate them, and algorithms are usually trivial unless there are data structures on which to operate. At the heart of virtually every computer program are its algorithms and its data structures.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |