CS 162 Lecture Notes - Lecture 24: Binary Tree, Linked List, Nerf
CS 162 – Lecture 24 – Data Structures
Data Structures
o The conceptual shape or arrangement of the data
o Arrays
▪ Stored in contiguous memory
▪ Random access to data elements
▪ Same data
o Lists
▪ Not stored contiguously
▪ No random access
▪ Any data of the same type
o Dynamic
▪ Grouping data together
▪ Sequential ordering
Abstract Data Types
o Stack: entries are only inserted and removed at the head
▪ Last in, First out (LIFO)
▪ Push: add to the top/front
▪ Pop: remove from the top/front
▪ Ideal for storing items that must be retrieved in the reverse order from
which they are stored
▪ Examples:
• Stack of plates
• Recursion
o Sum(list)
▪ If len==0
• Return val
▪ Return sum(list-1)+val
• Parking in Corvallis
find more resources at oneclass.com
find more resources at oneclass.com