This document provides an overview of common algorithms and data structures. It begins by defining an algorithm and discussing algorithm analysis techniques like asymptotic analysis. It then covers basic data structures like arrays, linked lists, stacks, queues, and trees. It explains various sorting algorithms like selection sort, bubble sort, insertion sort, quicksort, and mergesort. It also discusses search techniques like binary search and binary search trees. Other topics covered include priority queues, hashing, graphs, graph traversal, minimum spanning trees, shortest paths, and string searching algorithms.
Basics in algorithms and data structure Eman magdy
The document discusses data structures and algorithms. It notes that good programmers focus on data structures and their relationships, while bad programmers focus on code. It then provides examples of different data structures like trees and binary search trees, and algorithms for searching, inserting, deleting, and traversing tree structures. Key aspects covered include the time complexity of different searching algorithms like sequential search and binary search, as well as how to implement operations like insertion and deletion on binary trees.
The document discusses various tree data structures and algorithms related to binary trees. It begins with an introduction to different types of binary trees such as strict binary trees, complete binary trees, and extended binary trees. It then covers tree traversal algorithms including preorder, inorder and postorder traversal. The document also discusses representations of binary trees using arrays and linked lists. Finally, it explains algorithms for operations on binary search trees such as searching, insertion, deletion and rebalancing through rotations in AVL trees.
These lecture notes were revised in 2019 by John Bullinaria of the University of Birmingham. They cover fundamental computer science topics like algorithms, data structures, searching, sorting, trees, graphs and more. The notes are divided into 12 chapters with sections on topics such as arrays, linked lists, recursion, binary search trees, hashing, and graph algorithms.
The document discusses various tree data structures and algorithms. It defines common tree terminology like nodes, roots, leaves. It describes different types of trees like binary trees, binary search trees, and their properties. It explains tree traversal algorithms like preorder, inorder and postorder. It also summarizes minimum spanning tree algorithms like Kruskal's and Prim's, and single source shortest path algorithms like Dijkstra's.
This document provides an overview of trees and graphs as data structures. It discusses binary trees, including their implementation and operations like searching. Binary search trees are described, with examples of insertion and searching. Graphs are then introduced, including undirected and directed graphs. Graph representations in Python are shown. Examples of an undirected weighted graph, minimal spanning tree, and shortest paths are provided. Finally, it notes some common graph algorithms.
This document summarizes an internship project on data structures and algorithms. It covers topics like asymptotic notation, time complexity, arrays, trees, linked lists, stacks, queues, graphs, searching, sorting, and recursion algorithms. Examples of various data structures and their operations are explained along with analyzing their time complexities. Qualities of good algorithms and different types of searching and sorting algorithms are also discussed.
Binary search trees have the following key properties:
1. Each node contains a value.
2. The left subtree of a node contains only values smaller than the node's value.
3. The right subtree of a node contains only values larger than the node's value.
Binary search trees allow for efficient insertion and search operations in O(log n) time due to their structure. Deletion may require rebalancing the tree to maintain the binary search tree properties.
Introduction to data structure by anil duttAnil Dutt
This document provides an introduction and overview of common data structures including linked lists, stacks, queues, trees, and graphs. It defines each structure and describes their basic operations and implementations. Linked lists allow insertions and deletions anywhere and come in singly and doubly linked varieties. Stacks and queues follow last-in, first-out and first-in, first-out rules respectively. Binary trees enable fast searching and sorting of data. Graphs represent relationships between nodes connected by edges.
This document provides an overview of algorithms and data structures. It covers sorting algorithms like insertion sort, bubble sort, merge sort, and quicksort. It discusses complexity analysis using Big O notation and compares the time complexities of different sorting and searching algorithms. Common linear and nonlinear data structures are explained like arrays, linked lists, stacks, queues, trees, and hash tables. Abstract data types like maps, sets, queues and stacks are also introduced. Dijkstra's algorithm for finding shortest paths in graphs is described.
A binary search tree (BST) is a tree data structure where each node has a maximum of two children, and the values of left descendant nodes are less than the current node, which is less than the values of right descendant nodes. This structure allows for fast lookup, insertion, and removal of nodes in O(log n) time on average. However, in a worst case scenario where the tree is unbalanced, these operations can take O(n) time. Common operations on a BST include creating an empty tree, searching for a node, inserting a new node, and deleting an existing node.
The document provides resources for learning data structures and algorithms. It lists popular books, training websites, and YouTube channels on the topic. It then covers various data structures like arrays, lists, stacks, queues, hash tables, trees, and graphs. It explains each data structure with examples and discusses common algorithms like sorting, searching, and graph algorithms. Key algorithms covered include topological sort, minimum spanning tree, and shortest path finding. The document is a comprehensive guide to data structures and algorithms.
The document discusses binary trees and binary search trees. It begins with an overview of binary tree operations and traversals, including in-order, pre-order and post-order traversal. It then covers binary search trees, including their properties and operations like searching, finding the minimum/maximum values, and successors/predecessors. The document provides examples and pseudocode for traversing and performing operations on binary trees and binary search trees, including inserting and deleting nodes.
This document discusses binary search trees (BSTs) and their use for dynamic sets and sorting. It covers BST operations like search, insert, find minimum/maximum, and delete. It explains that BST sorting runs in O(n log n) time like quicksort. Maintaining a height of O(log n) can lead to efficient implementations of priority queues and other dynamic set applications using BSTs.
The document discusses several sorting algorithms:
1. Shell sort improves on insertion sort by sorting elements farther apart before closer elements.
2. Bubble sort compares adjacent elements and swaps them if out of order, repeating until sorted.
3. Quicksort chooses a "pivot" element and partitions the array into subarrays of smaller and larger elements, recursively sorting them.
4. Selection sort finds the minimum element and swaps it into the sorted portion of the array.
1) The document describes writing an MPI program to calculate a quantity called coverage from data files in a distributed manner across a cluster.
2) MPI (Message Passing Interface) is a standard for writing programs that can run in parallel on multiple processors. The program should distribute the computation efficiently across the cluster nodes and yield the same results as a serial code.
3) The MPI program structure involves initialization, processes running concurrently on nodes, communication between processes, and finalization. Communicators define which processes can communicate.
presentation on b tress. heap trees.hashingBindiya syed
The document provides information on various algorithms and data structures including merge sort, B-trees, hashing, and heap trees. It discusses the concepts and steps of merge sort, including dividing the array, sorting each half recursively, and merging the halves. It also explains B-trees, including their structure with keys and children, and examples of constructing a B-tree through insertions. Hashing techniques like division and multiplication methods are described along with how to handle collisions through chaining.
This document discusses various data structures and algorithms. It covers common data structures like stacks, linked lists, arrays, hash tables, trees, and heaps. It also covers fundamental sorting algorithms like selection sort, insertion sort, bubble sort, merge sort, quicksort, and heapsort. Additionally, it discusses searching algorithms like linear search and binary search. The document provides brief descriptions of each concept and notes their time complexities.
•Common Problems Needs Computers
•The Search Problem
•Basic Search Algorithms
–Algorithms used for searching the contents of an array
•Linear or Sequential Search
•Binary Search
•Comparison Between Linear and Binary Search
•Algorithms for solving shortest path problems
–Sequential Search Algorithms
•Depth-First Search
•Breadth First Search
–Parallel or distributed Search Algorithms
•Parallel Depth-First Search
•Parallel Breadth First Search
AlgoXY is a free book about elementary
algorithms and data structures. This book doesn't only focus on an
imperative (or procedural) approach, but also includes purely functional
algorithms and data structures. It doesn't require readers to
master any programming languages, because all the algorithms are
described using mathematical functions and pseudocode.
Data Structures and Algorithm Analysis in C++, 3rd Edition by Dr. Clifford A....thienvo61
This document provides a summary of a textbook on data structures and algorithms. The textbook covers fundamental data structures like lists, stacks, queues, trees, graphs and advanced structures. It also covers searching and sorting algorithms. The textbook is intended as a teaching text to help readers understand the principles of selecting appropriate data structures and assessing their costs and benefits rather than just memorizing implementations.
This document discusses binary trees and binary search trees. It defines key tree terms like root, child, parent, leaf nodes. It explains tree traversal methods like preorder, inorder and postorder. It also covers basic BST operations like insertion, search and deletion of nodes. Code snippets are provided to implement these operations and traversal methods on a sample binary search tree. Examples of traversing a sample tree in different orders are given.
Bridging the divide: A conversation on tariffs today in the book industry - T...BookNet Canada
A collaboration-focused conversation on the recently imposed US and Canadian tariffs where speakers shared insights into the current legislative landscape, ongoing advocacy efforts, and recommended next steps. This event was presented in partnership with the Book Industry Study Group.
Link to accompanying resource: https://bnctechforum.ca/sessions/bridging-the-divide-a-conversation-on-tariffs-today-in-the-book-industry/
Presented by BookNet Canada and the Book Industry Study Group on May 29, 2025 with support from the Department of Canadian Heritage.
Binary search trees have the following key properties:
1. Each node contains a value.
2. The left subtree of a node contains only values smaller than the node's value.
3. The right subtree of a node contains only values larger than the node's value.
Binary search trees allow for efficient insertion and search operations in O(log n) time due to their structure. Deletion may require rebalancing the tree to maintain the binary search tree properties.
Introduction to data structure by anil duttAnil Dutt
This document provides an introduction and overview of common data structures including linked lists, stacks, queues, trees, and graphs. It defines each structure and describes their basic operations and implementations. Linked lists allow insertions and deletions anywhere and come in singly and doubly linked varieties. Stacks and queues follow last-in, first-out and first-in, first-out rules respectively. Binary trees enable fast searching and sorting of data. Graphs represent relationships between nodes connected by edges.
This document provides an overview of algorithms and data structures. It covers sorting algorithms like insertion sort, bubble sort, merge sort, and quicksort. It discusses complexity analysis using Big O notation and compares the time complexities of different sorting and searching algorithms. Common linear and nonlinear data structures are explained like arrays, linked lists, stacks, queues, trees, and hash tables. Abstract data types like maps, sets, queues and stacks are also introduced. Dijkstra's algorithm for finding shortest paths in graphs is described.
A binary search tree (BST) is a tree data structure where each node has a maximum of two children, and the values of left descendant nodes are less than the current node, which is less than the values of right descendant nodes. This structure allows for fast lookup, insertion, and removal of nodes in O(log n) time on average. However, in a worst case scenario where the tree is unbalanced, these operations can take O(n) time. Common operations on a BST include creating an empty tree, searching for a node, inserting a new node, and deleting an existing node.
The document provides resources for learning data structures and algorithms. It lists popular books, training websites, and YouTube channels on the topic. It then covers various data structures like arrays, lists, stacks, queues, hash tables, trees, and graphs. It explains each data structure with examples and discusses common algorithms like sorting, searching, and graph algorithms. Key algorithms covered include topological sort, minimum spanning tree, and shortest path finding. The document is a comprehensive guide to data structures and algorithms.
The document discusses binary trees and binary search trees. It begins with an overview of binary tree operations and traversals, including in-order, pre-order and post-order traversal. It then covers binary search trees, including their properties and operations like searching, finding the minimum/maximum values, and successors/predecessors. The document provides examples and pseudocode for traversing and performing operations on binary trees and binary search trees, including inserting and deleting nodes.
This document discusses binary search trees (BSTs) and their use for dynamic sets and sorting. It covers BST operations like search, insert, find minimum/maximum, and delete. It explains that BST sorting runs in O(n log n) time like quicksort. Maintaining a height of O(log n) can lead to efficient implementations of priority queues and other dynamic set applications using BSTs.
The document discusses several sorting algorithms:
1. Shell sort improves on insertion sort by sorting elements farther apart before closer elements.
2. Bubble sort compares adjacent elements and swaps them if out of order, repeating until sorted.
3. Quicksort chooses a "pivot" element and partitions the array into subarrays of smaller and larger elements, recursively sorting them.
4. Selection sort finds the minimum element and swaps it into the sorted portion of the array.
1) The document describes writing an MPI program to calculate a quantity called coverage from data files in a distributed manner across a cluster.
2) MPI (Message Passing Interface) is a standard for writing programs that can run in parallel on multiple processors. The program should distribute the computation efficiently across the cluster nodes and yield the same results as a serial code.
3) The MPI program structure involves initialization, processes running concurrently on nodes, communication between processes, and finalization. Communicators define which processes can communicate.
presentation on b tress. heap trees.hashingBindiya syed
The document provides information on various algorithms and data structures including merge sort, B-trees, hashing, and heap trees. It discusses the concepts and steps of merge sort, including dividing the array, sorting each half recursively, and merging the halves. It also explains B-trees, including their structure with keys and children, and examples of constructing a B-tree through insertions. Hashing techniques like division and multiplication methods are described along with how to handle collisions through chaining.
This document discusses various data structures and algorithms. It covers common data structures like stacks, linked lists, arrays, hash tables, trees, and heaps. It also covers fundamental sorting algorithms like selection sort, insertion sort, bubble sort, merge sort, quicksort, and heapsort. Additionally, it discusses searching algorithms like linear search and binary search. The document provides brief descriptions of each concept and notes their time complexities.
•Common Problems Needs Computers
•The Search Problem
•Basic Search Algorithms
–Algorithms used for searching the contents of an array
•Linear or Sequential Search
•Binary Search
•Comparison Between Linear and Binary Search
•Algorithms for solving shortest path problems
–Sequential Search Algorithms
•Depth-First Search
•Breadth First Search
–Parallel or distributed Search Algorithms
•Parallel Depth-First Search
•Parallel Breadth First Search
AlgoXY is a free book about elementary
algorithms and data structures. This book doesn't only focus on an
imperative (or procedural) approach, but also includes purely functional
algorithms and data structures. It doesn't require readers to
master any programming languages, because all the algorithms are
described using mathematical functions and pseudocode.
Data Structures and Algorithm Analysis in C++, 3rd Edition by Dr. Clifford A....thienvo61
This document provides a summary of a textbook on data structures and algorithms. The textbook covers fundamental data structures like lists, stacks, queues, trees, graphs and advanced structures. It also covers searching and sorting algorithms. The textbook is intended as a teaching text to help readers understand the principles of selecting appropriate data structures and assessing their costs and benefits rather than just memorizing implementations.
This document discusses binary trees and binary search trees. It defines key tree terms like root, child, parent, leaf nodes. It explains tree traversal methods like preorder, inorder and postorder. It also covers basic BST operations like insertion, search and deletion of nodes. Code snippets are provided to implement these operations and traversal methods on a sample binary search tree. Examples of traversing a sample tree in different orders are given.
Bridging the divide: A conversation on tariffs today in the book industry - T...BookNet Canada
A collaboration-focused conversation on the recently imposed US and Canadian tariffs where speakers shared insights into the current legislative landscape, ongoing advocacy efforts, and recommended next steps. This event was presented in partnership with the Book Industry Study Group.
Link to accompanying resource: https://bnctechforum.ca/sessions/bridging-the-divide-a-conversation-on-tariffs-today-in-the-book-industry/
Presented by BookNet Canada and the Book Industry Study Group on May 29, 2025 with support from the Department of Canadian Heritage.
AI Agents in Logistics and Supply Chain Applications Benefits and ImplementationChristine Shepherd
AI agents are reshaping logistics and supply chain operations by enabling automation, predictive insights, and real-time decision-making across key functions such as demand forecasting, inventory management, procurement, transportation, and warehouse operations. Powered by technologies like machine learning, NLP, computer vision, and robotic process automation, these agents deliver significant benefits including cost reduction, improved efficiency, greater visibility, and enhanced adaptability to market changes. While practical use cases show measurable gains in areas like dynamic routing and real-time inventory tracking, successful implementation requires careful integration with existing systems, quality data, and strategic scaling. Despite challenges such as data integration and change management, AI agents offer a strong competitive edge, with widespread industry adoption expected by 2025.
Boosting MySQL with Vector Search -THE VECTOR SEARCH CONFERENCE 2025 .pdfAlkin Tezuysal
As the demand for vector databases and Generative AI continues to rise, integrating vector storage and search capabilities into traditional databases has become increasingly important. This session introduces the *MyVector Plugin*, a project that brings native vector storage and similarity search to MySQL. Unlike PostgreSQL, which offers interfaces for adding new data types and index methods, MySQL lacks such extensibility. However, by utilizing MySQL's server component plugin and UDF, the *MyVector Plugin* successfully adds a fully functional vector search feature within the existing MySQL + InnoDB infrastructure, eliminating the need for a separate vector database. The session explains the technical aspects of integrating vector support into MySQL, the challenges posed by its architecture, and real-world use cases that showcase the advantages of combining vector search with MySQL's robust features. Attendees will leave with practical insights on how to add vector search capabilities to their MySQL systems.
Interested in leveling up your JavaScript skills? Join us for our Introduction to TypeScript workshop.
Learn how TypeScript can improve your code with dynamic typing, better tooling, and cleaner architecture. Whether you're a beginner or have some experience with JavaScript, this session will give you a solid foundation in TypeScript and how to integrate it into your projects.
Workshop content:
- What is TypeScript?
- What is the problem with JavaScript?
- Why TypeScript is the solution
- Coding demo
Creating an Accessible Future-How AI-powered Accessibility Testing is Shaping...Impelsys Inc.
Web accessibility is a fundamental principle that strives to make the internet inclusive for all. According to the World Health Organization, over a billion people worldwide live with some form of disability. These individuals face significant challenges when navigating the digital landscape, making the quest for accessible web content more critical than ever.
Enter Artificial Intelligence (AI), a technological marvel with the potential to reshape the way we approach web accessibility. AI offers innovative solutions that can automate processes, enhance user experiences, and ultimately revolutionize web accessibility. In this blog post, we’ll explore how AI is making waves in the world of web accessibility.
Integration of Utility Data into 3D BIM Models Using a 3D Solids Modeling Wor...Safe Software
Jacobs has developed a 3D utility solids modelling workflow to improve the integration of utility data into 3D Building Information Modeling (BIM) environments. This workflow, a collaborative effort between the New Zealand Geospatial Team and the Australian Data Capture Team, employs FME to convert 2D utility data into detailed 3D representations, supporting enhanced spatial analysis and clash detection.
To enable the automation of this process, Jacobs has also developed a survey data standard that standardizes the capture of existing utilities. This standard ensures consistency in data collection, forming the foundation for the subsequent automated validation and modelling steps. The workflow begins with the acquisition of utility survey data, including attributes such as location, depth, diameter, and material of utility assets like pipes and manholes. This data is validated through a custom-built tool that ensures completeness and logical consistency, including checks for proper connectivity between network components. Following validation, the data is processed using an automated modelling tool to generate 3D solids from 2D geometric representations. These solids are then integrated into BIM models to facilitate compatibility with 3D workflows and enable detailed spatial analyses.
The workflow contributes to improved spatial understanding by visualizing the relationships between utilities and other infrastructure elements. The automation of validation and modeling processes ensures consistent and accurate outputs, minimizing errors and increasing workflow efficiency.
This methodology highlights the application of FME in addressing challenges associated with geospatial data transformation and demonstrates its utility in enhancing data integration within BIM frameworks. By enabling accurate 3D representation of utility networks, the workflow supports improved design collaboration and decision-making in complex infrastructure projects
Developing Schemas with FME and Excel - Peak of Data & AI 2025Safe Software
When working with other team members who may not know the Esri GIS platform or may not be database professionals; discussing schema development or changes can be difficult. I have been using Excel to help illustrate and discuss schema design/changes during meetings and it has proven a useful tool to help illustrate how a schema will be built. With just a few extra columns, that Excel file can be sent to FME to create new feature classes/tables. This presentation will go thru the steps needed to accomplish this task and provide some lessons learned and tips/tricks that I use to speed the process.
TrustArc Webinar - 2025 Global Privacy SurveyTrustArc
How does your privacy program compare to your peers? What challenges are privacy teams tackling and prioritizing in 2025?
In the sixth annual Global Privacy Benchmarks Survey, we asked global privacy professionals and business executives to share their perspectives on privacy inside and outside their organizations. The annual report provides a 360-degree view of various industries' priorities, attitudes, and trends. See how organizational priorities and strategic approaches to data security and privacy are evolving around the globe.
This webinar features an expert panel discussion and data-driven insights to help you navigate the shifting privacy landscape. Whether you are a privacy officer, legal professional, compliance specialist, or security expert, this session will provide actionable takeaways to strengthen your privacy strategy.
This webinar will review:
- The emerging trends in data protection, compliance, and risk
- The top challenges for privacy leaders, practitioners, and organizations in 2025
- The impact of evolving regulations and the crossroads with new technology, like AI
Predictions for the future of privacy in 2025 and beyond
Presentation given at the LangChain community meetup London
https://lu.ma/9d5fntgj
Coveres
Agentic AI: Beyond the Buzz
Introduction to AI Agent and Agentic AI
Agent Use case and stats
Introduction to LangGraph
Build agent with LangGraph Studio V2
Down the Rabbit Hole – Solving 5 Training RoadblocksRustici Software
Feeling stuck in the Matrix of your training technologies? You’re not alone. Managing your training catalog, wrangling LMSs and delivering content across different tools and audiences can feel like dodging digital bullets. At some point, you hit a fork in the road: Keep patching things up as issues pop up… or follow the rabbit hole to the root of the problems.
Good news, we’ve already been down that rabbit hole. Peter Overton and Cameron Gray of Rustici Software are here to share what we found. In this webinar, we’ll break down 5 training roadblocks in delivery and management and show you how they’re easier to fix than you might think.
Domino IQ – What to Expect, First Steps and Use Casespanagenda
Webinar Recording: https://www.panagenda.com/webinars/domino-iq-what-to-expect-first-steps-and-use-cases/
HCL Domino iQ Server – From Ideas Portal to implemented Feature. Discover what it is, what it isn’t, and explore the opportunities and challenges it presents.
Key Takeaways
- What are Large Language Models (LLMs) and how do they relate to Domino iQ
- Essential prerequisites for deploying Domino iQ Server
- Step-by-step instructions on setting up your Domino iQ Server
- Share and discuss thoughts and ideas to maximize the potential of Domino iQ
For the full video of this presentation, please visit: https://www.edge-ai-vision.com/2025/06/state-space-models-vs-transformers-for-ultra-low-power-edge-ai-a-presentation-from-brainchip/
Tony Lewis, Chief Technology Officer at BrainChip, presents the “State-space Models vs. Transformers for Ultra-low-power Edge AI” tutorial at the May 2025 Embedded Vision Summit.
At the embedded edge, choices of language model architectures have profound implications on the ability to meet demanding performance, latency and energy efficiency requirements. In this presentation, Lewis contrasts state-space models (SSMs) with transformers for use in this constrained regime. While transformers rely on a read-write key-value cache, SSMs can be constructed as read-only architectures, enabling the use of novel memory types and reducing power consumption. Furthermore, SSMs require significantly fewer multiply-accumulate units—drastically reducing compute energy and chip area.
New techniques enable distillation-based migration from transformer models such as Llama to SSMs without major performance loss. In latency-sensitive applications, techniques such as precomputing input sequences allow SSMs to achieve sub-100 ms time-to-first-token, enabling real-time interactivity. Lewis presents a detailed side-by-side comparison of these architectures, outlining their trade-offs and opportunities at the extreme edge.
Artificial Intelligence in the Nonprofit Boardroom.pdfOnBoard
OnBoard recently partnered with Microsoft Tech for Social Impact on the AI in the Nonprofit Boardroom Survey, an initiative designed to uncover the current and future role of artificial intelligence in nonprofit governance.
2. Algorithm:
An algorithm is a set of instructions for solving a problem or
accomplishing a task.
To design a better a program, algorithm is required
3. Algorithm vs program
Algorithm
To design
It can be written in any
natural language
The person who is having the
particular domain knowledge
can write algorithm
Algorithm is independent of
hardware and software
Program
To Implement
It can be written in any
programming language
Programmers can write
programs
Program is dependent on
hardware and software
4. How to write an algorithm?
Problem- Design an algorithm to add two values
and display the result
Step 1- Start
Step 2- Declare three integers a,b,c
Step 3- Define values of a & b
Step 4- add values of a & b
Step 5- Store added values to c
Step 6- print c
Step 7- Stop
5. Different types of Algorithm
Searching
Binary search tree
AVL
Hashing
Sorting
Shortest path
Dynamic programming
6. Searching algorithms
Searching Algorithms are designed to check for an element or
retrieve an element from any data structure where it is stored.
These algorithms are generally classified into two categories:
Sequential Search: In this, the list or array is traversed sequentially
and every element is checked. For example: Linear Search.
Interval Search: These algorithms are specifically designed for
searching in sorted data-structures. These type of searching
algorithms are much more efficient than Linear Search as they
repeatedly target the center of the search structure and divide the
search space in half. For Example: Binary Search.
8. def search(arr, x):
for i in range(len(arr)):
if arr[i] == x:
return i
return -1
print(search([12,34,23,54,32,78,67],80))
9. Binary search
First sort the elements in ascending order
Initialize the first value with low. Initialize as 0
Initialize the last value with high. Initialize as n-1
Now we can calculate the middle values
Mid =low+high//2
13. def binary_search(arr, low, high, x):
if high >= low:
mid = (high + low) // 2
if arr[mid] == x:
return mid
elif arr[mid] > x:
return binary_search(arr, low, mid - 1, x)
else:
return binary_search(arr, mid + 1, high, x)
else:
return -1
arr = [ 2, 3, 4, 10, 40 ]
x = 10
result = binary_search(arr, 0, len(arr)-1, x)
if result != -1:
print("Element is present at index", result)
else:
print("Element is not present in array")
14. Jump search- Searching algorithm for sorted
arrays or list
Procedure:
1.Calculate the array size and jump size(j=sqrt(n)).
2.Jump from index i to index j
3.Check x==arr[j] , return x
or x<arr[j], back a step and perform linear operation
16. Interpolation Search
Conditions to be satisfied
1.Sorted array
2.Elements should be uniformly distributed
Example: 2 4 6 8 10 12
3.Formula to find the key element
Pos=l+(x-a[l])/(a[h]-a[l]) x(h-l)
17. Binary Search Tree(BST)
A binary Search Tree is a node-based binary tree data structure
which has the following properties:
The left subtree of a node contains only nodes with keys lesser
than the node’s key.
The right subtree of a node contains only nodes with keys
greater than the node’s key.
There must be no duplicate nodes.
19. Construction and insertion of elements in BST
If the tree is empty, then consider the element as a root
If the element is greater than the root, insert to right
subtree
If the element is lesser than the root, insert to left subtree
21. Python implementation
def insert(self, data):
if self.data:
if data < self.data:
if self.left is None:
self.left = Node(data)
else:
self.left.insert(data)
elif data > self.data:
if self.right is None:
self.right = Node(data)
else:
self.right.insert(data)
else:
self.data = data
def PrintTree(self):
if self.left:
self.left.PrintTree()
print( self.data),
if self.right:
self.right.PrintTree()
# Use the insert method to add nodes
root = Node(12)
root.insert(6)
root.insert(14)
root.insert(3)
root.PrintTree()
22. Deletion:
Delete a node having no children(leaf nodes)
Delete a node having 1 children
Child replace the position of parent
Delete a node having 2 children
Replace parent with child
Child can be minimum element of right subtree
Child can be maximum element of left subtree
24. AVL Tree
It should satisfy the properties of binary search tree
Self balancing binary search tree- Balancing heights of left sub tree and
right sub tree
Measured in terms of balancing factor
If BST obeys balancing factor, we call that as AVL tree
Balancing factor=Height of LST-Height of RST
Every node in a tree should contain the Balancing factor as either 0 or 1
or -1
Invented by Adelson,Velsky,Lindas
We can perform the operations like insertion and deletion in AVL tree
25. Rotations involved in AVL Tree
There are 4 types rotations involved to change the
unbalanced tree to balanced tree
1.LL rotation
2.RR rotation
3.LR rotation
4.RL rotation
31. Sorting Algorithms
A Sorting Algorithm is used to rearrange a given array or list
elements according to a comparison operator on the elements.
There are different types of sorting techniques
Bubble sort
Insertion sort
Selection sort
Merge sort
Heap sort
32. Bubble sort- Bubble sort is a simple sorting algorithm. This
sorting algorithm is comparison-based algorithm in which
each pair of adjacent elements is compared and the elements
are swapped if they are not in order.
33. Insertion Sort- compare each element with all the previous
element and inserting the correct element into the desired
location
34. Selection sort-Selection sort is a sorting algorithm that selects
the smallest element from an unsorted list in each iteration and
places that element at the beginning of the unsorted list.
35. Merge sort-Merge sort is one of the most efficient sorting algorithms. It is
based on the divide-and-conquer strategy. Merge sort continuously cuts
down a list into multiple sublists until each has only one item, then merges
those sublists into a sorted list
36. Heap sort
To implement heap sort, we need to follow two properties.
1.Constructing complete binary tree
2.Follow the heap order min heap & max heap
Min heap- Parent node shoud be lesser than the child nodes.
Max heap- Parent node should be greater than the child nodes.
Delete and replace the root node with tha last chid node.
Deleted node should be placed at the last position of the array.
38. Graphs
Graph is defined as a set of (V,E) pairs, where V is set of vertices,
E is set of edges
Vertices- represented by circles
Edges- represented as lines
A,B,C are vertices
(A,B),(B,C),(A,C)-Edges
A
B C
40. Graph traversals-Travelling to all the nodes
Two algorithms in graphs traversals
1.Depth First Search(DFS)- stack data structure
2.Breadth First Search(BFS)-Queue datastructure
A
B C
D E F G
41. Spanning tree- A spanning tree is a sub-graph of an
undirected connected graph, which includes all the vertices
of the graph with a minimum possible number of edges
Rules to be followed while constructing Spanning tree
1.Spanning tree should connect all vertices of a graph.
2.If graph is having n vertices, spanning tree should have n-1 edges.
3.Should not contain any cycles.
42. Kruskal’s Algorithm: To find the minimum cost
spanning tree
Procedure:
1. Arrange all the elements in ascending order based on the cost.
2. Consider least cost weighted edge and include it in a tree. If
the edge forms a cycle,just ignore and consider the next least
cost weighted edge.
3. Repeat step 2 until all the vertices are included in a tree.
44. Prim’s Algorithm: To find minimum cost
spanning tree
Procedure:
1. Consider any vertex of a graph.
2. Find all the edges of the selected vertex to all new vertices.
3. Select the least weighted edge and include it in a tree. If the least
weighted edge forms a cycle , then discard it.
4. Repeat step 2 and 3 until all the vertices are included in a tree.
46. Shortest path routing algorithm
Route- Path through which the packet travels from source to
destination.
We can find the shortest route with the help of some functions
between nodes
Functions can be cost, distance,time,traffic etc.,
Finding shortest path can be done in two ways
1.By constructing a tree
2.Using Dijkstra’s algorithm
49. Dynamic Programming
Used to solve optimization problems.
The Dynamic Programming works:
1.Breaks down the complex problem into simpler sub problems
2. Find optimal solution to these sub problems.
3. Store the result of sub problems
4. Reuse them so that same sub problem is not calculated more than once
5. Finally calculate the result of complex problem
Applicable to the problems having the properties:
1.Optimal substructure
2.Overlapping Sub problem
50. Example:
Recursive method
def fib(n):
if n<=1:
return n
else:
return(fib(n-1)+fib(n-2))
nterms=4
if nterms<=0:
print("Enter positive integer")
else:
for i in range(nterms):
print(fib(i))
51. Dynamic programming method
class solution(object):
def fib(self,n):
if n==0:
return(0)
if n==1:
return(1)
dp=[0]*(n+1)
dp[0]=0
dp[1]=1
print(dp)
for i in range(2,n+1):
dp[i]=dp[i-1]+dp[i-2]
print(dp)
out=solution()
out.fib(5)