180 likes | 412 Views
Data Structures. Main Concepts. Data Structures Stacks, queues, lists, trees, hash tables Algorithms Searching, sorting, recursion, analysis of running time. Definitions.
E N D
Main Concepts • Data Structures • Stacks, queues, lists, trees, hash tables • Algorithms • Searching, sorting, recursion, analysis of running time Lecture 1: Introduction
Definitions • A data structure is an organized collection of data with specific aggregate properties or “a systematic way of organizing and accessing data” in a computer’s memory • An algorithm is a sequence of program instructions designed to compute a particular result Lecture 1: Introduction
Data Structure Main Concepts “ A systematic way of organizing and accessing data” in a computer’s memory We use variables to store data in a computer’s memory. Does that mean that variables are data structures? Lecture 1: Introduction
Data Structure Main Concepts “ A systematic way of organizing and accessing data” in a computer’s memory We use variables to store data in a computer’s memory. Does that mean that variables are data structures? No. When we talk about data structures, we are referring to programming elements that can hold a lot of data, like an array. Lecture 1: Introduction
Data Structures as Tools Main Concepts • Data structures are tools that we use in our programs • Good data structures and algorithms are necessary for efficiency and speed in our applications • We will study • The most important data structures & algorithms • How to make them • How to use them • How to measure their performance • How to find readymade tools Lecture 1: Introduction
Data Structure Main Concepts Important things to remember about any data structure: • How are the data related? • For example, are they in a sequence? • This is the “organizing” part • What operations can be performed on the data? • This is the “accessing” part Lecture 1: Introduction
Data Structure Example Main Concepts Stack = data structure that stores data elements which are inserted or removed in LIFO (last-in first-out) order How are the data related? • Stored in a linear sequence determined by the insertion order What operations can be performed on the data? • Basic Operations on Stack • - Push (Insertion) • - Pop (Deletion) Uses: • Backtracking • Storing addresses in a Web browser’s history • Implementing an “undo” feature by storing changes • Reversing data • Parsing Lecture 1: Introduction
Algorithm Main Concepts • Definition of Algorithm(after Al Kho-war-iz-mi a 9th century Persian mathematician) – • An ordered sequence of unambiguous and well-defined instructions that performs some task and halts in finite time • an ordered sequence means that you can number the steps • unambiguous and well-defined instructions means that each instruction is clear, do-able, and can be done without difficulty • performs some task • halts in finite time (algorithms terminate!) Lecture 1: Introduction
Abstract Data Type • A specification for a data structure that tells us • The type of data stored • The operations that are supported • Specifies what the operations do, but not how they do it Lecture 1: Introduction
Five Steps per Datatype • Understand it Abstractly • Write a Specification • Write Applications • Implement • Analyze the Implementation Lecture 1: Introduction