2-D Arrays
Chapter 2
Part Two
Data Structures and Algorithms Using Python R. Necaise.
2-D Arrays
Arrays can be defined with multiple dimensions.
Two-dimensional arrays:
organize the data in rows and columns
element access: [i,j]
Data Structures and Algor
Amortized cost is the average cost per use of the operation (function or
method). It can only be used when the operation is used n times in sequence.
The classication of an algorithm based on the order of magnitude on which an
algorithm executes.
Assume
Lang
-Jw.\o.¢|-Htm MmmcmicmmijMALlFOsmu-m
.limr Wu, A
mm} m cum MW)
3 mm
\WthkéhmmaMmmmmmlmgsmmm
you "alumina;
«H a; y.» lama. o. \33-\ um Mani-mu.
E El compnuug a; ° ' {MSW-n3 0Mme
¢ J. Hm. is mean+ 00)
• Set ADT: Unsorted List
◦ implemented using an unsorted Python list
• Sorted Sequences
◦ The efﬁciency of some algorithms can be improved when working with
sorted sequences
◦ we can use a sorted sequence to improve the efﬁciency of the Set ADT
◦ th
Sets
Data Structures and Algorithms Using Python, by R. Necaise.
Chapter 3
Introduction
The Set is a common container used in
programming.
stores unique values.
represents the mathematical set structure.
Data Structures and Algorithms Using Python, by R.
Searching
Data Structures and Algorithms Using Python R. Necaise
Searching
The process of selecting particular information
from a collection of data based on specific criteria.
Can be performed on different data structures.
sequence search
search key (or
• In Appendix A
• Rules of Coding
◦ Readability
‣ easy to read
‣ include comments
‣ use meaningful identiﬁers
◦ Comments
‣ only use the hash symbol
‣ describe various elements of code
• Variables
◦ a named storage location that associates a name
Maps
Data Structures and Algorithms Using Python R. Necaise
Maps
Stores a collection of records.
A unique key identifies each record.
Records are selected by key value.
aka dictionary.
Python provides a built-in dictionary.
Great example for comparing di
Arrays and Vectors
Data Structures and Algorithms Using Python R. Necaise.
Chapter 2
The Array Structure
An array is the most basic type of container.
Implemented at the hardware level.
Most languages provide arrays as a primitive type.
Can be used with
Algorithm Analysis
Data Structures and Algorithms Using Python R. Necaise
Part 1
Algorithms
Algorithms are designed to solve problems.
A problem can have multiple solutions.
How do we determine which
How do we determine which
solution is the most efficie
• Abstraction
◦ a concept or an idea that is not real
◦ used by computer scientist to help manage complex problems
‣ restrict the focus to those properties that are relevant in the current
context
‣ focus on the what not how
• Types of Abstractions
Project 1
Homework 1
the sum of the minimum
values from each row in 2D array
Homework 2
Product of neighbors is odd or even(1/0)
Counting number of
nodes in a circular linked list
Takes 4D array as
param, prints contents of every cell of that array
Quiz 1