This document provides an overview of data structures and algorithms. It discusses topics like arrays, stacks, queues, sparse matrices, and analysis of algorithms. Key points include:
- Arrays allow storing elements in contiguous memory locations and accessing via indexes. Representations include one-dimensional, two-dimensional, and sparse arrays.
- Stacks follow LIFO while queues follow FIFO using operations like push, pop for stacks and enqueue, dequeue for queues.
- Sparse matrices store only non-zero elements to save space using representations like triplet format and linked lists.
- Algorithm analysis includes asymptotic analysis of time and space complexity using notations like Big O. Performance of common operations on data structures is also
Data Structure & aaplications_Module-1.pptxGIRISHKUMARBC1
This document provides information about the course "Data Structures and Applications". The course aims to explain fundamentals of data structures and their applications for programming. It will cover linear and non-linear data structures like stacks, queues, lists, trees and graphs. Students will learn sorting and searching algorithms and how to select suitable data structures for application development and problem solving.
This document provides an introduction to the CSE 326: Data Structures course. It discusses the following key points in 3 sentences or less:
The course will cover common data structures and algorithms, how to choose the appropriate data structure for different needs, and how to justify design decisions through formal reasoning. It aims to help students become better developers by understanding fundamental data structures and when to apply them. The document provides examples of stacks and queues to illustrate abstract data types, data structures, and their implementations in different programming languages.
This document provides an introduction to the CSE 326: Data Structures course. It discusses the following key points in 3 sentences or less:
The course will cover common data structures and algorithms, how to choose the appropriate data structure for different needs, and how to justify design decisions through formal reasoning. It aims to help students become better developers by understanding fundamental data structures and when to apply them. The document provides examples of stacks and queues to illustrate abstract data types, data structures, and their implementations in different programming languages.
This document provides an overview of a Data Structures course. The course will cover basic data structures and algorithms used in software development. Students will learn about common data structures like lists, stacks, and queues; analyze the runtime of algorithms; and practice implementing data structures. The goal is for students to understand which data structures are appropriate for different problems and be able to justify design decisions. Key concepts covered include abstract data types, asymptotic analysis to evaluate algorithms, and the tradeoffs involved in choosing different data structure implementations.
This document provides an introduction to data structures and algorithms. It defines key terms like data structure, abstract data type, and algorithm. It also covers different types of data structures like arrays, linked lists, stacks, and queues. Specifically, it discusses the List abstract data type and implementations of lists using arrays and linked lists. It provides examples of common list operations like insertion, deletion, searching, and printing when using arrays and linked lists to represent a list. The running time of these operations is discussed as well.
02._Object-Oriented_Programming_Concepts.pptYonas D. Ebren
This document discusses object-oriented programming concepts and provides an example of analyzing a software development process using object-oriented principles. It describes a typical 5-step software development process of analysis, design, implementation, testing, and maintenance. It then introduces object-oriented programming concepts like modeling a problem as a set of collaborating objects and components. As an example, it analyzes the classic game Tetris in terms of its objects like pieces and boards, their properties and capabilities.
This document discusses different data structures and their implementation. It describes linear data structures like arrays, linked lists, stacks and queues that store elements sequentially and non-linear structures like trees and graphs that store elements non-sequentially. It also discusses abstract data types, static and dynamic implementation of data structures, and built-in versus user defined data structures. Real life applications of different data structures are provided.
The document discusses arrays and linked lists as abstract data types (ADTs). It describes arrays as the simplest data structure, storing elements in sequential memory locations. Linked lists store elements using pointers, with each node containing data and a pointer to the next node. The document outlines common operations on arrays and linked lists like traversal, insertion, deletion, and searching. It also discusses different types of linked lists like singly linked, doubly linked, and circular linked lists.
The document discusses data structures and algorithms. It defines data structures and different types including primitive and non-primitive structures. It describes operations on data structures like traversing, searching, insertion and deletion. It also defines concepts like abstract data types, asymptotic analysis, and different algorithm analysis methods. Examples provided include linear search algorithm and binary search algorithm in pseudocode and C code.
This document provides an introduction to the concept of data structures. It discusses the need for data structures due to increasing data and processing requirements. It defines key terms like abstract data type, algorithm complexity, and different types of data structures. It explains linear data structures like arrays, linked lists, stacks and queues. Non-linear structures like trees and graphs are also introduced. Common operations on data structures like traversing, insertion, deletion, searching and sorting are outlined. The document aims to provide foundational knowledge on data structures and algorithms.
- Exploratory data analysis (EDA) is used to summarize and visualize data to understand its key characteristics, variables, and relationships.
- In R, EDA involves descriptive statistics like mean, median, and mode as well as graphical methods like histograms, density plots, and box plots.
- Functions like head(), tail(), summary(), and str() provide information about the structure, dimensions, and descriptive statistics of data frames in R. Additional functions like pairs plots and faceted histograms allow visualizing relationships between variables.
The document discusses different data structures like arrays, linked lists, stacks, and queues, explaining what they are, common operations on them like searching and sorting, as well as examples of algorithms for implementing common operations like insertion and deletion on each data structure. Key data structures are explained along with their properties and typical applications.
This document provides an introduction to data structures and linear data structures. It discusses what data and data structures are, why we need data structures, and common operations on data structures like traversal, search, insertion, and deletion. It then covers specific linear data structures like arrays, linked lists, stacks, and queues. For each, it provides class definitions and examples of implementation and common operations like insertion, deletion, traversal, etc. It also discusses some applications of different data structures.
The document discusses different data structures like arrays, stacks, queues, linked lists, trees, graphs. It provides definitions of each data structure and describes their common operations like traversing, searching, insertion, deletion. It also includes algorithms for operations on linear arrays, stacks, queues and priority queues. Implementation of different data structures and their applications are explained with examples.
This document provides an introduction to data structures. It discusses primitive and non-primitive data structures and their classifications. Linear data structures like arrays, stacks, queues and linked lists are covered, along with non-linear structures like trees and graphs. Common operations on data structures like traversing, searching, inserting and deleting are also summarized. Finally, the document introduces abstract data types and provides examples of common ADT specifications for lists, stacks and queues.
This document provides an overview of advanced data structures and algorithms. It defines data structures as a way to store and organize data for efficient access and modification. The document then reviews basic concepts like variables, data types, and algorithms. It describes common data structures like arrays, linked lists, stacks, queues, trees, and hash tables. It also covers topics like asymptotic analysis, algorithms analysis, and the substitution method for solving algorithm recurrences. The document is an introduction to advanced data structure and algorithm concepts.
This document provides an overview of data structures and algorithms. It discusses pseudo code, abstract data types, atomic and composite data, data structures, algorithm efficiency using Big O notation, and various searching algorithms like sequential, binary, and hashed list searches. Key concepts covered include pseudo code structure and syntax, defining algorithms with headers and conditions, and analyzing different search algorithms.
The document discusses various Python libraries used for data science tasks. It describes NumPy for numerical computing, SciPy for algorithms, Pandas for data structures and analysis, Scikit-Learn for machine learning, Matplotlib for visualization, and Seaborn which builds on Matplotlib. It also provides examples of loading data frames in Pandas, exploring and manipulating data, grouping and aggregating data, filtering, sorting, and handling missing values.
1.1 introduction to Data Structures.pptAshok280385
Here are the algorithms for the given problems:
1. WAA to find largest of three numbers:
1. Start
2. Read three numbers a, b, c
3. If a > b and a > c then largest number is a
4. Else If b > a and b > c then largest number is b
5. Else largest number is c
6. Print largest number
7. Stop
2. WAA to find the sum of first 10 natural numbers using for loop:
1. Start
2. Declare variables i, sum
3. Initialize i=1, sum=0
4. For i=1 to 10
5. sum =
PEST OF WHEAT SORGHUM BAJRA and MINOR MILLETS.pptxArshad Shaikh
Wheat, sorghum, and bajra (pearl millet) are susceptible to various pests that can significantly impact crop yields. Common pests include aphids, stem borers, shoot flies, and armyworms. Aphids feed on plant sap, weakening the plants, while stem borers and shoot flies damage the stems and shoots, leading to dead hearts and reduced growth. Armyworms, on the other hand, are voracious feeders that can cause extensive defoliation and grain damage. Effective management strategies, including resistant varieties, cultural practices, and targeted pesticide applications, are essential to mitigate pest damage and ensure healthy crop production.
"Geography Study Material for Class 10th" provides a comprehensive and easy-to-understand resource for key topics like Resources & Development, Water Resources, Agriculture, Minerals & Energy, Manufacturing Industries, and Lifelines of the National Economy. Designed as per the latest NCERT/JKBOSE syllabus, it includes notes, maps, diagrams, and MODEL question Paper to help students excel in exams. Whether revising for exams or strengthening conceptual clarity, this material ensures effective learning and high scores. Perfect for last-minute revisions and structured study sessions.
More Related Content
Similar to data structures queue stack insert and delete time complexity (20)
This document provides an introduction to data structures and algorithms. It defines key terms like data structure, abstract data type, and algorithm. It also covers different types of data structures like arrays, linked lists, stacks, and queues. Specifically, it discusses the List abstract data type and implementations of lists using arrays and linked lists. It provides examples of common list operations like insertion, deletion, searching, and printing when using arrays and linked lists to represent a list. The running time of these operations is discussed as well.
02._Object-Oriented_Programming_Concepts.pptYonas D. Ebren
This document discusses object-oriented programming concepts and provides an example of analyzing a software development process using object-oriented principles. It describes a typical 5-step software development process of analysis, design, implementation, testing, and maintenance. It then introduces object-oriented programming concepts like modeling a problem as a set of collaborating objects and components. As an example, it analyzes the classic game Tetris in terms of its objects like pieces and boards, their properties and capabilities.
This document discusses different data structures and their implementation. It describes linear data structures like arrays, linked lists, stacks and queues that store elements sequentially and non-linear structures like trees and graphs that store elements non-sequentially. It also discusses abstract data types, static and dynamic implementation of data structures, and built-in versus user defined data structures. Real life applications of different data structures are provided.
The document discusses arrays and linked lists as abstract data types (ADTs). It describes arrays as the simplest data structure, storing elements in sequential memory locations. Linked lists store elements using pointers, with each node containing data and a pointer to the next node. The document outlines common operations on arrays and linked lists like traversal, insertion, deletion, and searching. It also discusses different types of linked lists like singly linked, doubly linked, and circular linked lists.
The document discusses data structures and algorithms. It defines data structures and different types including primitive and non-primitive structures. It describes operations on data structures like traversing, searching, insertion and deletion. It also defines concepts like abstract data types, asymptotic analysis, and different algorithm analysis methods. Examples provided include linear search algorithm and binary search algorithm in pseudocode and C code.
This document provides an introduction to the concept of data structures. It discusses the need for data structures due to increasing data and processing requirements. It defines key terms like abstract data type, algorithm complexity, and different types of data structures. It explains linear data structures like arrays, linked lists, stacks and queues. Non-linear structures like trees and graphs are also introduced. Common operations on data structures like traversing, insertion, deletion, searching and sorting are outlined. The document aims to provide foundational knowledge on data structures and algorithms.
- Exploratory data analysis (EDA) is used to summarize and visualize data to understand its key characteristics, variables, and relationships.
- In R, EDA involves descriptive statistics like mean, median, and mode as well as graphical methods like histograms, density plots, and box plots.
- Functions like head(), tail(), summary(), and str() provide information about the structure, dimensions, and descriptive statistics of data frames in R. Additional functions like pairs plots and faceted histograms allow visualizing relationships between variables.
The document discusses different data structures like arrays, linked lists, stacks, and queues, explaining what they are, common operations on them like searching and sorting, as well as examples of algorithms for implementing common operations like insertion and deletion on each data structure. Key data structures are explained along with their properties and typical applications.
This document provides an introduction to data structures and linear data structures. It discusses what data and data structures are, why we need data structures, and common operations on data structures like traversal, search, insertion, and deletion. It then covers specific linear data structures like arrays, linked lists, stacks, and queues. For each, it provides class definitions and examples of implementation and common operations like insertion, deletion, traversal, etc. It also discusses some applications of different data structures.
The document discusses different data structures like arrays, stacks, queues, linked lists, trees, graphs. It provides definitions of each data structure and describes their common operations like traversing, searching, insertion, deletion. It also includes algorithms for operations on linear arrays, stacks, queues and priority queues. Implementation of different data structures and their applications are explained with examples.
This document provides an introduction to data structures. It discusses primitive and non-primitive data structures and their classifications. Linear data structures like arrays, stacks, queues and linked lists are covered, along with non-linear structures like trees and graphs. Common operations on data structures like traversing, searching, inserting and deleting are also summarized. Finally, the document introduces abstract data types and provides examples of common ADT specifications for lists, stacks and queues.
This document provides an overview of advanced data structures and algorithms. It defines data structures as a way to store and organize data for efficient access and modification. The document then reviews basic concepts like variables, data types, and algorithms. It describes common data structures like arrays, linked lists, stacks, queues, trees, and hash tables. It also covers topics like asymptotic analysis, algorithms analysis, and the substitution method for solving algorithm recurrences. The document is an introduction to advanced data structure and algorithm concepts.
This document provides an overview of data structures and algorithms. It discusses pseudo code, abstract data types, atomic and composite data, data structures, algorithm efficiency using Big O notation, and various searching algorithms like sequential, binary, and hashed list searches. Key concepts covered include pseudo code structure and syntax, defining algorithms with headers and conditions, and analyzing different search algorithms.
The document discusses various Python libraries used for data science tasks. It describes NumPy for numerical computing, SciPy for algorithms, Pandas for data structures and analysis, Scikit-Learn for machine learning, Matplotlib for visualization, and Seaborn which builds on Matplotlib. It also provides examples of loading data frames in Pandas, exploring and manipulating data, grouping and aggregating data, filtering, sorting, and handling missing values.
1.1 introduction to Data Structures.pptAshok280385
Here are the algorithms for the given problems:
1. WAA to find largest of three numbers:
1. Start
2. Read three numbers a, b, c
3. If a > b and a > c then largest number is a
4. Else If b > a and b > c then largest number is b
5. Else largest number is c
6. Print largest number
7. Stop
2. WAA to find the sum of first 10 natural numbers using for loop:
1. Start
2. Declare variables i, sum
3. Initialize i=1, sum=0
4. For i=1 to 10
5. sum =
PEST OF WHEAT SORGHUM BAJRA and MINOR MILLETS.pptxArshad Shaikh
Wheat, sorghum, and bajra (pearl millet) are susceptible to various pests that can significantly impact crop yields. Common pests include aphids, stem borers, shoot flies, and armyworms. Aphids feed on plant sap, weakening the plants, while stem borers and shoot flies damage the stems and shoots, leading to dead hearts and reduced growth. Armyworms, on the other hand, are voracious feeders that can cause extensive defoliation and grain damage. Effective management strategies, including resistant varieties, cultural practices, and targeted pesticide applications, are essential to mitigate pest damage and ensure healthy crop production.
"Geography Study Material for Class 10th" provides a comprehensive and easy-to-understand resource for key topics like Resources & Development, Water Resources, Agriculture, Minerals & Energy, Manufacturing Industries, and Lifelines of the National Economy. Designed as per the latest NCERT/JKBOSE syllabus, it includes notes, maps, diagrams, and MODEL question Paper to help students excel in exams. Whether revising for exams or strengthening conceptual clarity, this material ensures effective learning and high scores. Perfect for last-minute revisions and structured study sessions.
How to Manage & Create a New Department in Odoo 18 EmployeeCeline George
In Odoo 18's Employee module, organizing your workforce into departments enhances management and reporting efficiency. Departments are a crucial organizational unit within the Employee module.
Completed Tuesday June 10th.
An Orientation Sampler of 8 pages.
It helps to understand the text behind anything. This improves our performance and confidence.
Your training will be mixed media. Includes Rehab Intro and Meditation vods, all sold separately.
Editing our Vods & New Shop.
Retail under $30 per item. Store Fees will apply. Digital Should be low cost.
I am still editing the package. I wont be done until probably July? However; Orientation and Lecture 1 (Videos) will be available soon. Media will vary between PDF and Instruction Videos.
Thank you for attending our free workshops. Those can be used with any Reiki Yoga training package. Traditional Reiki does host rules and ethics. Its silent and within the JP Culture/Area/Training/Word of Mouth. It allows remote healing but there’s limits for practitioners and masters. We are not allowed to share certain secrets/tools. Some content is designed only for “Masters”. Some yoga are similar like the Kriya Yoga-Church (Vowed Lessons). We will review both Reiki and Yoga (Master symbols) later on. Sounds Simple but these things host Energy Power/Protection.
Imagine This package will be a supplement or upgrade for professional Reiki. You can create any style you need.
♥♥♥
•* ́ ̈ ̧.•
(Job) Tech for students: In short, high speed is essential. (Space, External Drives, virtual clouds)
Fast devices and desktops are important. Please upgrade your technology and office as needed and timely. - MIA J. Tech Dept (Timeless)
♥♥♥
•* ́ ̈ ̧.•
Copyright Disclaimer 2007-2025+: These lessons are not to be copied or revised without the
Author’s permission. These Lessons are designed Rev. Moore to instruct and guide students on the path to holistic health and wellness.
It’s about expanding your Nature Talents, gifts, even Favorite Hobbies.
♥♥♥
•* ́ ̈ ̧.•
First, Society is still stuck in the matrix. Many of the spiritual collective, say the matrix crashed. Its now collapsing. This means anything lower, darker realms, astral, and matrix are below 5D. 5D is thee trend. It’s our New Dimensional plane. However; this plane takes work ethic,
integration, and self discovery. ♥♥♥
•* ́ ̈ ̧.•
We don’t need to slave, mule, or work double shifts to fuse Reiki lol. It should blend naturally within our lifestyles. Same with Yoga. There’s no
need to use all the poses/asanas. For under a decade, my fav exercises are not asanas but Pilates. It’s all about Yoga-meditation when using Reiki. (Breaking old myths.)
Thank You for reading our Orientation Sampler. The Workshop is 14 pages on introduction. These are a joy and effortless to produce/make.
Unit- 4 Biostatistics & Research Methodology.pdfKRUTIKA CHANNE
Blocking and confounding (when a third variable, or confounder, influences both the exposure and the outcome) system for Two-level factorials (a type of experimental design where each factor (independent variable) is investigated at only two levels, typically denoted as "high" and "low" or "+1" and "-1")
Regression modeling (statistical model that estimates the relationship between one dependent variable and one or more independent variables using a line): Hypothesis testing in Simple and Multiple regression models
Introduction to Practical components of Industrial and Clinical Trials Problems: Statistical Analysis Using Excel, SPSS, MINITAB®️, DESIGN OF EXPERIMENTS, R - Online Statistical Software to Industrial and Clinical trial approach
Overview of Employee in Odoo 18 - Odoo SlidesCeline George
The employee module is a core component of the HR workspace that helps the business to get the employee activities and details. This would also allow you to get the employee details by acting as a centralized system and accessing, updating, and managing all the other employee data.
Exploring Ocean Floor Features for Middle SchoolMarie
This 16 slide science reader is all about ocean floor features. It was made to use with middle school students.
You can download the PDF at thehomeschooldaily.com
Thanks! Marie
THERAPEUTIC COMMUNICATION included definition, characteristics, nurse patient...parmarjuli1412
The document provides an overview of therapeutic communication, emphasizing its importance in nursing to address patient needs and establish effective relationships. THERAPEUTIC COMMUNICATION included some topics like introduction of COMMUNICATION, definition, types, process of communication, definition therapeutic communication, goal, techniques of therapeutic communication, non-therapeutic communication, few ways to improved therapeutic communication, characteristics of therapeutic communication, barrier of THERAPEUTIC RELATIONSHIP, introduction of interpersonal relationship, types of IPR, elements/ dynamics of IPR, introduction of therapeutic nurse patient relationship, definition, purpose, elements/characteristics , and phases of therapeutic communication, definition of Johari window, uses, what actually model represent and its areas, THERAPEUTIC IMPASSES and its management in 5th semester Bsc. nursing and 2nd GNM students
Battle of Bookworms is a literature quiz organized by Pragya, UEM Kolkata, as part of their cultural fest Ecstasia. Curated by quizmasters Drisana Bhattacharyya, Argha Saha, and Aniket Adhikari, the quiz was a dynamic mix of classical literature, modern writing, mythology, regional texts, and experimental literary forms. It began with a 20-question prelim round where ‘star questions’ played a key tie-breaking role. The top 8 teams moved into advanced rounds, where they faced audio-visual challenges, pounce/bounce formats, immunity tokens, and theme-based risk-reward questions. From Orwell and Hemingway to Tagore and Sarala Das, the quiz traversed a global and Indian literary landscape. Unique rounds explored slipstream fiction, constrained writing, adaptations, and true crime literature. It included signature IDs, character identifications, and open-pounce selections. Questions were crafted to test contextual understanding, narrative knowledge, and authorial intent, making the quiz both intellectually rewarding and culturally rich. Battle of Bookworms proved literature quizzes can be insightful, creative, and deeply enjoyable for all.
Ray Dalio How Countries go Broke the Big CycleDadang Solihin
A complete and practical understanding of the Big Debt Cycle. A much more practical understanding of how supply and demand really work compared to the conventional economic thinking. A complete and practical understanding of the Overall Big Cycle, which is driven by the Big Debt Cycle and the other major cycles, including the big political cycle within countries that changes political orders and the big geopolitical cycle that changes world orders.
This presentation has been made keeping in mind the students of undergraduate and postgraduate level. To keep the facts in a natural form and to display the material in more detail, the help of various books, websites and online medium has been taken. Whatever medium the material or facts have been taken from, an attempt has been made by the presenter to give their reference at the end.
In the seventh century, the rule of Sindh state was in the hands of Rai dynasty. We know the names of five kings of this dynasty- Rai Divji, Rai Singhras, Rai Sahasi, Rai Sihras II and Rai Sahasi II. During the time of Rai Sihras II, Nimruz of Persia attacked Sindh and killed him. After the return of the Persians, Rai Sahasi II became the king. After killing him, one of his Brahmin ministers named Chach took over the throne. He married the widow of Rai Sahasi and became the ruler of entire Sindh by suppressing the rebellions of the governors.
2. Agenda
• Introduction to Data Structures.
• ADT vs. DS.
• Python Built-in Data Structures (Lists, Tuples, Sets, Dict).
• Famous Data Structures:
Stack.
Queue.
Linked Lists && Doubly Linked Lists.
4. Dictionaries (I)
• Store pairs of entries called items
{ 'CS' : '743-713-3350', 'UHPD' : '713-743-3333'}
• Each pair of entries contains
• A key
• A value
• Key and values are separated by a colon
• Paris of entries are separated by commas
• Dictionary is enclosed within curly braces
5. Usage
• Keys must be unique within a dictionary
• No duplicates
• If we have
age = {'Alice' : 25, 'Bob' :28}
then
age['Alice'] is 25 #is used for checking the value
and
age['Bob'] is 28
6. Dictionaries are mutable
• >>> age = {'Alice' : 25, 'Bob' : 28}
• >>> saved = age
• >>> age['Bob'] = 29
• >>> age
{'Bob': 29, 'Alice': 25}
• >>> saved
{'Bob': 29, 'Alice': 25}
7. Keys must be unique
• >>> age = {'Alice' : 25, 'Bob' : 28, 'Alice' : 26}
• >>> age
{'Bob': 28, 'Alice': 26} # if two value for the same key the
last one is
the one that will be saved
9. Updating directories
• >>> age = {'Alice': 26 , 'Carol' : 22}
The update function either update existing value or create it if no
exist
• >>> age.update({'Bob' : 29})
• >>> age
{'Bob': 29, 'Carol': 22, 'Alice': 26}
• >>> age.update({'Carol' : 23})
• >>> age
{'Bob': 29, 'Carol': 23, 'Alice': 26}
10. Returning a value
• >>> age = {'Bob': 29, 'Carol': 23, 'Alice': 26}
• >>> age.get('Bob')
29
• >>> age['Bob']
29
11. Removing a specific item (I)
• >>> a = {'Alice' : 26, 'Carol' : 'twenty-two'}
• >>> a
{'Carol': 'twenty-two', 'Alice': 26}
• # pop function take the key remove the key and value from the dictionary and return the
value
• >>> a.pop('Carol’)
'twenty-two'
• >>> a
{'Alice': 26}
13. Remove the first item
# popitem() it will select the first item in the dictionary to return and remove it
• >>> age = {'Bob': 29, 'Carol': 23, 'Alice': 26}
• >>> age.popitem()
• ('Bob', 29)
• >>> age
• {'Carol': 23, 'Alice': 26}
• >>> age.popitem()
('Carol', 23)
• >>> age
{'Alice': 26}
14. 14
Data Types & Data Structures
• Applications/programs read data, store data temporarily,
process it and finally output results.
• What is data? Numbers, Characters, etc.
Application/
Program
Input
data
Output
data
16. 16
The Need for Data Structures
• Data structures organize data
more efficient programs.
• More powerful computers more complex applications.
• More complex applications demand more calculations.
• Complex computing tasks are unlike our everyday experience.
• Any organization for a collection of records can be searched,
processed in any order, or modified.
• The choice of data structure and algorithm can make the difference
between a program running in a few seconds or many days.
17. 17
Efficiency
A solution is said to be efficient if it solves the problem within its
resource constraints.
• Space
• Time
• The cost of a solution is the amount of resources that the
solution consumes… expressed in terms of big O notation
18. 18
Selecting a Data Structure
Select a data structure as follows:
1. Analyze the problem to determine the resource
constraints a solution must meet.
2. Determine the basic operations that must be supported.
Quantify the resource constraints for each operation.
3. Select the data structure that best meets these
requirements.
19. 19
Abstract Data Types
Abstract Data Type (ADT): a definition for a data type solely in
terms of a set of values and a set of operations on that data
type.
Each ADT operation is defined by its inputs and outputs.
Encapsulation: Hide implementation details.
20. 20
Data Structure
• A data structure is the physical implementation of an ADT.
• Each operation associated with the ADT is implemented by one or more subroutines in
the implementation.
• Data structure usually refers to an organization for data in main memory.
• File structure is an organization for data on peripheral storage, such as a disk
drive.
• Data structure is representation of the logical relationship existing between
individual elements of data.
• In other words, a data structure is a way of organizing all data items that
considers not only the elements stored but also their relationship to each other.
21. 21
Logical vs. Physical Form
Data items have both a logical and a physical form.
Logical form: definition of the data item within an ADT.
• Ex: Integers in mathematical sense: +, -
Physical form: implementation of the data item within a data
structure.
• Ex: 16/32 bit integers, overflow.
22. What is Program
• Data structure affects the design of both structural & functional aspects of a program.
Program=algorithm + Data Structure
• You know that a algorithm is a step by step procedure to solve a particular function.
• A Set of Instructions
• Data Structures + Algorithms
• Data Structure = A Container stores Data
• Algorithm = Logic + Control
• That means, algorithm is a set of instruction written to carry out certain tasks & the
data structure is the way of organizing the data with their logical relationship retained.
• To develop a program of an algorithm, we should select an appropriate data structure
for that algorithm.
• Therefore algorithm and its associated data structures from a program.
23. Functions of Data Structures
• The most commonly used operation on data
structure are broadly categorized into following
types:
• Create.
• Insert
• Delete
• update
Some DS need extra functions
• Selection.
• Searching.
• Sorting.
• Merging.
Insertion needs sometime
• Index.
• Key.
• Position.
• Priority.
24. Common Data Structures
• List
• Set
• Tuple
• Dictionary
• Stack
• Queue
• Linked List
• Tree
• Heap
• Hash Table
• Priority Queue
this lecture
through next lectures
https://www.youtube.com/watch?v=R-HLU9Fl5ug
Video tutorial: (in Python)
https://www.programiz.com/python-programming/list
Interactive tutorial: (in Python)
https://www.programiz.com/python-programming/set
https://www.programiz.com/python-programming/tuple
https://www.programiz.com/python-programming/dictionary
26. 26
The Stack ADT
• The Stack ADT stores arbitrary
objects
• Insertions and deletions follow
the last-in first-out scheme
• Think of a spring-loaded plate
dispenser
• Main stack operations:
• push(object): inserts an element
• object pop(): removes and returns
the last inserted element
• Auxiliary stack operations:
• object top(): returns the last
inserted element without
removing it
• integer len(): returns the
number of elements stored
• boolean is_empty(): indicates
whether no elements are stored
28. Applications of Stacks
• Direct applications
• Page-visited history in a Web browser
• Undo sequence in a text editor
• Chain of method calls in a language that supports recursion
• Indirect applications
• Auxiliary data structure for algorithms
• Component of other data structures
29. List-based Stack
• A simple way of implementing the Stack ADT uses a list
• We add elements from left to right
• A variable keeps track of the index of the top element
S
0 1 2 t
…
33. The Queue ADT
• The Queue ADT stores arbitrary
objects
• Insertions and deletions follow
the first-in first-out scheme
• Insertions are at the rear of the
queue and removals are at the
front of the queue
• Main queue operations:
• enqueue(object): inserts an
element at the end of the queue
• object dequeue(): removes and
returns the element at the
front of the queue
• Auxiliary queue
operations:
• object first(): returns the
element at the front
without removing it
• integer len(): returns the
number of elements stored
• boolean is_empty():
indicates whether no
elements are stored
35. Applications of Queues
• Direct applications
• Waiting lists, bureaucracy
• Access to shared resources (e.g., printer)
• Multiprogramming
• Indirect applications
• Auxiliary data structure for algorithms
• Component of other data structures
36. Queue in Python
• Use the following three instance variables:
• _data: is a reference to a list instance with a fixed capacity.
• _size: is an integer representing the current number of elements
stored in the queue (as opposed to the length of the data list).
• _front: is an integer that represents the index within data of the
first element of the queue (assuming the queue is not empty).
39. Linked List Data Structure
Visualize the Queue:
https://visualgo.net/en/list
40. Singly Linked List
A singly linked list is a
concrete data structure
consisting of a sequence of
nodes, starting from a head
pointer
Each node stores
element
link to the next node
next
elem node
A B C D
head
41. Inserting at the Head
1. Allocate a new node
2. Insert new element
3. Have new node point to old
head
4. Update head to point to new
node
42. Removing at the Head
1. Update head to point
to next node in the
list
2. Allow garbage
collector to reclaim
the former first node
43. Inserting at the Tail
1. Allocate a new node
2. Insert new element
3. Have new node
point to null
4. Have old last node
point to new node
5. Update tail to point
to new node
44. Removing at the Tail
Removing at the tail
of a singly linked list
is not efficient!
There is no
constant-time way
to update the tail to
point to the previous
node
45. Linked Lists
Stack as a Linked List
We can implement a stack with a singly linked list
The top element is stored at the first node of the list
The space used is O(n) and each operation of the Stack ADT
takes O(1) time
t
nodes
elements
47. Linked Lists
Queue as a Linked List
We can implement a queue with a singly linked list
The front element is stored at the first node
The rear element is stored at the last node
The space used is O(n) and each operation of the Queue ADT
takes O(1) time
f
r
nodes
elements
50. Doubly-Linked Lists
Doubly Linked List
• A doubly linked list provides a natural
implementation of the Node List ADT
• Nodes implement Position and store:
• element
• link to the previous node
• link to the next node
• Special trailer and header nodes
prev next
elem
trailer
header nodes/positions
elements
node
Visualize the Doubly linked List:
https://visualgo.net/en/list
51. Insertion
• Insert a new node, q, between p and its successor.
A B X C
A B C
p
A B C
p
X
q
p q
52. Deletion
• Remove a node, p, from a doubly-linked list.
A B C D
p
A B C
D
p
A B C
#16: A primary concern for this course is efficiency.
You might believe that faster computers make it unnecessary to be concerned with efficiency. However…
So we need special training.
#17: Alternate definition: Better than known alternatives (“relatively efficient”).
Space and time are typical constraints for programs.
This does not mean always strive for the most efficient program. If the program operates well within resource constraints, there is no benefit to making it faster or smaller.
#18: Typically want the “simplest” data structure that will meet the requirements.
#46: slot is nothing more than a memory management nicety: when you define __slots__ on a class, you’re telling the Python interpreter that the list of attributes described within are the only attributes this class will ever need, and a dynamic dictionary is not needed to manage the references to other objects within the class