for tuesday
play

For Tuesday Read Weiss, chapter 4, sections 1,2,6 This should again - PowerPoint PPT Presentation

For Tuesday Read Weiss, chapter 4, sections 1,2,6 This should again be review as far as concepts. Can refer to Savitch for more on C++ Homework: List practice homework described on ReggieNet Late Passes You have 2 for the


  1. For Tuesday • Read Weiss, chapter 4, sections 1,2,6 – This should again be review as far as concepts. – Can refer to Savitch for more on C++ • Homework: – List practice homework described on ReggieNet

  2. Late Passes • You have 2 for the semester. • Only good for programs and papers. • Allow you to hand in up to 5 days late IF you have a late pass left. • Each good for +.05 on final grade if unused. • Must acknowledge the use of the late pass. • Only way to turn in late work in this course.

  3. Programming Assignment 1

  4. Linked Lists • What’s the basic concept?

  5. What Is a Node? • Two parts – Data – Pointer to the next one • Make the data public • Do provide a constructor with appropriate defaults

  6. Creating Nodes • We’ll always create nodes dynamically. • Note that we almost never actually work with a node itself; we use pointers to the nodes. • Important: – ALWAYS initialize next to NULL when a node is created unless you are immediately assigning it another meaningful value.

  7. C++ Details • Deleting nodes . . .

  8. Linked List Variations • Doubly-linked lists • Empty head node

  9. Stacks • What is a stack? • What would a stack ADT look like? • How could you implement a stack? • What are stacks used for?

  10. Stack ADT • AbstractDataType Stack { instances linear list of elements; one end is the top operations IsEmpty() IsFull() (not always needed) Top() Push(element) Pop() }

  11. Queues • What is a queue? • What would a queue ADT look like? • How could you implement a queue? • What are queues used for?

  12. Queue ADT • AbstractDataType Queue { instances linear list of elements; one end is the front , the other the rear operations IsEmpty() IsFull() (not always needed) Front() Add(elem) (or Put(elem) or Enqueue(elem)) Delete() (or Get() or Dequeue()) }

  13. A Note on Push and Pop • In this class, do not use push and pop to refer to queue operations. • They should only apply to stack operations.

  14. Queues and Stacks • Often used in similar contexts to achieve different desired results. • Often used in conjunction with other data structures.

  15. Trees • Hierarchical structure • Single root • Each node has zero or more children • Each node except the root has exactly one parent

  16. Tree Definition • A tree t is a finite nonempty set of elements. One of these elements is called the root, and the remaining elements (if any) are partitioned into trees which are called the subtrees of t.

  17. Tree Vocabulary • Root • Leaf • Child • Subtree • Parent • Forest • Sibling • Degree • Grandchild • Level • Grandparent • Height • Ancestor • Descendent

  18. Tree properties • There is exactly one path connecting any two nodes in a tree. – Least common ancestor – Any node could be a root. • A tree with N nodes has N-1 edges.

Download Presentation
Download Policy: The content available on the website is offered to you 'AS IS' for your personal information and use only. It cannot be commercialized, licensed, or distributed on other websites without prior consent from the author. To download a presentation, simply click this link. If you encounter any difficulties during the download process, it's possible that the publisher has removed the file from their server.

Recommend


More recommend