This presentation is all about various built in
datastructures which we have in python.
List
Dictionary
Tuple
Set
and various methods present in each data structure
Python is a widely used high-level programming language for general-purpose programming. Python is a simple, powerful and easy to learn the programming language. It is commonly used for Web and Internet development, Scientific and Numeric computing, Business application and Desktop GUI development etc. The basic data structures in python are lists, dictionaries, tuples, strings and sets
This presentation is all about various built in
datastructures which we have in python.
List
Dictionary
Tuple
Set
and various methods present in each data structure
Python is a widely used high-level programming language for general-purpose programming. Python is a simple, powerful and easy to learn the programming language. It is commonly used for Web and Internet development, Scientific and Numeric computing, Business application and Desktop GUI development etc. The basic data structures in python are lists, dictionaries, tuples, strings and sets
AVL Trees
Adelson-Velskii and Landis
Binary Search Tree - Best Time
All BST operations are O(d), where d is tree depth
minimum d is for a binary tree with N nodes
What is the best case tree?
What is the worst case tree?
So, best case running time of BST operations is O(log N)
Binary Search Tree - Worst Time
Worst case running time is O(N)
What happens when you Insert elements in ascending order?
Insert: 2, 4, 6, 8, 10, 12 into an empty BST
Problem: Lack of “balance”:
compare depths of left and right subtree
Unbalanced degenerate tree
Balanced and unbalanced BST
Approaches to balancing trees
Don't balance
May end up with some nodes very deep
Strict balance
The tree must always be balanced perfectly
Pretty good balance
Only allow a little out of balance
Adjust on access
Self-adjusting
Balancing Binary Search Trees
Many algorithms exist for keeping binary search trees balanced
Adelson-Velskii and Landis (AVL) trees (height-balanced trees)
Splay trees and other self-adjusting trees
B-trees and other multiway search trees
Perfect Balance
Want a complete tree after every operation
tree is full except possibly in the lower right
This is expensive
For example, insert 2 in the tree on the left and then rebuild as a complete tree
AVL - Good but not Perfect Balance
AVL trees are height-balanced binary search trees
Balance factor of a node
height(left subtree) - height(right subtree)
An AVL tree has balance factor calculated at every node
For every node, heights of left and right subtree can differ by no more than 1
Store current heights in each node
Height of an AVL Tree
N(h) = minimum number of nodes in an AVL tree of height h.
Basis
N(0) = 1, N(1) = 2
Induction
N(h) = N(h-1) + N(h-2) + 1
Solution (recall Fibonacci analysis)
N(h) > h ( 1.62)
Height of an AVL Tree
N(h) > h ( 1.62)
Suppose we have n nodes in an AVL tree of height h.
n > N(h) (because N(h) was the minimum)
n > h hence log n > h (relatively well balanced tree!!)
h < 1.44 log2n (i.e., Find takes O(logn))
Node Heights
Node Heights after Insert 7
Insert and Rotation in AVL Trees
Insert operation may cause balance factor to become 2 or –2 for some node
only nodes on the path from insertion point to root node have possibly changed in height
So after the Insert, go back up to the root node by node, updating heights
If a new balance factor is 2 or –2, adjust tree by rotation around the node
Single Rotation in an AVL Tree
Implementation
Single Rotation
Double Rotation
Implement Double Rotation in two lines.
Insertion in AVL Trees
Insert at the leaf (as for all BST)
only nodes on the path from insertion point to root node have possibly changed in height
So after the Insert, go back up to the root node by node, updating heights
If a new balance factor is 2 or –2, adjust tree by rotation around the node
Insert in BST
Insert in AVL trees
Example of Insertions in an A
Data Structure Introduction
Data Structure Definition
Data Structure Types
Data Structure Characteristics
Need for Data Structure
Stack Definition
Stack Representation
Stack Operations
Stack Algorithm
Program for Stack in C++
Linked List Definition
Linked List Representation
Linked List Operations
Linked List Algorithm
Program for Linked List in C++
Linked List Defination
Linked List Representation
Linked List Operations
Linked List Algorithm
Program for Linked List in C++
AVL Trees
Adelson-Velskii and Landis
Binary Search Tree - Best Time
All BST operations are O(d), where d is tree depth
minimum d is for a binary tree with N nodes
What is the best case tree?
What is the worst case tree?
So, best case running time of BST operations is O(log N)
Binary Search Tree - Worst Time
Worst case running time is O(N)
What happens when you Insert elements in ascending order?
Insert: 2, 4, 6, 8, 10, 12 into an empty BST
Problem: Lack of “balance”:
compare depths of left and right subtree
Unbalanced degenerate tree
Balanced and unbalanced BST
Approaches to balancing trees
Don't balance
May end up with some nodes very deep
Strict balance
The tree must always be balanced perfectly
Pretty good balance
Only allow a little out of balance
Adjust on access
Self-adjusting
Balancing Binary Search Trees
Many algorithms exist for keeping binary search trees balanced
Adelson-Velskii and Landis (AVL) trees (height-balanced trees)
Splay trees and other self-adjusting trees
B-trees and other multiway search trees
Perfect Balance
Want a complete tree after every operation
tree is full except possibly in the lower right
This is expensive
For example, insert 2 in the tree on the left and then rebuild as a complete tree
AVL - Good but not Perfect Balance
AVL trees are height-balanced binary search trees
Balance factor of a node
height(left subtree) - height(right subtree)
An AVL tree has balance factor calculated at every node
For every node, heights of left and right subtree can differ by no more than 1
Store current heights in each node
Height of an AVL Tree
N(h) = minimum number of nodes in an AVL tree of height h.
Basis
N(0) = 1, N(1) = 2
Induction
N(h) = N(h-1) + N(h-2) + 1
Solution (recall Fibonacci analysis)
N(h) > h ( 1.62)
Height of an AVL Tree
N(h) > h ( 1.62)
Suppose we have n nodes in an AVL tree of height h.
n > N(h) (because N(h) was the minimum)
n > h hence log n > h (relatively well balanced tree!!)
h < 1.44 log2n (i.e., Find takes O(logn))
Node Heights
Node Heights after Insert 7
Insert and Rotation in AVL Trees
Insert operation may cause balance factor to become 2 or –2 for some node
only nodes on the path from insertion point to root node have possibly changed in height
So after the Insert, go back up to the root node by node, updating heights
If a new balance factor is 2 or –2, adjust tree by rotation around the node
Single Rotation in an AVL Tree
Implementation
Single Rotation
Double Rotation
Implement Double Rotation in two lines.
Insertion in AVL Trees
Insert at the leaf (as for all BST)
only nodes on the path from insertion point to root node have possibly changed in height
So after the Insert, go back up to the root node by node, updating heights
If a new balance factor is 2 or –2, adjust tree by rotation around the node
Insert in BST
Insert in AVL trees
Example of Insertions in an A
Data Structure Introduction
Data Structure Definition
Data Structure Types
Data Structure Characteristics
Need for Data Structure
Stack Definition
Stack Representation
Stack Operations
Stack Algorithm
Program for Stack in C++
Linked List Definition
Linked List Representation
Linked List Operations
Linked List Algorithm
Program for Linked List in C++
Linked List Defination
Linked List Representation
Linked List Operations
Linked List Algorithm
Program for Linked List in C++
Essentials of Automations: Optimizing FME Workflows with ParametersSafe Software
Are you looking to streamline your workflows and boost your projects’ efficiency? Do you find yourself searching for ways to add flexibility and control over your FME workflows? If so, you’re in the right place.
Join us for an insightful dive into the world of FME parameters, a critical element in optimizing workflow efficiency. This webinar marks the beginning of our three-part “Essentials of Automation” series. This first webinar is designed to equip you with the knowledge and skills to utilize parameters effectively: enhancing the flexibility, maintainability, and user control of your FME projects.
Here’s what you’ll gain:
- Essentials of FME Parameters: Understand the pivotal role of parameters, including Reader/Writer, Transformer, User, and FME Flow categories. Discover how they are the key to unlocking automation and optimization within your workflows.
- Practical Applications in FME Form: Delve into key user parameter types including choice, connections, and file URLs. Allow users to control how a workflow runs, making your workflows more reusable. Learn to import values and deliver the best user experience for your workflows while enhancing accuracy.
- Optimization Strategies in FME Flow: Explore the creation and strategic deployment of parameters in FME Flow, including the use of deployment and geometry parameters, to maximize workflow efficiency.
- Pro Tips for Success: Gain insights on parameterizing connections and leveraging new features like Conditional Visibility for clarity and simplicity.
We’ll wrap up with a glimpse into future webinars, followed by a Q&A session to address your specific questions surrounding this topic.
Don’t miss this opportunity to elevate your FME expertise and drive your projects to new heights of efficiency.
Observability Concepts EVERY Developer Should Know -- DeveloperWeek Europe.pdfPaige Cruz
Monitoring and observability aren’t traditionally found in software curriculums and many of us cobble this knowledge together from whatever vendor or ecosystem we were first introduced to and whatever is a part of your current company’s observability stack.
While the dev and ops silo continues to crumble….many organizations still relegate monitoring & observability as the purview of ops, infra and SRE teams. This is a mistake - achieving a highly observable system requires collaboration up and down the stack.
I, a former op, would like to extend an invitation to all application developers to join the observability party will share these foundational concepts to build on:
Transcript: Selling digital books in 2024: Insights from industry leaders - T...BookNet Canada
The publishing industry has been selling digital audiobooks and ebooks for over a decade and has found its groove. What’s changed? What has stayed the same? Where do we go from here? Join a group of leading sales peers from across the industry for a conversation about the lessons learned since the popularization of digital books, best practices, digital book supply chain management, and more.
Link to video recording: https://bnctechforum.ca/sessions/selling-digital-books-in-2024-insights-from-industry-leaders/
Presented by BookNet Canada on May 28, 2024, with support from the Department of Canadian Heritage.
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
Generative AI Deep Dive: Advancing from Proof of Concept to ProductionAggregage
Join Maher Hanafi, VP of Engineering at Betterworks, in this new session where he'll share a practical framework to transform Gen AI prototypes into impactful products! He'll delve into the complexities of data collection and management, model selection and optimization, and ensuring security, scalability, and responsible use.
Epistemic Interaction - tuning interfaces to provide information for AI supportAlan Dix
Paper presented at SYNERGY workshop at AVI 2024, Genoa, Italy. 3rd June 2024
https://alandix.com/academic/papers/synergy2024-epistemic/
As machine learning integrates deeper into human-computer interactions, the concept of epistemic interaction emerges, aiming to refine these interactions to enhance system adaptability. This approach encourages minor, intentional adjustments in user behaviour to enrich the data available for system learning. This paper introduces epistemic interaction within the context of human-system communication, illustrating how deliberate interaction design can improve system understanding and adaptation. Through concrete examples, we demonstrate the potential of epistemic interaction to significantly advance human-computer interaction by leveraging intuitive human communication strategies to inform system design and functionality, offering a novel pathway for enriching user-system engagements.
Dev Dives: Train smarter, not harder – active learning and UiPath LLMs for do...UiPathCommunity
💥 Speed, accuracy, and scaling – discover the superpowers of GenAI in action with UiPath Document Understanding and Communications Mining™:
See how to accelerate model training and optimize model performance with active learning
Learn about the latest enhancements to out-of-the-box document processing – with little to no training required
Get an exclusive demo of the new family of UiPath LLMs – GenAI models specialized for processing different types of documents and messages
This is a hands-on session specifically designed for automation developers and AI enthusiasts seeking to enhance their knowledge in leveraging the latest intelligent document processing capabilities offered by UiPath.
Speakers:
👨🏫 Andras Palfi, Senior Product Manager, UiPath
👩🏫 Lenka Dulovicova, Product Program Manager, UiPath
Builder.ai Founder Sachin Dev Duggal's Strategic Approach to Create an Innova...Ramesh Iyer
In today's fast-changing business world, Companies that adapt and embrace new ideas often need help to keep up with the competition. However, fostering a culture of innovation takes much work. It takes vision, leadership and willingness to take risks in the right proportion. Sachin Dev Duggal, co-founder of Builder.ai, has perfected the art of this balance, creating a company culture where creativity and growth are nurtured at each stage.
GraphRAG is All You need? LLM & Knowledge GraphGuy Korland
Guy Korland, CEO and Co-founder of FalkorDB, will review two articles on the integration of language models with knowledge graphs.
1. Unifying Large Language Models and Knowledge Graphs: A Roadmap.
https://arxiv.org/abs/2306.08302
2. Microsoft Research's GraphRAG paper and a review paper on various uses of knowledge graphs:
https://www.microsoft.com/en-us/research/blog/graphrag-unlocking-llm-discovery-on-narrative-private-data/
1. ARRAY
an array data structure or simply an array is a data structure consisting of a collection
of elements (values orvariables), each identified by at least one array index or key.
Applications
Arrays are used to implement mathematical vectors and matrices, as well as other kinds of
rectangular tables.
One-dimensional arrays
A one-dimensional array (or single dimension array) is a type of linear array. Accessing its
elements involves a single subscript which can either represent a row or column index.
As an example consider the C declaration int anArrayName[10];
Multidimensional arrays
For a two-dimensional array, the element with indices i,j would have address B + c · i + d · j,
where the coefficients c and d are the rowand column address increments, respectively.
For example: int a[3][2];
STACK::
A stack is a list in which insertion and deletion take place at the same end
This end is called top
The other end is called bottom
Stacks are known as LIFO (Last In, First Out) lists.
The last element inserted will be the first to be retrieved
Primary operations: Push and Pop
Push
Add an element to the top of the stack
Pop
Remove the element at the top of the stack
Implementation of Stacks
Any list implementation could be used to implement a stack
Arrays (static: the size of stack is given initially)
Linked lists (dynamic: never become full)
CODE)CHECK IT
LB=O;
TOP=LB; INSEERTION
WHILE TOP!= 4
READ X
NUM[TOP]=X
TOP=TOP+1
TOP=TOP-1
WHILE TOP!= -1 DELETION
{TOP= TOP -1}
QEUEE
2. Like a stack, a queue is also a list. However, with a queue, insertion is done at one end, while
deletion is performed at the other end.
Accessing the elements of queues follows a First In, First Out (FIFO) order.
Like customers standing in a check-out line in a store, the first customer in is the first customer
served.
Enqueue and Dequeue
Primary queue operations: Enqueue and Dequeue
Like check-out lines in a store, a queue has a front and a rear.
Enqueue – insert an element at the rear of the queue
Dequeue – remove an element from the front of the queue
Implementation of Queue
Just as stacks can be implemented as arrays or linked lists, so with queues.
Dynamic queues have the same advantages over static queues as dynamic stacks have over static
stacks
Queue Implementation of Array
There are several different algorithms to implement Enqueue and Dequeue
Naïve way
When enqueuing, the front index is always fixed and the rear index moves forward in the array.
rear rear rear
3 3 6 3 6 9
front front front
Enqueue(3) Enqueue(6) Enqueue(9)
Naïve way (cont’d)
When dequeuing, the front index is fixed, and the element at the front the queue is removed.
Move all the elements after it by one position. (Inefficient!!!)
3. rear rear rear = -1
6 9 9
front front front
Dequeue() Dequeue() Dequeue()
Delete ( ):
Description: Here QUEUE is an array with N locations. FRONT and REAR points to the front
and rear of
the QUEUE.
1. If (FRONT == 0) Then [Check for underflow]
2. Print: Underflow
3. Else
4. ITEM = QUEUE[FRONT]
5. If (FRONT == REAR) Then [Check if only one element is left]
(a) Set FRONT = 0
(b) Set REAR = 0
6. Else
7. Set FRONT = FRONT + 1 [Increment FRONT by 1]
[End of Step 5 If]
8. Print: ITEM deleted
[End of
Insert ( ):
Description: Here QUEUE is an array with N locations. FRONT and REAR points to the front
and rear of
the QUEUE. ITEM is the value to be inserted.
1. If (REAR == N) Then [Check for overflow]
2. Print: Overflow
3. Else
4. If (FRONT and REAR == 0) Then [Check if QUEUE is empty]
(a) Set FRONT = 1
(b) Set REAR = 1
5. Else
6. Set REAR = REAR + 1 [Increment REAR by 1]
[End of Step 4 If]
7. QUEUE[REAR] = ITEM
8. Print: ITEM inserted
[End of Step 1 If]
9. Exit
LINKLIST
A linked list or one way list is a linear collection of data elements called nodes where the linear
order is given by means of pointers. That is each node is divided into two parts the first part
4. contains the address of the element and the second part called the link field or next pointer field
contains the address of the next node in the list.
The linked list can be of following types:
1. Linear Linked List or One Way List or Singly Linked List.
2. Doubly Linked List or Two Way List.
3. Circular Linked List.
4. Header Linked List.
5. Two Way Header Linked List.
6. Circular Header Linked List.
7. Two Way Circular Header Linked List
• Types of linked lists:
– Singly linked list
• Begins with a pointer to the first node
• Terminates with a null pointer
• Only traversed in one direction
– Circular, singly linked
• Pointer in the last node points back to the first node
– Doubly linked list
• Two “start pointers” – first element and last element
• Each node has a forward pointer and a backward pointer
• Allows traversals both forwards and backwards
– Circular, doubly linked list
• Forward pointer of the last node points to the first node and backward
pointer of the first node points to the last node
Header Linked List.
Header Linked List: A header linked list which always contains a special node, called the header node, at
the beginning of the list. The following are two kinds of widely used header list:
1. A grounded header list is a header list where the last node contains the null pointer.
2. A circular header list is a header list where the last node points back to the header node.
Unless otherwise stated or implied, our header list will always be circular list. Accordingly, in
such a case, the header node also acts as a sentinel indicating the end of the list.
Header Linked List
. Two Way Header Linked List.
The two-way list is a linear collection of data elements called nodes where each node is divided into three
parts:
1. An information field INFO which contains the data of N
2. A pointer field FORW which contains the location of the next node in the list.
3. A pointer field BACK which contains the location of the preceding node in the list.
5. The list also requires two list pointer variables: FIRST, which points to the first node in the list, and LAST,
which points to the last node in the list. Observe that the null pointer appears in the FORW field of the last
node in the list and also in the BACK field
of the first node in the list.
TREE (inorder, preorder, postfix, memory representation by
array and link list)
• Tree nodes contain two or more links
– All other data structures we have discussed only contain one
• Binary trees
– All nodes contain two links
• None, one, or both of which may be NULL
– The root node is the first node in a tree.
– Each link in the root node refers to a child
– A node with no children is called a leaf node
• Binary search tree
– Values in left sub tree less than parent
– Values in right sub tree greater than parent
– Facilitates duplicate elimination
– Fast searches - for a balanced tree, maximum of log n comparisons
6. 4
7
2 7
5 7
1 4 6 93
1 3 5
7 17 3 44 6
1 8
• Tree traversals:
– In order traversal – prints the node values in ascending order
1. Traverse the left sub tree with an in order traversal
2. Process the value in the node (i.e., print the node value)
3. Traverse the right sub tree with an in order traversal
– Preorder traversal
1. Process the value in the node
2. Traverse the left sub tree with a preorder traversal
3. Traverse the right sub tree with a preorder traversal
– Post order traversal
1. Traverse the left subtree with a postorder traversal
2. Traverse the right subtree with a postorder traversal
3. Process the value in the node
For example
can be represented by the array
Suppose we would like to represent the following tree in memory, using only lists (which are
created by chaining conses). You should already know how acons is created and what parts
constitute one. If not, go back to an introductory book on Common Lisp.
7. This tree can be represented as a set of linked lists, like in the following diagram:
The natural way to represent the previous tree as a Common Lisp list is like the following:
(1 (2 6 7 8) 3 (4 (9 12)) (5 10 11))
The first element of a list is the root of that tree (or a node) and the rest of the elements are
the subtrees (more nodes). For example, the subtree (2 6 7 8)is a tree with “2” at its root
and the elements “6 7 8” as its children.
Graph definition
A graph is a collection of nodes called vertices, and the connections between them, called edges.
An example
The following diagram shows a graph with 5 vertices and 7 edges. The edges between A and D
and B and C are pairs that make a bidirectional connection, represented here by a double-headed
arrow.
8. disjkstra algorithm to find shortest path
The indented lines under a given line are done under the condition that line. Once that condition
is no longer met you move on in the algorithm. The first part of the algorithm is an initialization
of the graph into the setup described earlier; the rest is concerned with searching through the
graph to find distances. To illustrate the algorithm we provide an example below.
In the above picture o is marked by a double circle. The Unburned node with the smallest &delta
value is orange. It will be burned at the next step in the algorithm. The yellow vertex is the one
that is currently burning. Gray vertices have been labeled as Burned by the algorithm. Neighbors
if the burning vertex whose &delta is being updated have their edges marked in orange. This
happens when δ(u) + w(u,n) < &delta(n). Edges corresponding to sources are marked in blue.
Note that the algorithm will occasionally overwrite the source of a vertex with a closer source.
Once all the vertices are Burned the algorithm is burned.
Now that we've run the algorithm how do we find the shortest path from o to another vertex? We
simply follow thesource edges (blue in the example) from the destination until we reach o, and
the distance we have travelled corresponds to the label &delta on the destination. We also know
that we have actually found the shortest path (it is possible to have more than one path tied for
being the shortest) since our fire has always chosen to take the shortest steps possible when
moving to a new location.
You might have already noticed that the blue subgraph doesn't contain any loops, and this is what
mathematicians call a tree. In fact this is a very special kind of tree called a minimal spanning
tree because it grows from the root o to all of its leaves, the other vertices in G, in the shortest
way possible. Minimal spanning trees are very useful. For instance, if a cable company needs to
wire all the houses in a neighborhood using as little wire as possible, a minimal spanning tree of
the neighborhood provides them with the most efficient way to do so.
9. Game tree (definiton)
games) game tree - A tree representing contingencies in a game. Each node in a game tree
represents a possible position (e.g., possible configuration of pieces on a chessboard) in
the game, and each branching ("edge" in graph terms) represents a possible move.
A constructor gets called automatically when you create an object of a class; if you define your
own constructor, by default a constructor is called which is the Default Constructor. A class can
have more than one constructor. It has the same name as the class itself.
Destructors are again methods of a class that enable the destruction of an object after its use;
destructors also provide the means of memory clean up after usage. Destructors are always called
in the reverse order of Constructors. There can only be one destructor per class and they neither
take an input parameter nor do they return anything. Destructors need not be called explicitly.
Code:
class Vehicle
{
Int Registration = 0;
public:
Vehicle(int regis) // constructor
{
Registration = regis;
}
Virtual void GetRegistration() = 0;
~Vehicle() // destructor
{
}
ATTRIBUTE FUNCTION
In GNU C, you declare certain things about functions called in your
program which help the compiler optimize function calls and check your
code more carefully.
The keyword `__attribute__' allows you to specify special attributes
when making a declaration. This keyword is followed by an attribute
specification inside double parentheses.
void fatal () __attribute__ ((noreturn));
void
fatal (...)
{
... /* Print error message. */ ...
exit (1);
}
Attribute Member
The member attribute is a multi-value attribute that contains the list of distinguished names for the
user, group, and contact objects that are members of the group. Each item in the list is a linked
10. reference to the object that represents the member; therefore, the Active Directory server automatically
updates the distinguished names in the member property when a member object is moved or renamed.