Join us in Developer++: DSA Series which is an C++ workshop series organized to upskill Data Structures & Algorithms concepts and problem solving in C++ Language. This event is going to be hosted by Prof. Piyush Kumar Soni who is an assistant professor at NMIMS MPSTME Shirpur campus with an experience of 9 year. This session is going to cover core topics of DSA like Vector, LinkedList, Stack and Queue, along with their implementation using STL Library.
Assg 14 C++ Standard Template Library (STL)(Extra Credit .docxfestockton
Assg 14: C++ Standard Template Library (STL)
(Extra Credit Opportunity)
COSC 2336 Fall 2019
Dates:
Due: Sunday December 08, by Midnight
Objectives
ˆ Practice using an enterprise level set of data structures and algorithms
provided by the STL.
ˆ Connect what we learned about things like stacks, queues, lists, dictio-
naries, etc. to their implementations and applications from the C++
STL.
Description
This assignment is a bit di�erent than the previous assignments in the class,
and is being given as an extra credit opportunity. The assignment is open
ended. I have described 7 tasks or items you can perform, involving the
C++ standard template library. I will give up to 5 points for each of the 7
tasks (for a total of up to 35 points), that will be considered extra credit,
and applied to your programming assignment portion of the course grade to
make up some points on past programs in the class.
This assignment is open ended. I have not given you any starting code or
tests/assertions to use for the assignment. To get credit for the assignment,
you should submit a single �le named "assg14-stl.cpp". The �le should be
compilable and runnable using the C++ IDE/compiler environment you and
I have been using this semester for the class assignments. I would prefer that
you create a separate function for each of the tasks you chose to submit work
for, and that your main function simply calls each of the functions for the
1
task. Your functions should be documented and code formatted using the
usual class style guidelines. You can make up some work for the functions
to do, e.g. to pass them in a parameter and return a value, if you wish.
However, it is also su�cient to simply have void functions that take no
parameters. You should, though, add some output and test assertions of
your own to demonstrate your code working on the tasks using the STL
containers and algorithms. Also if you do more than 1 task demonstrating
a container, make sure you always use a di�erent type to be stored in the
container. For example, don't demonstrate all of your containers on <int>
values, use a variety like <double> <string> <char>, or even better, create
your own small structure or class and demonstrate a container of those user
de�ned types you created.
You should use our textbook for reference on using the STL containers
and algorithms. Another good online reference for the C++ STL is:
cplusplus.com: http://www.cplusplus.com/reference/stl/
You may work on any of the following tasks for this extra credit oppor-
tunity:
1. The STL divides up its containers into 4 categories. The simplest are
the sequence containers, which are intended to store data and access
it in a sequential manner. Vectors are like basic arrays in C, but they
are dynamic and have the ability to resize themselves automatically
when an element is inserted or deleted. Vectors really use C arrays
for their implementation. Insertion can be done in O(1) time to the
end, though if the vecto ...
This is an intermediate conversion course for C++, suitable for second year computing students who may have learned Java or another language in first year.
Assg 14 C++ Standard Template Library (STL)(Extra Credit .docxfestockton
Assg 14: C++ Standard Template Library (STL)
(Extra Credit Opportunity)
COSC 2336 Fall 2019
Dates:
Due: Sunday December 08, by Midnight
Objectives
ˆ Practice using an enterprise level set of data structures and algorithms
provided by the STL.
ˆ Connect what we learned about things like stacks, queues, lists, dictio-
naries, etc. to their implementations and applications from the C++
STL.
Description
This assignment is a bit di�erent than the previous assignments in the class,
and is being given as an extra credit opportunity. The assignment is open
ended. I have described 7 tasks or items you can perform, involving the
C++ standard template library. I will give up to 5 points for each of the 7
tasks (for a total of up to 35 points), that will be considered extra credit,
and applied to your programming assignment portion of the course grade to
make up some points on past programs in the class.
This assignment is open ended. I have not given you any starting code or
tests/assertions to use for the assignment. To get credit for the assignment,
you should submit a single �le named "assg14-stl.cpp". The �le should be
compilable and runnable using the C++ IDE/compiler environment you and
I have been using this semester for the class assignments. I would prefer that
you create a separate function for each of the tasks you chose to submit work
for, and that your main function simply calls each of the functions for the
1
task. Your functions should be documented and code formatted using the
usual class style guidelines. You can make up some work for the functions
to do, e.g. to pass them in a parameter and return a value, if you wish.
However, it is also su�cient to simply have void functions that take no
parameters. You should, though, add some output and test assertions of
your own to demonstrate your code working on the tasks using the STL
containers and algorithms. Also if you do more than 1 task demonstrating
a container, make sure you always use a di�erent type to be stored in the
container. For example, don't demonstrate all of your containers on <int>
values, use a variety like <double> <string> <char>, or even better, create
your own small structure or class and demonstrate a container of those user
de�ned types you created.
You should use our textbook for reference on using the STL containers
and algorithms. Another good online reference for the C++ STL is:
cplusplus.com: http://www.cplusplus.com/reference/stl/
You may work on any of the following tasks for this extra credit oppor-
tunity:
1. The STL divides up its containers into 4 categories. The simplest are
the sequence containers, which are intended to store data and access
it in a sequential manner. Vectors are like basic arrays in C, but they
are dynamic and have the ability to resize themselves automatically
when an element is inserted or deleted. Vectors really use C arrays
for their implementation. Insertion can be done in O(1) time to the
end, though if the vecto ...
This is an intermediate conversion course for C++, suitable for second year computing students who may have learned Java or another language in first year.
In C, a struct models what a thing has/is (i.e., the data, also called the characteristics), but not what it does (its behavior, represented by functions).
The functions are outside and separate from structs.
In C++, the characteristics and behavior are integrated into a single structure, called object.
The data type of an object is the class of the object
The packaging of the data and the functions into a class type is called data encapsulation.
Stack is a collection based on the principle of adding elements and retrieving them in the opposite order
What is STACK?
Stack Operations
Applications
Built-in Stack
Downloadable Resources
In computer science, a queue (/ˈkjuː/ kyew) is a particular kind of abstract data type or collection in which the entities in the collection are kept in order and the principal (or only) operations on the collection are the addition of entities to the rear terminal position, known as enqueue, and removal of entities from the front terminal position, known as dequeue. This makes the queue a First-In-First-Out (FIFO) data structure. In a FIFO data structure, the first element added to the queue will be the first one to be removed. This is equivalent to the requirement that once a new element is added, all elements that were added before have to be removed before the new element can be removed. Often a peek or front operation is also entered, returning the value of the front element without dequeuing it. A queue is an example of a linear data structure, or more abstractly a sequential collection.
This is an intermediate conversion course for C++, suitable for second year computing students who may have learned Java or another language in first year.
Enchancing adoption of Open Source Libraries. A case study on Albumentations.AIVladimir Iglovikov, Ph.D.
Presented by Vladimir Iglovikov:
- https://www.linkedin.com/in/iglovikov/
- https://x.com/viglovikov
- https://www.instagram.com/ternaus/
This presentation delves into the journey of Albumentations.ai, a highly successful open-source library for data augmentation.
Created out of a necessity for superior performance in Kaggle competitions, Albumentations has grown to become a widely used tool among data scientists and machine learning practitioners.
This case study covers various aspects, including:
People: The contributors and community that have supported Albumentations.
Metrics: The success indicators such as downloads, daily active users, GitHub stars, and financial contributions.
Challenges: The hurdles in monetizing open-source projects and measuring user engagement.
Development Practices: Best practices for creating, maintaining, and scaling open-source libraries, including code hygiene, CI/CD, and fast iteration.
Community Building: Strategies for making adoption easy, iterating quickly, and fostering a vibrant, engaged community.
Marketing: Both online and offline marketing tactics, focusing on real, impactful interactions and collaborations.
Mental Health: Maintaining balance and not feeling pressured by user demands.
Key insights include the importance of automation, making the adoption process seamless, and leveraging offline interactions for marketing. The presentation also emphasizes the need for continuous small improvements and building a friendly, inclusive community that contributes to the project's growth.
Vladimir Iglovikov brings his extensive experience as a Kaggle Grandmaster, ex-Staff ML Engineer at Lyft, sharing valuable lessons and practical advice for anyone looking to enhance the adoption of their open-source projects.
Explore more about Albumentations and join the community at:
GitHub: https://github.com/albumentations-team/albumentations
Website: https://albumentations.ai/
LinkedIn: https://www.linkedin.com/company/100504475
Twitter: https://x.com/albumentations
How to Get CNIC Information System with Paksim Ga.pptxdanishmna97
Pakdata Cf is a groundbreaking system designed to streamline and facilitate access to CNIC information. This innovative platform leverages advanced technology to provide users with efficient and secure access to their CNIC details.
In C, a struct models what a thing has/is (i.e., the data, also called the characteristics), but not what it does (its behavior, represented by functions).
The functions are outside and separate from structs.
In C++, the characteristics and behavior are integrated into a single structure, called object.
The data type of an object is the class of the object
The packaging of the data and the functions into a class type is called data encapsulation.
Stack is a collection based on the principle of adding elements and retrieving them in the opposite order
What is STACK?
Stack Operations
Applications
Built-in Stack
Downloadable Resources
In computer science, a queue (/ˈkjuː/ kyew) is a particular kind of abstract data type or collection in which the entities in the collection are kept in order and the principal (or only) operations on the collection are the addition of entities to the rear terminal position, known as enqueue, and removal of entities from the front terminal position, known as dequeue. This makes the queue a First-In-First-Out (FIFO) data structure. In a FIFO data structure, the first element added to the queue will be the first one to be removed. This is equivalent to the requirement that once a new element is added, all elements that were added before have to be removed before the new element can be removed. Often a peek or front operation is also entered, returning the value of the front element without dequeuing it. A queue is an example of a linear data structure, or more abstractly a sequential collection.
This is an intermediate conversion course for C++, suitable for second year computing students who may have learned Java or another language in first year.
Enchancing adoption of Open Source Libraries. A case study on Albumentations.AIVladimir Iglovikov, Ph.D.
Presented by Vladimir Iglovikov:
- https://www.linkedin.com/in/iglovikov/
- https://x.com/viglovikov
- https://www.instagram.com/ternaus/
This presentation delves into the journey of Albumentations.ai, a highly successful open-source library for data augmentation.
Created out of a necessity for superior performance in Kaggle competitions, Albumentations has grown to become a widely used tool among data scientists and machine learning practitioners.
This case study covers various aspects, including:
People: The contributors and community that have supported Albumentations.
Metrics: The success indicators such as downloads, daily active users, GitHub stars, and financial contributions.
Challenges: The hurdles in monetizing open-source projects and measuring user engagement.
Development Practices: Best practices for creating, maintaining, and scaling open-source libraries, including code hygiene, CI/CD, and fast iteration.
Community Building: Strategies for making adoption easy, iterating quickly, and fostering a vibrant, engaged community.
Marketing: Both online and offline marketing tactics, focusing on real, impactful interactions and collaborations.
Mental Health: Maintaining balance and not feeling pressured by user demands.
Key insights include the importance of automation, making the adoption process seamless, and leveraging offline interactions for marketing. The presentation also emphasizes the need for continuous small improvements and building a friendly, inclusive community that contributes to the project's growth.
Vladimir Iglovikov brings his extensive experience as a Kaggle Grandmaster, ex-Staff ML Engineer at Lyft, sharing valuable lessons and practical advice for anyone looking to enhance the adoption of their open-source projects.
Explore more about Albumentations and join the community at:
GitHub: https://github.com/albumentations-team/albumentations
Website: https://albumentations.ai/
LinkedIn: https://www.linkedin.com/company/100504475
Twitter: https://x.com/albumentations
How to Get CNIC Information System with Paksim Ga.pptxdanishmna97
Pakdata Cf is a groundbreaking system designed to streamline and facilitate access to CNIC information. This innovative platform leverages advanced technology to provide users with efficient and secure access to their CNIC details.
LF Energy Webinar: Electrical Grid Modelling and Simulation Through PowSyBl -...DanBrown980551
Do you want to learn how to model and simulate an electrical network from scratch in under an hour?
Then welcome to this PowSyBl workshop, hosted by Rte, the French Transmission System Operator (TSO)!
During the webinar, you will discover the PowSyBl ecosystem as well as handle and study an electrical network through an interactive Python notebook.
PowSyBl is an open source project hosted by LF Energy, which offers a comprehensive set of features for electrical grid modelling and simulation. Among other advanced features, PowSyBl provides:
- A fully editable and extendable library for grid component modelling;
- Visualization tools to display your network;
- Grid simulation tools, such as power flows, security analyses (with or without remedial actions) and sensitivity analyses;
The framework is mostly written in Java, with a Python binding so that Python developers can access PowSyBl functionalities as well.
What you will learn during the webinar:
- For beginners: discover PowSyBl's functionalities through a quick general presentation and the notebook, without needing any expert coding skills;
- For advanced developers: master the skills to efficiently apply PowSyBl functionalities to your real-world scenarios.
In his public lecture, Christian Timmerer provides insights into the fascinating history of video streaming, starting from its humble beginnings before YouTube to the groundbreaking technologies that now dominate platforms like Netflix and ORF ON. Timmerer also presents provocative contributions of his own that have significantly influenced the industry. He concludes by looking at future challenges and invites the audience to join in a discussion.
GraphSummit Singapore | The Future of Agility: Supercharging Digital Transfor...Neo4j
Leonard Jayamohan, Partner & Generative AI Lead, Deloitte
This keynote will reveal how Deloitte leverages Neo4j’s graph power for groundbreaking digital twin solutions, achieving a staggering 100x performance boost. Discover the essential role knowledge graphs play in successful generative AI implementations. Plus, get an exclusive look at an innovative Neo4j + Generative AI solution Deloitte is developing in-house.
Pushing the limits of ePRTC: 100ns holdover for 100 daysAdtran
At WSTS 2024, Alon Stern explored the topic of parametric holdover and explained how recent research findings can be implemented in real-world PNT networks to achieve 100 nanoseconds of accuracy for up to 100 days.
Removing Uninteresting Bytes in Software FuzzingAftab Hussain
Imagine a world where software fuzzing, the process of mutating bytes in test seeds to uncover hidden and erroneous program behaviors, becomes faster and more effective. A lot depends on the initial seeds, which can significantly dictate the trajectory of a fuzzing campaign, particularly in terms of how long it takes to uncover interesting behaviour in your code. We introduce DIAR, a technique designed to speedup fuzzing campaigns by pinpointing and eliminating those uninteresting bytes in the seeds. Picture this: instead of wasting valuable resources on meaningless mutations in large, bloated seeds, DIAR removes the unnecessary bytes, streamlining the entire process.
In this work, we equipped AFL, a popular fuzzer, with DIAR and examined two critical Linux libraries -- Libxml's xmllint, a tool for parsing xml documents, and Binutil's readelf, an essential debugging and security analysis command-line tool used to display detailed information about ELF (Executable and Linkable Format). Our preliminary results show that AFL+DIAR does not only discover new paths more quickly but also achieves higher coverage overall. This work thus showcases how starting with lean and optimized seeds can lead to faster, more comprehensive fuzzing campaigns -- and DIAR helps you find such seeds.
- These are slides of the talk given at IEEE International Conference on Software Testing Verification and Validation Workshop, ICSTW 2022.
Threats to mobile devices are more prevalent and increasing in scope and complexity. Users of mobile devices desire to take full advantage of the features
available on those devices, but many of the features provide convenience and capability but sacrifice security. This best practices guide outlines steps the users can take to better protect personal devices and information.
Securing your Kubernetes cluster_ a step-by-step guide to success !KatiaHIMEUR1
Today, after several years of existence, an extremely active community and an ultra-dynamic ecosystem, Kubernetes has established itself as the de facto standard in container orchestration. Thanks to a wide range of managed services, it has never been so easy to set up a ready-to-use Kubernetes cluster.
However, this ease of use means that the subject of security in Kubernetes is often left for later, or even neglected. This exposes companies to significant risks.
In this talk, I'll show you step-by-step how to secure your Kubernetes cluster for greater peace of mind and reliability.
Maruthi Prithivirajan, Head of ASEAN & IN Solution Architecture, Neo4j
Get an inside look at the latest Neo4j innovations that enable relationship-driven intelligence at scale. Learn more about the newest cloud integrations and product enhancements that make Neo4j an essential choice for developers building apps with interconnected data and generative AI.
A tale of scale & speed: How the US Navy is enabling software delivery from l...sonjaschweigert1
Rapid and secure feature delivery is a goal across every application team and every branch of the DoD. The Navy’s DevSecOps platform, Party Barge, has achieved:
- Reduction in onboarding time from 5 weeks to 1 day
- Improved developer experience and productivity through actionable findings and reduction of false positives
- Maintenance of superior security standards and inherent policy enforcement with Authorization to Operate (ATO)
Development teams can ship efficiently and ensure applications are cyber ready for Navy Authorizing Officials (AOs). In this webinar, Sigma Defense and Anchore will give attendees a look behind the scenes and demo secure pipeline automation and security artifacts that speed up application ATO and time to production.
We will cover:
- How to remove silos in DevSecOps
- How to build efficient development pipeline roles and component templates
- How to deliver security artifacts that matter for ATO’s (SBOMs, vulnerability reports, and policy evidence)
- How to streamline operations with automated policy checks on container images
In the rapidly evolving landscape of technologies, XML continues to play a vital role in structuring, storing, and transporting data across diverse systems. The recent advancements in artificial intelligence (AI) present new methodologies for enhancing XML development workflows, introducing efficiency, automation, and intelligent capabilities. This presentation will outline the scope and perspective of utilizing AI in XML development. The potential benefits and the possible pitfalls will be highlighted, providing a balanced view of the subject.
We will explore the capabilities of AI in understanding XML markup languages and autonomously creating structured XML content. Additionally, we will examine the capacity of AI to enrich plain text with appropriate XML markup. Practical examples and methodological guidelines will be provided to elucidate how AI can be effectively prompted to interpret and generate accurate XML markup.
Further emphasis will be placed on the role of AI in developing XSLT, or schemas such as XSD and Schematron. We will address the techniques and strategies adopted to create prompts for generating code, explaining code, or refactoring the code, and the results achieved.
The discussion will extend to how AI can be used to transform XML content. In particular, the focus will be on the use of AI XPath extension functions in XSLT, Schematron, Schematron Quick Fixes, or for XML content refactoring.
The presentation aims to deliver a comprehensive overview of AI usage in XML development, providing attendees with the necessary knowledge to make informed decisions. Whether you’re at the early stages of adopting AI or considering integrating it in advanced XML development, this presentation will cover all levels of expertise.
By highlighting the potential advantages and challenges of integrating AI with XML development tools and languages, the presentation seeks to inspire thoughtful conversation around the future of XML development. We’ll not only delve into the technical aspects of AI-powered XML development but also discuss practical implications and possible future directions.
GridMate - End to end testing is a critical piece to ensure quality and avoid...ThomasParaiso2
End to end testing is a critical piece to ensure quality and avoid regressions. In this session, we share our journey building an E2E testing pipeline for GridMate components (LWC and Aura) using Cypress, JSForce, FakerJS…
Alt. GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using ...James Anderson
Effective Application Security in Software Delivery lifecycle using Deployment Firewall and DBOM
The modern software delivery process (or the CI/CD process) includes many tools, distributed teams, open-source code, and cloud platforms. Constant focus on speed to release software to market, along with the traditional slow and manual security checks has caused gaps in continuous security as an important piece in the software supply chain. Today organizations feel more susceptible to external and internal cyber threats due to the vast attack surface in their applications supply chain and the lack of end-to-end governance and risk management.
The software team must secure its software delivery process to avoid vulnerability and security breaches. This needs to be achieved with existing tool chains and without extensive rework of the delivery processes. This talk will present strategies and techniques for providing visibility into the true risk of the existing vulnerabilities, preventing the introduction of security issues in the software, resolving vulnerabilities in production environments quickly, and capturing the deployment bill of materials (DBOM).
Speakers:
Bob Boule
Robert Boule is a technology enthusiast with PASSION for technology and making things work along with a knack for helping others understand how things work. He comes with around 20 years of solution engineering experience in application security, software continuous delivery, and SaaS platforms. He is known for his dynamic presentations in CI/CD and application security integrated in software delivery lifecycle.
Gopinath Rebala
Gopinath Rebala is the CTO of OpsMx, where he has overall responsibility for the machine learning and data processing architectures for Secure Software Delivery. Gopi also has a strong connection with our customers, leading design and architecture for strategic implementations. Gopi is a frequent speaker and well-known leader in continuous delivery and integrating security into software delivery.
UiPath Test Automation using UiPath Test Suite series, part 6DianaGray10
Welcome to UiPath Test Automation using UiPath Test Suite series part 6. In this session, we will cover Test Automation with generative AI and Open AI.
UiPath Test Automation with generative AI and Open AI webinar offers an in-depth exploration of leveraging cutting-edge technologies for test automation within the UiPath platform. Attendees will delve into the integration of generative AI, a test automation solution, with Open AI advanced natural language processing capabilities.
Throughout the session, participants will discover how this synergy empowers testers to automate repetitive tasks, enhance testing accuracy, and expedite the software testing life cycle. Topics covered include the seamless integration process, practical use cases, and the benefits of harnessing AI-driven automation for UiPath testing initiatives. By attending this webinar, testers, and automation professionals can gain valuable insights into harnessing the power of AI to optimize their test automation workflows within the UiPath ecosystem, ultimately driving efficiency and quality in software development processes.
What will you get from this session?
1. Insights into integrating generative AI.
2. Understanding how this integration enhances test automation within the UiPath platform
3. Practical demonstrations
4. Exploration of real-world use cases illustrating the benefits of AI-driven test automation for UiPath
Topics covered:
What is generative AI
Test Automation with generative AI and Open AI.
UiPath integration with generative AI
Speaker:
Deepak Rai, Automation Practice Lead, Boundaryless Group and UiPath MVP
UiPath Test Automation using UiPath Test Suite series, part 6
DSA-Day-2-PS.pptx
1. MUKESH PATEL SCHOOL OF TECHNOLOGY MANAGEMENT & ENGINEERING, SHIRPUR
Day-2
19th February 2023
Data Structures- Using STL in C++
1
Instructor
Piyush Kumar Soni
Assistant Professor,
Information Technology Department
Workshop on
Data Structures &
Algorithms
2. MUKESH PATEL SCHOOL OF TECHNOLOGY MANAGEMENT & ENGINEERING, SHIRPUR
Contents
2
• Template Functions and Classes
• C++ Standard Template Library (STL)
• Iterators
• Algorithms
• Containers
• vectors
• list
• queue
• stack
• Functions
3. MUKESH PATEL SCHOOL OF TECHNOLOGY MANAGEMENT & ENGINEERING, SHIRPUR
Template Functions and Classes
3
• A template is a simple yet very powerful tool in C++. The idea is to pass data
type as a parameter so that we don’t need to write the same code for different
data types.
• Eg., we may need to sort() for different data types. Rather than writing and
maintaining multiple codes, we can write one sort() and pass data type as a
parameter.
• Keywords to support templates: ‘template’ and ‘typename’. The second
keyword can always be replaced by the keyword ‘class’.
• Templates are expanded at compile time.
• This is like macros. The difference is, that the compiler does type checking
before template expansion. The idea is simple, source code contains only
function/class, but compiled code may contain multiple copies of the same
function/class.
4. MUKESH PATEL SCHOOL OF TECHNOLOGY MANAGEMENT & ENGINEERING, SHIRPUR
Template Functions
4
• Function Templates: We write a generic function that can be used for
different data types.
5. MUKESH PATEL SCHOOL OF TECHNOLOGY MANAGEMENT & ENGINEERING, SHIRPUR
Template Classes
5
• Class Templates: Like function templates, class templates are useful when a
class defines something that is independent of the data type.
6. MUKESH PATEL SCHOOL OF TECHNOLOGY MANAGEMENT & ENGINEERING, SHIRPUR
Standard Template Library (STL)
6
• The Standard Template Library (STL) is a set of C++ template classes to
provide common programming data structures and functions.
• It is a generalized library and so, its components are parameterized.
• The key benefits of the STL is that it provides a way to write generic,
reusable code that can be applied to different data types.
• Key components of the STL include
• Iterators
• Algorithms
• Containers
• Functions
7. MUKESH PATEL SCHOOL OF TECHNOLOGY MANAGEMENT & ENGINEERING, SHIRPUR
Iterators
7
• As the name suggests, iterators are used for working on a sequence of
values.
• Iterators are used to point at the memory addresses of STL containers.
• They reduce the complexity and execution time of the program.
• Operations:-
• begin() :- This function is used to return the beginning position of the
container.
• end() :- This function is used to return the after end position of the
container.
8. MUKESH PATEL SCHOOL OF TECHNOLOGY MANAGEMENT & ENGINEERING, SHIRPUR
Iterators
8
• next() :- This function
returns the new iterator
that the iterator would
point after advancing
the positions mentioned
in its arguments.
• prev() :- This function
returns the new iterator
that the iterator would
point after decrementing
the positions mentioned
in its arguments.
9. MUKESH PATEL SCHOOL OF TECHNOLOGY MANAGEMENT & ENGINEERING, SHIRPUR
Iterators
9
• inserter() :- This function is used to insert the elements at any position in the
container. It accepts 2 arguments, the container and iterator to position where
the elements have to be inserted.
10. MUKESH PATEL SCHOOL OF TECHNOLOGY MANAGEMENT & ENGINEERING, SHIRPUR
Algorithms
10
• The header algorithm defines a collection of functions specially designed to
be used on a range of elements.
• They act on containers and provide means for various operations for the
contents of the containers.
• Examples:
• Sort
• Reverse
• Max
11. MUKESH PATEL SCHOOL OF TECHNOLOGY MANAGEMENT & ENGINEERING, SHIRPUR
Sort
11
• Sorting means arranging the data in a
particular fashion, which can be
increasing or decreasing.
• There is a built-in function in C++ STL
by the name of sort().
• This function internally uses IntroSort.
It is implemented using hybrid of
QuickSort, HeapSort and InsertionSort.
By default, it uses QuickSort but if
QuickSort is doing unfair partitioning
and taking more than N*logN time, it
switches to HeapSort and when the
array size becomes really small, it
switches to InsertionSort.
12. MUKESH PATEL SCHOOL OF TECHNOLOGY MANAGEMENT & ENGINEERING, SHIRPUR
Reverse and Max
12
• reverse(first_iterator, last_iterator) – To reverse a vector. ( if ascending ->
descending OR if descending -> ascending)
• *max_element (first_iterator, last_iterator) – To find the maximum element
of a vector.
13. MUKESH PATEL SCHOOL OF TECHNOLOGY MANAGEMENT & ENGINEERING, SHIRPUR
Containers
13
• A container is a holder object that stores a collection of other objects (its
elements). They are implemented as class templates, which allows great
flexibility in the types supported as elements.
• The container manages the storage space for its elements and provides
member functions to access them, either directly or through iterators
(reference objects with similar properties to pointers).
• Following is the list of containers available with STL:
• vector
• list
• deque
• arrays
• forward_list
• queue
• priority_queue
• stack
14. MUKESH PATEL SCHOOL OF TECHNOLOGY MANAGEMENT & ENGINEERING, SHIRPUR
Vector
14
• Vectors are the same as dynamic arrays with the ability to resize itself
automatically when an element is inserted or deleted, with their storage being
handled automatically by the container.
• Vector elements are placed in contiguous storage so that they can be accessed
and traversed using iterators.
• Funtions:
• begin() – Returns an iterator pointing to the first element in the vector
• end() – Returns an iterator pointing to the theoretical element that follows the last
element in the vector
• rbegin() – Returns a reverse iterator pointing to the last element in the vector (reverse
beginning). It moves from last to first element
• rend() – Returns a reverse iterator pointing to the theoretical element preceding the first
element in the vector (considered as reverse end)
15. MUKESH PATEL SCHOOL OF TECHNOLOGY MANAGEMENT & ENGINEERING, SHIRPUR
Vector
15
16. MUKESH PATEL SCHOOL OF TECHNOLOGY MANAGEMENT & ENGINEERING, SHIRPUR
Vector
16
• size() – Returns the
number of elements in the
vector.
• resize(n) – Resizes the
container so that it contains
‘n’ elements.
• empty() – Returns whether
the container is empty.
17. MUKESH PATEL SCHOOL OF TECHNOLOGY MANAGEMENT & ENGINEERING, SHIRPUR
Stack
17
• Stacks are a type of container adaptors with LIFO(Last In First Out) type of
working, where a new element is added at one end (top) and an element is
removed from that end only.
• The functions associated with stack are:
• empty() – Returns whether the stack is empty
• size() – Returns the size of the stack
• top() – Returns a reference to the top most element of the stack
• push(g) – Adds the element ‘g’ at the top of the stack
• pop() – Deletes the most recent entered element of the stack
18. MUKESH PATEL SCHOOL OF TECHNOLOGY MANAGEMENT & ENGINEERING, SHIRPUR
Stack
18
19. MUKESH PATEL SCHOOL OF TECHNOLOGY MANAGEMENT & ENGINEERING, SHIRPUR
Queue
19
• Queues are a type of container adaptors that operate in a first in first out
(FIFO) type of arrangement. Elements are inserted at the back (end) and are
deleted from the front.
20. MUKESH PATEL SCHOOL OF TECHNOLOGY MANAGEMENT & ENGINEERING, SHIRPUR
Problem-Statement-1
20
• Concatenation of Array:
• Given an integer array nums of length n, you want to create an array ans of
length 2n where ans[i] == nums[i] and ans[i + n] == nums[i] for 0 <= i < n
(0-indexed).
• Specifically, ans is the concatenation of two nums arrays.
• Return the array ans.
• Example:
Input: nums = [1,2,1]
Output: [1,2,1,1,2,1]
Explanation: The array ans is formed as follows:
- ans = [nums[0],nums[1],nums[2],nums[0],nums[1],nums[2]]
- ans = [1,2,1,1,2,1]
21. MUKESH PATEL SCHOOL OF TECHNOLOGY MANAGEMENT & ENGINEERING, SHIRPUR
Solution
21
22. MUKESH PATEL SCHOOL OF TECHNOLOGY MANAGEMENT & ENGINEERING, SHIRPUR
Problem-Statement-2
22
• Kids With the Greatest Number of Candies:
• There are `n` kids with candies. You are given an integer array `candies`,
where each `candies[i]` represents the number of candies the `ith` kid has,
and an integer `extraCandies`, denoting the number of extra candies that you
have.
• Return a boolean array result of length n, where result[i] is true if, after
giving the ith kid all the extraCandies , they will have the greatest number of
candies among all the kids, or false otherwise.
• Note that multiple kids can have the greatest number of candies.
23. MUKESH PATEL SCHOOL OF TECHNOLOGY MANAGEMENT & ENGINEERING, SHIRPUR
Solution
23
24. MUKESH PATEL SCHOOL OF TECHNOLOGY MANAGEMENT & ENGINEERING, SHIRPUR
Problem-Statement-3
24
• Reverse String:
• Solution:
25. MUKESH PATEL SCHOOL OF TECHNOLOGY MANAGEMENT & ENGINEERING, SHIRPUR
Problem-Statement-4
25
• Backspace String Compare:
• Given two strings s and t, return true if they are equal when both are typed
into empty text editors. '#' means a backspace character.
• Note that after backspacing an empty text, the text will continue empty.
• Example 1:
Input: s = "ab#c", t = "ad#c"
Output: true
Explanation: Both s and t become "ac".
• Example 2:
Input: s = "ab##", t = "c#d#"
Output: true
Explanation: Both s and t become "".
26. MUKESH PATEL SCHOOL OF TECHNOLOGY MANAGEMENT & ENGINEERING, SHIRPUR
Solution
26
27. MUKESH PATEL SCHOOL OF TECHNOLOGY MANAGEMENT & ENGINEERING, SHIRPUR
Problem-Statement-5
27
• Implement a stack using Queue:
• Solution:
28. MUKESH PATEL SCHOOL OF TECHNOLOGY MANAGEMENT & ENGINEERING, SHIRPUR
Solution
28
29. MUKESH PATEL SCHOOL OF TECHNOLOGY MANAGEMENT & ENGINEERING, SHIRPUR
Problem-Statement-6
29
• Number of Students Unable to Eat Lunch:
• The school cafeteria offers circular and square sandwiches at lunch break,
referred to by numbers `0` and `1` respectively. All students stand in a queue.
Each student either prefers square or circular sandwiches.
• The number of sandwiches in the cafeteria is equal to the number of students.
The sandwiches are placed in a stack. At each step:
• If the student at the front of the queue prefers the sandwich on the top of
the stack, they will take it and leave the queue.
• Otherwise, they will leave it and go to the queue's end.
• This continues until none of the queue students want to take the top
sandwich and are thus unable to eat.
30. MUKESH PATEL SCHOOL OF TECHNOLOGY MANAGEMENT & ENGINEERING, SHIRPUR
Solution
30
31. MUKESH PATEL SCHOOL OF TECHNOLOGY MANAGEMENT & ENGINEERING, SHIRPUR
Thank You…!!!
31