CHAPTER 2
Introduction to Data Structures and Algorithm
NOTE: The material in this presentation is a compilation from the Zybook of “Principles of Data Structure”, the book “Data Structures and other objects using C++” by Michael Main and Walter Savitvch, and original content from your professor.
By Prof. Rafael Orta, M.S.
https://quizizz.com/
Last week we covered
NOTE: The material in this presentation is a compilation from the Zybook of “Principles of Data Structure”, the book “Data Structures and other objects using C++” by Michael Main and Walter Savitvch, and original material from your professor.
Agenda for this week
NOTE: The material in this presentation is a compilation from the Zybook of “Principles of Data Structure”, the book “Data Structures and other objects using C++” by Michael Main and Walter Savitvch, and original material from your professor.
What is a Data structure
A way of:
- Accessing
- Updating
- Searching
- Inserting new Data
- Removing Data
Basic Data Structures
Basic Data Structures
Options: Graph – Min heap tree – Max heap tree – Hash table – Binary Tree – Linked List – Array - Record
What C++ Abstract Data Type is very similar to a record
A/ A Struct
Live Demo
(Structs, Arrays & Vectors)
Introduction to Algorithms
“An algorithm describes a sequence of steps to solve a computational problem or perform a calculation. An algorithm can be described in English, pseudocode or a programming language among others.”
Introduction to Algorithms
“A computational problem specifies an input, a question about the input that can be answered using a computer, and the desired output..”
Introduction to Algorithms
Let’s work on this: What would be the gas cost for a trip from Philadelphia to Boston?
See C++ Code on my website
Relation between data structures and algorithms.
Abstracts Data Types
Video
Applications of ADT’s
Can you explain the relationship between data structures and algorithms ?.
Algorithm Efficiency
Different Algorithms have different running times
Time (sec.)
Input size (n)
O(n)
O(n5)
O(log2 n )
Can you think of an algorithm whose �running time complexity is Big O(log n)?
Binary Search
In general, the worst-case scenario of a Binary Search is Log of n + 1. The Big O notation for Binary Search is O(log N). In contrast to O(N) which takes an additional step for each data element, O(log N) means that the algorithm takes an additional step each time the data doubles.
Sometimes you sacrifice efficiency for simplicity, specially if the problem is complex, in that case you select the best algorithm you can find, which may not be the absolute best.
Video
What is the name of this data structure?.
A/ Linked List