1 / 9

Data Structures

Data Structures. You have already come across elementary data types integer real Boolean And some structured data types (data structures) string array record. Data Structures. Other data structures such as Queues Stacks & Binary Trees Have to be constructed by the programmer.

saki
Download Presentation

Data Structures

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Data Structures You have already come across elementary data types • integer • real • Boolean And some structured data types (data structures) • string • array • record

  2. Data Structures Other data structures such as Queues Stacks & Binary Trees Have to be constructed by the programmer

  3. Queues Queues are data structures that maintain the order of FIFO First In First Out

  4. Queues New elements may only be added to the end of a queue; and elements may only be retrieved from the front of a queue. Pointers mark the front and rear of the queue. front rear

  5. Stacks The terminology associated with stacks comes from the spring-loaded plate containers you get in canteens. They maintain the order LIFO Last In First Out

  6. Stacks New elements are added to the top of the stack. The item at the top of the stack is the first to be removed. top

  7. Queues and Stacks Queues are used for • Characters typed at a keyboard are held in a keyboard buffer • Output waiting to be printed is commonly stored in a queue Stacks are used for • Calculations • Used to store the return address when a subroutine is called

  8. Queues and Stacks An example http://www.cmpe.boun.edu.tr/~akin/cmpe223/stack_queue/chap2_2.htm

  9. Queues and Stacks Queues are more difficult to implement than Stacks. A Stack can be used to reverse a Queue. Stacks and Queues have preset sizes. If you try to add an element to a queue or stack that has no free space you get overflow. If you try to remove an element from an empty queue or stack you get underflow.

More Related