140 likes | 361 Views
Data Structures. Introduction. What is data?. (Latin) Plural of datum = something given. Data and Operations. "Data" and "Operations" are to Computer Science as "Point" and "Line" are to Geometry. Undefined terms, the starting point. Computers, Algorithms, Programs.
E N D
Data Structures Introduction
What is data? • (Latin) Plural of datum = something given.
Data and Operations • "Data" and "Operations" are to Computer Science as "Point" and "Line" are to Geometry. • Undefined terms, the starting point.
Computers, Algorithms, Programs • Computers are machines that perform operations on data • Algorithms are sequences of operations to be performed on particular types of data in order to achieve a meaningful outcome. • Programs are algorithms that are coded in a particular syntax or language such as Assembly, C++, Java, or Python
Data vs. information • Data becomes information when it is structured in some way that has meaning.
Ways of structuring data • Bit strings (0's and 1's) • Integers • Floating point numbers • Logical values (True, False) • Characters • Strings • Lists, Queues, Dequeus, Trees • Files, pictures …
Operations • Each data structure has its own set of operations. • Integers: • Add, multiply, divide, compare… • Strings of characters • Concatenate, print, compare, substrings…
In Data Structures, we study • Ways of structuring data Abstract Data Types (ADT's) e.g. Lists, Stacks, Queues, Trees, Graphs • Operations on those data types Algorithms to manipulate ADT's e.g. Searching, Sorting, Recursion
User Interface Implementation Operations ADT's encapsulate. Data & Algorithms.
List 10 random 2-digit integers >>>from random import randint >>>[randint(10,100) for i in range(10)] [87, 35, 52, 88, 87, 60, 19, 19, 26, 72] Examples of encapsulation: randint(a,b): An algorithm not in Python range(n): Implemention is built in to Python List: An abstract data type
Use of Abstract Data Types • Separates the problem of implementation from that of manipulation • Allows the programmer to solve problems without regard to implementation. • Allows the programmer to alter the implementation without affecting problems already solved.
Understanding Data Structures • Helps you write better programs • Makes you a better problem solver • Helps you use computers more efficiently • Helps you maintain programs more effectively
Why Python? • Fact: (Alan Turing) Any computer (with a minimal set of operations) can, with enough time and memory, perform any task any other computer can do. • Any programming language (with a minimal set of operations) can implement any algorithm that any other programming language can implement.
Python • Has an impressive set of built-in data structures. • New data structures can be implemented relatively easily. • Interpreted language. You can try anything before compiling.