Abstract: This workshop teaches basic algorithms in whiteboarding interviews. All the code examples are in Python and the course has dual purpose teaching basic Python programming.
The document discusses object-oriented programming concepts in Python including classes, objects, methods, encapsulation, inheritance, and polymorphism. It provides examples of defining a class with attributes and methods, instantiating objects from a class, and accessing object attributes and methods. It also covers the differences between procedure-oriented and object-oriented programming, and fundamental OOP concepts like encapsulation, inheritance, and polymorphism in Python.
This document provides an overview of string manipulation in C++. It discusses C-style strings and introduces C++ strings as objects of the string class. It describes various string constructors, functions for comparison, concatenation, insertion, extraction and other operations. Examples are given to demonstrate the use of functions like length(), capacity(), empty(), at(), find(), assign(), begin() and end(). The document is intended as a lecture on object-oriented string handling in C++.
The document discusses file handling in C++. It describes how programs can store data permanently in files on secondary storage devices. It explains the different stream classes like ifstream, ofstream and fstream that are used for file input, output and input/output operations. It provides details on the general steps to open, use and close files. It also discusses concepts like file pointers, reading and writing data to files, and updating records in sequential access files.
This document provides an introduction to Python programming concepts including data types, operators, control flow statements, functions and modules. It discusses the basic Python data types like integers, floats, booleans, strings, lists, tuples, dictionaries and sets. It also covers Python operators like arithmetic, assignment, comparison, logical and identity operators. Additionally, it describes control flow statements like if/else and for loops. Finally, it touches on functions, modules and input/output statements in Python.
The document discusses data structures and linked lists. It begins with an introduction to data structures, classifying them as primitive, non-primitive, linear and non-linear. Linked lists are introduced as a linear data structure where elements are linked using pointers rather than stored contiguously in memory. Key advantages of linked lists over arrays are their dynamic size and ease of insertion/deletion. The document provides examples of creating nodes for a linked list in memory and connecting them using pointers.
This document provides an introduction and overview of the Python programming language. It discusses Python's features such as being simple, easy to learn, free and open source, portable, and having batteries included. It also covers installing Python, writing a simple "Hello World" program, using variables and data types, operators, control flow statements, functions, and various Python data structures like lists, tuples, and dictionaries. The document is intended to teach beginners the basics of Python.
The document provides an introduction to Python programming by discussing statements and syntax. It covers assignment statements, expression statements, print operations, conditional statements like if/else, and loop statements like while and for. It explains how Python programs are composed of modules containing statements with expressions. Truth tests for conditionals and built-in functions like range, zip that can be used in loops are also overviewed.
This document provides an overview of Python collections including strings, bytes, lists, tuples, dictionaries, sets, and ranges. It discusses how to create, access, modify, iterate through, and perform common operations on each collection type. For each collection, it provides examples of basic usage and built-in methods. The document is intended as a reference for working with the main collection data types in Python.
This document provides an overview of key Python concepts:
1. Modules allow organizing Python code into files and namespaces. The file name is the module name with a .py extension.
2. Python code is compiled into bytecode cache files (.pyc) for improved performance. These files are platform independent.
3. Advanced optimizations can be applied to bytecode with command line flags, but may affect program functionality in rare cases.
4. Standard modules provide useful functions like dir() to inspect modules and packages for organizing code. Input/output, strings, files and exceptions are also covered.
The document discusses Python programming language. Some key points:
- Python was invented by Guido Van Rossum and is a combination of various programming languages.
- It is a general purpose, high-level programming language that is interpreted, interactive, object-oriented and extensible.
- Python can be used for web applications, desktop applications, data analysis, artificial intelligence, and more. Popular companies that use Python include Google, YouTube, and NASA.
- Python code is portable and can run on various platforms. It has a simple syntax and is easy to learn.
This Edureka Python tutorial will help you in learning various sequences in Python - Lists, Tuples, Strings, Sets, Dictionaries. It will also explain various operations possible on them. Below are the topics covered in this tutorial:
1. Python Sequences
2. Python Lists
3. Python Tuples
4. Python Sets
5. Python Dictionaries
6. Python Strings
This presentation provides the information on python including the topics Python features, applications, variables and operators in python, control statements, numbers, strings, print formatting, list and list comprehension, dictionaries, tuples, files, sets, boolean, mehtods and functions, lambda expressions and a sample project using Python.
This document provides an introduction to the Python programming language. It discusses Python's design philosophy emphasizing readability. It also covers printing messages, reading input, variables and data types, operators, and basic syntax like comments and identifiers. Arithmetic, relational, logical and bitwise operators are explained along with examples.
The document discusses arrays in C programming. It defines arrays as collections of data of the same type with a common name. It shows different ways to declare and initialize arrays, as well as examples of accessing array elements using indexes and looping through arrays using for loops. It also demonstrates storing different data types in separate arrays and calculating totals by accessing corresponding elements from each array.
The document discusses input/output files in Java. It covers the key classes used for reading and writing files in Java, including FileInputStream, FileOutputStream, FileReader, and FileWriter. It also discusses byte streams versus character streams, and provides examples of reading and writing to files in Java using these classes. Standard input/output streams like System.in and System.out are also covered.
This document provides an overview of Linux command line essentials including shell script basics, variables, operators, loops, and functions. It covers topics such as the difference between CLI and GUI interfaces, what a kernel and shell are, defining variables and variable types, arithmetic, relational, boolean, and file test operators, while, for, and until loops, and creating reusable functions. The document is from edureka.co and serves as an introduction to common Linux shell scripting concepts.
The document compares interpreters and compilers. It states that interpreters translate code line-by-line while compilers scan the entire program at once. Interpreters have faster analysis time but slower overall execution, while compilers have slower analysis but faster execution. Interpreters do not generate object code so are more memory efficient. Languages like JavaScript, Python and Ruby use interpreters, while C, C++ and Java use compilers.
This document provides information on C programming concepts including data types, operators, functions, and basic program structure.
It defines key concepts like variables, data types (integer, float, character), operators (arithmetic, relational, logical), functions (printf, scanf), and basic program anatomy with main(), I/O statements, and comments. Examples are given to illustrate variable declaration and usage, arithmetic operations, type casting, and basic programs to read/write and perform calculations.
This document provides an overview of lists in Python. It defines lists as ordered and changeable collections that allow duplicate elements. It describes how to create, access, modify, loop through, add and remove elements from lists. Built-in list methods like append(), pop(), sort(), count() and their usage are explained. The document also shows examples of sorting lists, removing failed grades, shuffling words to create anagrams, and reading/writing lists from user input.
This document discusses string handling functions in C programming. It defines a string as an array of characters and introduces the string.h header file, which contains functions for manipulating strings like strlen(), strcmp(), strcmpi(), strcpy(), and strcat(). It explains what each function does, including getting the length of a string, comparing strings, copying one string to another, and concatenating two strings.
The document outlines file handling in C++, including the need for data files, types of files (text and binary), basic file operations for each type, and the components used in C++ for file handling like header files, classes, and functions. It discusses opening, reading, writing, and closing files, as well as file pointers and random vs sequential access.
This chapter discusses dictionaries and sets in Python. It covers how to create, manipulate, and iterate over dictionaries and sets. Some key dictionary topics include adding and retrieving key-value pairs, checking for keys, and using dictionary methods. For sets, the chapter discusses set operations like union, intersection, difference and symmetric difference. It also covers serializing objects using the pickle module.
This document discusses data types in Java. There are two main types: primitive data types (boolean, char, byte, etc.) and non-primitive types (classes, interfaces, arrays). It explains each of the eight primitive types and provides examples of non-primitive types like classes and arrays. The document also covers type casting (converting between data types), autoboxing/unboxing of primitive types to their corresponding wrapper classes, and the differences between implicit and explicit type casting.
Scala 3 by Example - Algebraic Data Types for Domain Driven Design - Part 1Philip Schwarz
slides can look grainy and/or out of focus when seen on slideshare - download for flawless quality - Based on Scott Wlaschin’s great book 'Domain Modeling Made Functional' and on Martin Odersky's talk 'A Tour of Scala 3'.
This document discusses different types of linked lists, including singly linked lists, circular linked lists, and doubly linked lists. It provides examples of circular linked lists and explains that in a circular linked list, the last node contains the address of the first node so that the list can be traversed repeatedly. The document also discusses common linked list operations like insertion and deletion of nodes. Finally, it covers stacks and queues, defining them as LIFO and FIFO data structures, respectively, and providing examples of their implementation and different types.
in this ppt, you find complete information of VI edited which Is text editor of UNIX operating system and all basic command like how to save files how to change how to edit how to delete
This document provides an overview of basic data structures in Python including stacks, queues, deques, and linked lists. It describes each data structure as an abstract data type with common operations. Implementations of each data structure are provided using Python classes. The stack, queue, and deque classes implement the respective data structures using Python lists. The linked list class implements nodes to link elements and allow for traversal. Examples are given demonstrating usage of each data structure implementation.
This document provides an overview of key Python concepts:
1. Modules allow organizing Python code into files and namespaces. The file name is the module name with a .py extension.
2. Python code is compiled into bytecode cache files (.pyc) for improved performance. These files are platform independent.
3. Advanced optimizations can be applied to bytecode with command line flags, but may affect program functionality in rare cases.
4. Standard modules provide useful functions like dir() to inspect modules and packages for organizing code. Input/output, strings, files and exceptions are also covered.
The document discusses Python programming language. Some key points:
- Python was invented by Guido Van Rossum and is a combination of various programming languages.
- It is a general purpose, high-level programming language that is interpreted, interactive, object-oriented and extensible.
- Python can be used for web applications, desktop applications, data analysis, artificial intelligence, and more. Popular companies that use Python include Google, YouTube, and NASA.
- Python code is portable and can run on various platforms. It has a simple syntax and is easy to learn.
This Edureka Python tutorial will help you in learning various sequences in Python - Lists, Tuples, Strings, Sets, Dictionaries. It will also explain various operations possible on them. Below are the topics covered in this tutorial:
1. Python Sequences
2. Python Lists
3. Python Tuples
4. Python Sets
5. Python Dictionaries
6. Python Strings
This presentation provides the information on python including the topics Python features, applications, variables and operators in python, control statements, numbers, strings, print formatting, list and list comprehension, dictionaries, tuples, files, sets, boolean, mehtods and functions, lambda expressions and a sample project using Python.
This document provides an introduction to the Python programming language. It discusses Python's design philosophy emphasizing readability. It also covers printing messages, reading input, variables and data types, operators, and basic syntax like comments and identifiers. Arithmetic, relational, logical and bitwise operators are explained along with examples.
The document discusses arrays in C programming. It defines arrays as collections of data of the same type with a common name. It shows different ways to declare and initialize arrays, as well as examples of accessing array elements using indexes and looping through arrays using for loops. It also demonstrates storing different data types in separate arrays and calculating totals by accessing corresponding elements from each array.
The document discusses input/output files in Java. It covers the key classes used for reading and writing files in Java, including FileInputStream, FileOutputStream, FileReader, and FileWriter. It also discusses byte streams versus character streams, and provides examples of reading and writing to files in Java using these classes. Standard input/output streams like System.in and System.out are also covered.
This document provides an overview of Linux command line essentials including shell script basics, variables, operators, loops, and functions. It covers topics such as the difference between CLI and GUI interfaces, what a kernel and shell are, defining variables and variable types, arithmetic, relational, boolean, and file test operators, while, for, and until loops, and creating reusable functions. The document is from edureka.co and serves as an introduction to common Linux shell scripting concepts.
The document compares interpreters and compilers. It states that interpreters translate code line-by-line while compilers scan the entire program at once. Interpreters have faster analysis time but slower overall execution, while compilers have slower analysis but faster execution. Interpreters do not generate object code so are more memory efficient. Languages like JavaScript, Python and Ruby use interpreters, while C, C++ and Java use compilers.
This document provides information on C programming concepts including data types, operators, functions, and basic program structure.
It defines key concepts like variables, data types (integer, float, character), operators (arithmetic, relational, logical), functions (printf, scanf), and basic program anatomy with main(), I/O statements, and comments. Examples are given to illustrate variable declaration and usage, arithmetic operations, type casting, and basic programs to read/write and perform calculations.
This document provides an overview of lists in Python. It defines lists as ordered and changeable collections that allow duplicate elements. It describes how to create, access, modify, loop through, add and remove elements from lists. Built-in list methods like append(), pop(), sort(), count() and their usage are explained. The document also shows examples of sorting lists, removing failed grades, shuffling words to create anagrams, and reading/writing lists from user input.
This document discusses string handling functions in C programming. It defines a string as an array of characters and introduces the string.h header file, which contains functions for manipulating strings like strlen(), strcmp(), strcmpi(), strcpy(), and strcat(). It explains what each function does, including getting the length of a string, comparing strings, copying one string to another, and concatenating two strings.
The document outlines file handling in C++, including the need for data files, types of files (text and binary), basic file operations for each type, and the components used in C++ for file handling like header files, classes, and functions. It discusses opening, reading, writing, and closing files, as well as file pointers and random vs sequential access.
This chapter discusses dictionaries and sets in Python. It covers how to create, manipulate, and iterate over dictionaries and sets. Some key dictionary topics include adding and retrieving key-value pairs, checking for keys, and using dictionary methods. For sets, the chapter discusses set operations like union, intersection, difference and symmetric difference. It also covers serializing objects using the pickle module.
This document discusses data types in Java. There are two main types: primitive data types (boolean, char, byte, etc.) and non-primitive types (classes, interfaces, arrays). It explains each of the eight primitive types and provides examples of non-primitive types like classes and arrays. The document also covers type casting (converting between data types), autoboxing/unboxing of primitive types to their corresponding wrapper classes, and the differences between implicit and explicit type casting.
Scala 3 by Example - Algebraic Data Types for Domain Driven Design - Part 1Philip Schwarz
slides can look grainy and/or out of focus when seen on slideshare - download for flawless quality - Based on Scott Wlaschin’s great book 'Domain Modeling Made Functional' and on Martin Odersky's talk 'A Tour of Scala 3'.
This document discusses different types of linked lists, including singly linked lists, circular linked lists, and doubly linked lists. It provides examples of circular linked lists and explains that in a circular linked list, the last node contains the address of the first node so that the list can be traversed repeatedly. The document also discusses common linked list operations like insertion and deletion of nodes. Finally, it covers stacks and queues, defining them as LIFO and FIFO data structures, respectively, and providing examples of their implementation and different types.
in this ppt, you find complete information of VI edited which Is text editor of UNIX operating system and all basic command like how to save files how to change how to edit how to delete
This document provides an overview of basic data structures in Python including stacks, queues, deques, and linked lists. It describes each data structure as an abstract data type with common operations. Implementations of each data structure are provided using Python classes. The stack, queue, and deque classes implement the respective data structures using Python lists. The linked list class implements nodes to link elements and allow for traversal. Examples are given demonstrating usage of each data structure implementation.
Strings in Python are sequence of characters that are immutable. They can be indexed, sliced, concatenated and their cases can be changed. Common string methods include find, count, strip, replace, capitalize etc. Lists are mutable sequences that can contain elements of different types. Common list operations include append, insert, pop, remove, sort etc. Tuples are immutable sequences that can be nested and support operations like slicing, indexing, unpacking etc. Sets are unordered collections of unique elements that support membership testing and set operations. Dictionaries are mutable mappings of unique keys to values that support various operations like get, update, keys, values etc.
This document provides an overview of dictionaries in Python. It discusses how dictionaries are defined using curly braces {}, how keys can be any immutable object like strings or numbers while values can be any object, and how to access values using keys. It also covers adding and deleting key-value pairs, checking for keys, shallow and deep copying, and creating dictionaries from keys or sequences.
Here is a Python function that calculates the distance between two points given their x and y coordinates:
```python
import math
def distance_between_points(x1, y1, x2, y2):
return math.sqrt((x2 - x1)**2 + (y2 - y1)**2)
```
To use it:
```python
distance = distance_between_points(1, 2, 4, 5)
print(distance)
```
This would print 3.605551275463989, which is the distance between the points (1,2) and (4,5).
The key steps are:
1.
1) Base types in Python include integers, floats, booleans, strings, bytes, lists, tuples, dictionaries, sets, and None. These types support various operations like indexing, slicing, membership testing, and type conversions.
2) Common loop statements in Python are for loops and while loops. For loops iterate over sequences, while loops repeat as long as a condition is true. Loop control statements like break, continue, and else can be used to control loop execution.
3) Functions are defined using the def keyword and can take parameters and return values. Functions allow for code reusability and organization. Built-in functions operate on containers to provide functionality like sorting, summing, and converting between types.
1) Base types in Python include integers, floats, booleans, strings, bytes, lists, tuples, dictionaries, sets, and None. These types support various operations like indexing, slicing, mathematical operations, membership testing, etc.
2) Functions are defined using the def keyword and can take parameters and return values. Functions are called by specifying the function name followed by parentheses that may contain arguments.
3) Common operations on containers in Python include getting the length, minimum/maximum values, sum, sorting, checking for membership, enumerating, and zipping containers. Methods like append, extend, insert, remove, pop can modify lists in-place.
Good morning Salma Hayek you have to do is your purpose of the best time to plant grass seed in the morning Salma Hayek you have to do is your purpose of the best time to plant grass seed in the morning Salma Hayek you have to do is your purpose of the best time to plant grass seed in the morning Salma Hayek you want me potter to plant in spring I will be there in the morning Salma Hayek you have a nice weekend with someone legally allowed in spring a contract for misunderstanding and tomorrow I hope it was about the best msg you want me potter you want me potter you want to do is your purpose of the best time to plant grass seed in the morning Salma Hayek you have to do it up but what do you think about the pros of the morning Salma good mornings are you doing well and tomorrow I hope it goes well and I hope you to do it goes well and tomorrow I have to be there at both locations in spring a nice day service and I hope it goes away soon as I can you have to be to get a I hope it goes away soon I hope it goes away soon I hope it goes away soon as I can you have to be to work at a time I can do is
1. Python provides various built-in container types including lists, tuples, dictionaries, sets, and strings for storing and organizing data.
2. These container types support common operations like indexing, slicing, membership testing, and methods for insertion, deletion, and modification.
3. The document provides examples of using operators and built-in functions to perform tasks like formatting strings, file I/O, conditional logic, loops, functions, and exceptions.
This document provides a summary of key Python concepts including:
1. Base data types like integers, floats, booleans, strings, lists, tuples, dictionaries, sets, and None.
2. Variables, assignments, identifiers, conversions between types, and string formatting.
3. Conditional statements like if/elif/else and boolean logic operators.
4. Loops like for and while loops for iterating over sequences.
5. Functions for defining reusable blocks of code and calling functions.
This document provides an overview of key Python concepts including types, sequences, lists, functions, and parameters. It discusses how Python is both strongly and dynamically typed. The main built-in sequences - lists, tuples, strings, and ranges - are described. Lists are covered in detail including construction, operations like indexing, slicing, and built-in methods. Finally, the document outlines the different types of function parameters - positional, keyword, and combining the two - and how to handle parameter collections using the * operator.
This document provides an introduction to using lists in Python. It defines what lists are in Python, how to create, access, update, and delete list elements, and some common list operations. It also provides examples of creating lists, accessing values at different indices, updating and deleting elements, and using basic operators like addition and multiplication. Finally, it proposes three exercises involving lists to practice these concepts.
Python 101++: Let's Get Down to Business!Paige Bailey
You've started the Codecademy and Coursera courses; you've thumbed through Zed Shaw's "Learn Python the Hard Way"; and now you're itching to see what Python can help you do. This is the workshop for you!
Here's the breakdown: we're going to be taking you on a whirlwind tour of Python's capabilities. By the end of the workshop, you should be able to easily follow any of the widely available Python courses on the internet, and have a grasp on some of the more complex aspects of the language.
Please don't forget to bring your personal laptop!
Audience: This course is aimed at those who already have some basic programming experience, either in Python or in another high level programming language (such as C/C++, Fortran, Java, Ruby, Perl, or Visual Basic). If you're an absolute beginner -- new to Python, and new to programming in general -- make sure to check out the "Python 101" workshop!
good new report fun enjoyThe WiMAX (IEEE 802.16e) standard offers peak data rates of 128Mbps downlink and
56Mbps uplink over 20MHz wide channels whilst the new standard in development, 4G
WiMAN-Advanced (802.16m) is targeting the requirements to be fully 4G using 64Q QAM,
BPSK and MIMO technologies to reach the 1Gbps rate. It is predicted that in an actual
deployment, using 4X2 MIMO in an urban microcell application using a 20 MHz TDD
channel, the 4G WiMAN-Advanced system will be able to support 120Mbps downlink and
60Mbps uplink per site concurrently. WiMAX applications are already in use in many countries
globally but research in 2010 gave results that showed only just over 350 set ups were actually
in use. Many previous WiMAX operators were found to have moved to LTE along with Yota,
who were the largest WiMAX operator in the world.
This document discusses four types of learning agents in artificial intelligence: simple reflex agents, model-based agents, goal-based agents, and utility-based agents. A learning agent improves upon these by dynamically learning a policy to model its environment and build action-state rules based on rewards from interacting with its environment.
Abstract: This workshop teaches the application of statistics to the software quality assurance process. The course covers smoke testing, acceptance testing, Pareto principle, defect distributions, automated vs. manual testing, predicting effort, and experimental thoughts using Bellman equation approach and machine learning.
Level: Intermediate
Requirements: Some basic statistics knowledge is preferred and experience or exposure to the software quality assurance process.
Abstract: This PDSG workshop covers the basics of OOP programming in Python. Concepts covered are class, object, scope, method overloading and inheritance.
Level: Fundamental
Requirements: One should have some knowledge of programming.
Abstract: This PDSG workshop covers the basics of OOP programming in Python. Concepts covered are class, object, scope, method overloading and inheritance.
Level: Fundamental
Requirements: One should have some knowledge of programming.
Python - Installing and Using Python and Jupyter NotepadAndrew Ferlitsch
Abstract: This PDSG workshop covers installing Python and Juypter Notebook, and how to create a notebook.
Level: Fundamental
Requirements: One should have some knowledge of programming.
Natural Language Processing - Groupings (Associations) GenerationAndrew Ferlitsch
Abstract: This PDSG workshop covers methods to automatically generate word groupings as associations, which can be used to teach associations between objects to pre-school and early school children. Ex. What item does not belong? Cat, Dog, Fire Truck, Bird
In this presentation, I will cover how to build categorical and association dictionaries to automatically generate associations of the form, what item does not belong.
Level: Intermediate
Requirements: One should have some programming knowledge.
Natural Language Provessing - Handling Narrarive Fields in Datasets for Class...Andrew Ferlitsch
Abstract: It is common for government and public datasets to include narrative fields, such as inspection reports, incident reporting, surveys, 911 calls, fire response, etc. In addition to categorical fields, such as datetime, location, demographics, these datasets tend to include a narrative description (e.g., what happened). It is typically in the narrative field that the most interesting data resides for the purpose of classifying. The problem, is that since the narrative is human interpreted and entered, each entry may be unique and if we use the whole entry as a single value, one will end up with an overfitted model that works only on the training data.
In this presentation, I will cover how natural language processing techniques are used to convert narrative fields into categorical data.
Level: Intermediate
Requirements: One should know basics of linear regression models. No prior programming knowledge is required.
Machine Learning - Introduction to Recurrent Neural NetworksAndrew Ferlitsch
Abstract: This PDSG workshop introduces basic concepts of recurrent neural networks. Concepts covered are feed forward vs. recurrent, time progression, memory cells, short term memory predictions and long term memory predictions.
Level: Fundamental
Requirements: No prior programming or statistics knowledge required.
Machine Learning - Introduction to Convolutional Neural NetworksAndrew Ferlitsch
Abstract: This PDSG workshop introduces basic concepts of convolutional neural networks. Concepts covered are image pixels, image preprocessing, feature detectors, feature maps, convolution, ReLU, pooling and flattening.
Level: Fundamental
Requirements: No prior programming or statistics knowledge required. Some knowledge of neural networks is recommended.
Machine Learning - Introduction to Neural NetworksAndrew Ferlitsch
Abstract: This PDSG workshop introduces basic concepts of neural networks. Concepts covered are Neurons, Binary vs. Categorical vs. Real Value output, activation functions, fully connected networks, deep neural networks, specialized learners, cost function and feed forward.
Level: Fundamental
Requirements: No prior programming or statistics knowledge required.
Abstract: This PDSG workshop introduces the basics of Python libraries used in machine learning. Libraries covered are Numpy, Pandas and MathlibPlot.
Level: Fundamental
Requirements: One should have some knowledge of programming and some statistics.
Machine Learning - Accuracy and Confusion MatrixAndrew Ferlitsch
Abstract: This PDSG workshop introduces basic concepts on measuring accuracy of your trained model. Concepts covered are loss functions and confusion matrices.
Level: Fundamental
Requirements: No prior programming or statistics knowledge required.
Abstract: This PDSG workshop introduces basic concepts of ensemble methods in machine learning. Concepts covered are Condercet Jury Theorem, Weak Learners, Decision Stumps, Bagging and Majority Voting.
Level: Fundamental
Requirements: No prior programming or statistics knowledge required.
Abstract: This PDSG workshop introduces basic concepts of multiple linear regression in machine learning. Concepts covered are Feature Elimination and Backward Elimination, with examples in Python.
Level: Fundamental
Requirements: Should have some experience with Python programming.
Abstract: This PDSG workshop introduces basic concepts of simple linear regression in machine learning. Concepts covered are Slope of a Line, Loss Function, and Solving Simple Linear Regression Equation, with examples.
Level: Fundamental
Requirements: No prior programming or statistics knowledge required.
Abstract: This PDSG workshop introduces basic concepts of categorical variables in training data. Concepts covered are dummy variable conversion, and dummy variable trap.
Level: Fundamental
Requirements: No prior programming or statistics knowledge required.
Abstract: This PDSG workshop introduces basic concepts of splitting a dataset for training a model in machine learning. Concepts covered are training, test and validation data, serial and random splitting, data imbalance and k-fold cross validation.
Level: Fundamental
Requirements: No prior programming or statistics knowledge required.
Dataset Preparation
Abstract: This PDSG workshop introduces basic concepts on preparing a dataset for training a model. Concepts covered are data wrangling, replacing missing values, categorical variable conversion, and feature scaling.
Level: Fundamental
Requirements: No prior programming or statistics knowledge required.
Abstract: This PDSG workshop introduces basic concepts on TensorFlow. The course covers fundamentals. Concepts covered are Vectors/Matrices/Vectors, Design&Run, Constants, Operations, Placeholders, Bindings, Operators, Loss Function and Training.
Level: Fundamental
Requirements: Some basic programming knowledge is preferred. No prior statistics background is required.
Abstract: This PDSG workshop introduces basic concepts on machine learning. The course covers fundamentals of Supervised and Unsupervised Learning, Decision Trees, Pruning, Ensemble Trees, Linear Regressions, Loss Functions, K-means, and dataset preparation.
Level: Fundamental
Requirements: No prior programming or statistics knowledge required.
6th Power Grid Model Meetup
Join the Power Grid Model community for an exciting day of sharing experiences, learning from each other, planning, and collaborating.
This hybrid in-person/online event will include a full day agenda, with the opportunity to socialize afterwards for in-person attendees.
If you have a hackathon proposal, tell us when you register!
About Power Grid Model
The global energy transition is placing new and unprecedented demands on Distribution System Operators (DSOs). Alongside upgrades to grid capacity, processes such as digitization, capacity optimization, and congestion management are becoming vital for delivering reliable services.
Power Grid Model is an open source project from Linux Foundation Energy and provides a calculation engine that is increasingly essential for DSOs. It offers a standards-based foundation enabling real-time power systems analysis, simulations of electrical power grids, and sophisticated what-if analysis. In addition, it enables in-depth studies and analysis of the electrical power grid’s behavior and performance. This comprehensive model incorporates essential factors such as power generation capacity, electrical losses, voltage levels, power flows, and system stability.
Power Grid Model is currently being applied in a wide variety of use cases, including grid planning, expansion, reliability, and congestion studies. It can also help in analyzing the impact of renewable energy integration, assessing the effects of disturbances or faults, and developing strategies for grid control and optimization.
Maxx nft market place new generation nft marketing placeusersalmanrazdelhi
PREFACE OF MAXXNFT
MaxxNFT: Powering the Future of Digital Ownership
MaxxNFT is a cutting-edge Web3 platform designed to revolutionize how
digital assets are owned, traded, and valued. Positioned at the forefront of the
NFT movement, MaxxNFT views NFTs not just as collectibles, but as the next
generation of internet equity—unique, verifiable digital assets that unlock new
possibilities for creators, investors, and everyday users alike.
Through strategic integrations with OKT Chain and OKX Web3, MaxxNFT
enables seamless cross-chain NFT trading, improved liquidity, and enhanced
user accessibility. These collaborations make it easier than ever to participate
in the NFT ecosystem while expanding the platform’s global reach.
With a focus on innovation, user rewards, and inclusive financial growth,
MaxxNFT offers multiple income streams—from referral bonuses to liquidity
incentives—creating a vibrant community-driven economy. Whether you
'
re
minting your first NFT or building a digital asset portfolio, MaxxNFT empowers
you to participate in the future of decentralized value exchange.
https://maxxnft.xyz/
As data privacy regulations become more pervasive across the globe and organizations increasingly handle and transfer (including across borders) meaningful volumes of personal and confidential information, the need for robust contracts to be in place is more important than ever.
This webinar will provide a deep dive into privacy contracting, covering essential terms and concepts, negotiation strategies, and key practices for managing data privacy risks.
Whether you're in legal, privacy, security, compliance, GRC, procurement, or otherwise, this session will include actionable insights and practical strategies to help you enhance your agreements, reduce risk, and enable your business to move fast while protecting itself.
This webinar will review key aspects and considerations in privacy contracting, including:
- Data processing addenda, cross-border transfer terms including EU Model Clauses/Standard Contractual Clauses, etc.
- Certain legally-required provisions (as well as how to ensure compliance with those provisions)
- Negotiation tactics and common issues
- Recent lessons from recent regulatory actions and disputes
Protecting Your Sensitive Data with Microsoft Purview - IRMS 2025Nikki Chapple
Session | Protecting Your Sensitive Data with Microsoft Purview: Practical Information Protection and DLP Strategies
Presenter | Nikki Chapple (MVP| Principal Cloud Architect CloudWay) & Ryan John Murphy (Microsoft)
Event | IRMS Conference 2025
Format | Birmingham UK
Date | 18-20 May 2025
In this closing keynote session from the IRMS Conference 2025, Nikki Chapple and Ryan John Murphy deliver a compelling and practical guide to data protection, compliance, and information governance using Microsoft Purview. As organizations generate over 2 billion pieces of content daily in Microsoft 365, the need for robust data classification, sensitivity labeling, and Data Loss Prevention (DLP) has never been more urgent.
This session addresses the growing challenge of managing unstructured data, with 73% of sensitive content remaining undiscovered and unclassified. Using a mountaineering metaphor, the speakers introduce the “Secure by Default” blueprint—a four-phase maturity model designed to help organizations scale their data security journey with confidence, clarity, and control.
🔐 Key Topics and Microsoft 365 Security Features Covered:
Microsoft Purview Information Protection and DLP
Sensitivity labels, auto-labeling, and adaptive protection
Data discovery, classification, and content labeling
DLP for both labeled and unlabeled content
SharePoint Advanced Management for workspace governance
Microsoft 365 compliance center best practices
Real-world case study: reducing 42 sensitivity labels to 4 parent labels
Empowering users through training, change management, and adoption strategies
🧭 The Secure by Default Path – Microsoft Purview Maturity Model:
Foundational – Apply default sensitivity labels at content creation; train users to manage exceptions; implement DLP for labeled content.
Managed – Focus on crown jewel data; use client-side auto-labeling; apply DLP to unlabeled content; enable adaptive protection.
Optimized – Auto-label historical content; simulate and test policies; use advanced classifiers to identify sensitive data at scale.
Strategic – Conduct operational reviews; identify new labeling scenarios; implement workspace governance using SharePoint Advanced Management.
🎒 Top Takeaways for Information Management Professionals:
Start secure. Stay protected. Expand with purpose.
Simplify your sensitivity label taxonomy for better adoption.
Train your users—they are your first line of defense.
Don’t wait for perfection—start small and iterate fast.
Align your data protection strategy with business goals and regulatory requirements.
💡 Who Should Watch This Presentation?
This session is ideal for compliance officers, IT administrators, records managers, data protection officers (DPOs), security architects, and Microsoft 365 governance leads. Whether you're in the public sector, financial services, healthcare, or education.
🔗 Read the blog: https://nikkichapple.com/irms-conference-2025/
Neural representations have shown the potential to accelerate ray casting in a conventional ray-tracing-based rendering pipeline. We introduce a novel approach called Locally-Subdivided Neural Intersection Function (LSNIF) that replaces bottom-level BVHs used as traditional geometric representations with a neural network. Our method introduces a sparse hash grid encoding scheme incorporating geometry voxelization, a scene-agnostic training data collection, and a tailored loss function. It enables the network to output not only visibility but also hit-point information and material indices. LSNIF can be trained offline for a single object, allowing us to use LSNIF as a replacement for its corresponding BVH. With these designs, the network can handle hit-point queries from any arbitrary viewpoint, supporting all types of rays in the rendering pipeline. We demonstrate that LSNIF can render a variety of scenes, including real-world scenes designed for other path tracers, while achieving a memory footprint reduction of up to 106.2x compared to a compressed BVH.
https://arxiv.org/abs/2504.21627
Nix(OS) for Python Developers - PyCon 25 (Bologna, Italia)Peter Bittner
How do you onboard new colleagues in 2025? How long does it take? Would you love a standardized setup under version control that everyone can customize for themselves? A stable desktop setup, reinstalled in just minutes. It can be done.
This talk was given in Italian, 29 May 2025, at PyCon 25, Bologna, Italy. All slides are provided in English.
Original slides at https://slides.com/bittner/pycon25-nixos-for-python-developers
Measuring Microsoft 365 Copilot and Gen AI SuccessNikki Chapple
Session | Measuring Microsoft 365 Copilot and Gen AI Success with Viva Insights and Purview
Presenter | Nikki Chapple 2 x MVP and Principal Cloud Architect at CloudWay
Event | European Collaboration Conference 2025
Format | In person Germany
Date | 28 May 2025
📊 Measuring Copilot and Gen AI Success with Viva Insights and Purview
Presented by Nikki Chapple – Microsoft 365 MVP & Principal Cloud Architect, CloudWay
How do you measure the success—and manage the risks—of Microsoft 365 Copilot and Generative AI (Gen AI)? In this ECS 2025 session, Microsoft MVP and Principal Cloud Architect Nikki Chapple explores how to go beyond basic usage metrics to gain full-spectrum visibility into AI adoption, business impact, user sentiment, and data security.
🎯 Key Topics Covered:
Microsoft 365 Copilot usage and adoption metrics
Viva Insights Copilot Analytics and Dashboard
Microsoft Purview Data Security Posture Management (DSPM) for AI
Measuring AI readiness, impact, and sentiment
Identifying and mitigating risks from third-party Gen AI tools
Shadow IT, oversharing, and compliance risks
Microsoft 365 Admin Center reports and Copilot Readiness
Power BI-based Copilot Business Impact Report (Preview)
📊 Why AI Measurement Matters: Without meaningful measurement, organizations risk operating in the dark—unable to prove ROI, identify friction points, or detect compliance violations. Nikki presents a unified framework combining quantitative metrics, qualitative insights, and risk monitoring to help organizations:
Prove ROI on AI investments
Drive responsible adoption
Protect sensitive data
Ensure compliance and governance
🔍 Tools and Reports Highlighted:
Microsoft 365 Admin Center: Copilot Overview, Usage, Readiness, Agents, Chat, and Adoption Score
Viva Insights Copilot Dashboard: Readiness, Adoption, Impact, Sentiment
Copilot Business Impact Report: Power BI integration for business outcome mapping
Microsoft Purview DSPM for AI: Discover and govern Copilot and third-party Gen AI usage
🔐 Security and Compliance Insights: Learn how to detect unsanctioned Gen AI tools like ChatGPT, Gemini, and Claude, track oversharing, and apply eDLP and Insider Risk Management (IRM) policies. Understand how to use Microsoft Purview—even without E5 Compliance—to monitor Copilot usage and protect sensitive data.
📈 Who Should Watch: This session is ideal for IT leaders, security professionals, compliance officers, and Microsoft 365 admins looking to:
Maximize the value of Microsoft Copilot
Build a secure, measurable AI strategy
Align AI usage with business goals and compliance requirements
🔗 Read the blog https://nikkichapple.com/measuring-copilot-gen-ai/
Introduction and Background:
Study Overview and Methodology: The study analyzes the IT market in Israel, covering over 160 markets and 760 companies/products/services. It includes vendor rankings, IT budgets, and trends from 2025-2029. Vendors participate in detailed briefings and surveys.
Vendor Listings: The presentation lists numerous vendors across various pages, detailing their names and services. These vendors are ranked based on their participation and market presence.
Market Insights and Trends: Key insights include IT market forecasts, economic factors affecting IT budgets, and the impact of AI on enterprise IT. The study highlights the importance of AI integration and the concept of creative destruction.
Agentic AI and Future Predictions: Agentic AI is expected to transform human-agent collaboration, with AI systems understanding context and orchestrating complex processes. Future predictions include AI's role in shopping and enterprise IT.
UiPath Community Berlin: Studio Tips & Tricks and UiPath InsightsUiPathCommunity
Join the UiPath Community Berlin (Virtual) meetup on May 27 to discover handy Studio Tips & Tricks and get introduced to UiPath Insights. Learn how to boost your development workflow, improve efficiency, and gain visibility into your automation performance.
📕 Agenda:
- Welcome & Introductions
- UiPath Studio Tips & Tricks for Efficient Development
- Best Practices for Workflow Design
- Introduction to UiPath Insights
- Creating Dashboards & Tracking KPIs (Demo)
- Q&A and Open Discussion
Perfect for developers, analysts, and automation enthusiasts!
This session streamed live on May 27, 18:00 CET.
Check out all our upcoming UiPath Community sessions at:
👉 https://community.uipath.com/events/
Join our UiPath Community Berlin chapter:
👉 https://community.uipath.com/berlin/
Evaluation Challenges in Using Generative AI for Science & Technical ContentPaul Groth
Evaluation Challenges in Using Generative AI for Science & Technical Content.
Foundation Models show impressive results in a wide-range of tasks on scientific and legal content from information extraction to question answering and even literature synthesis. However, standard evaluation approaches (e.g. comparing to ground truth) often don't seem to work. Qualitatively the results look great but quantitive scores do not align with these observations. In this talk, I discuss the challenges we've face in our lab in evaluation. I then outline potential routes forward.
Exploring the advantages of on-premises Dell PowerEdge servers with AMD EPYC processors vs. the cloud for small to medium businesses’ AI workloads
AI initiatives can bring tremendous value to your business, but you need to support your new AI workloads effectively. That means choosing the best possible infrastructure for your needs—and many companies are finding that the cloud isn’t right for them. According to a recent Rackspace survey of IT executives, 69 percent of companies have moved some of their applications on-premises from the cloud, with half of those citing security and compliance as the reason and 44 percent citing cost.
On-premises solutions provide a number of advantages. With full control over your security infrastructure, you can be certain that all compliance requirements remain firmly in the hands of your IT team. Opting for on-premises also gives you the ability to design your infrastructure to the precise needs of that team and your new AI workloads. Depending on the workload, you may also see performance benefits, along with more predictable costs. As you start to build your next AI initiative, consider an on-premises solution utilizing AMD EPYC processor-powered Dell PowerEdge servers.
Contributing to WordPress With & Without Code.pptxPatrick Lumumba
Contributing to WordPress: Making an Impact on the Test Team—With or Without Coding Skills
WordPress survives on collaboration, and the Test Team plays a very important role in ensuring the CMS is stable, user-friendly, and accessible to everyone.
This talk aims to deconstruct the myth that one has to be a developer to contribute to WordPress. In this session, I will share with the audience how to get involved with the WordPress Team, whether a coder or not.
We’ll explore practical ways to contribute, from testing new features, and patches, to reporting bugs. By the end of this talk, the audience will have the tools and confidence to make a meaningful impact on WordPress—no matter the skill set.
European Accessibility Act & Integrated Accessibility TestingJulia Undeutsch
Emma Dawson will guide you through two important topics in this session.
Firstly, she will prepare you for the European Accessibility Act (EAA), which comes into effect on 28 June 2025, and show you how development teams can prepare for it.
In the second part of the webinar, Emma Dawson will explore with you various integrated testing methods and tools that will help you improve accessibility during the development cycle, such as Linters, Storybook, Playwright, just to name a few.
Focus: European Accessibility Act, Integrated Testing tools and methods (e.g. Linters, Storybook, Playwright)
Target audience: Everyone, Developers, Testers
Introducing FME Realize: A New Era of Spatial Computing and ARSafe Software
A new era for the FME Platform has arrived – and it’s taking data into the real world.
Meet FME Realize: marking a new chapter in how organizations connect digital information with the physical environment around them. With the addition of FME Realize, FME has evolved into an All-data, Any-AI Spatial Computing Platform.
FME Realize brings spatial computing, augmented reality (AR), and the full power of FME to mobile teams: making it easy to visualize, interact with, and update data right in the field. From infrastructure management to asset inspections, you can put any data into real-world context, instantly.
Join us to discover how spatial computing, powered by FME, enables digital twins, AI-driven insights, and real-time field interactions: all through an intuitive no-code experience.
In this one-hour webinar, you’ll:
-Explore what FME Realize includes and how it fits into the FME Platform
-Learn how to deliver real-time AR experiences, fast
-See how FME enables live, contextual interactions with enterprise data across systems
-See demos, including ones you can try yourself
-Get tutorials and downloadable resources to help you start right away
Whether you’re exploring spatial computing for the first time or looking to scale AR across your organization, this session will give you the tools and insights to get started with confidence.
3. Coding Challenge
• Python Language Constructs Covered:
1. Main body
2. Indentation
3. Print
4. Line Comments
5. For loop – Range and Steps
6. If / else
7. Integer conversion
Prime Numbers
4. Prime Numbers
• Prime numbers are numbers that are only divisible by one and itself.
• Iterative Algorithm
1. For each number, we attempt to divide it by every number less than it, except for one.
2. The integer modulo operator is used to test if there is a remainder from the integer
division.
3. If there is no remainder, it is divisible by the number and therefore not a prime.
4. If each of the numbers it is divided by has a remainder, it is a prime.
print(“1)
print(“2”)
# Primes for numbers above 2
for number in range(3, 101):
# Attempt to divide this number by every number between 2 and one less than itself
for div in range(2, number):
if (number % div) == 0:
break
else:
print(number)
Range is always one less than the endpoint
Else clause is triggered when for loop does not complete all loops (i.e., break)
5. Prime Numbers – Skip Even Numbers
• Improvement:
1. Skip all even numbers, since they are divisible by two.
2. Odd numbers are not divisible by two, so skip dividing by even numbers.
print(“1)
print(“2”)
Print(“3”)
# Primes for numbers above 5
for number in range(5, 101, 2):
# Attempt to divide this number by every number between 3 and one less than itself
for div in range(3, number, 2):
if (number % div) == 0:
break
else:
print(number)
Step thru range in increments of 2 (odd numbers)
6. Prime Numbers – Skip Even Numbers, Divide by only
1/3 of range
• Improvement:
1. Since we are skipping evens, each prime must be divisible by at least the number 3.
2. So a prime must be divisible by 1/3 of less of itself.
print(“1)
print(“2”)
Print(“3”)
# Primes for numbers above 5
for number in range(5, 101, 2):
third = int(number / 3) + 1
# Attempt to divide this number by every number between 3 and 1/3 of itself
for div in range(3, third, 2):
if (number % div) == 0:
break
else:
print(number)
Round result to an integer
7. Coding Challenge
• Python Language Constructs Covered:
1. Function Definition
2. Iterative vs. Recursion
3. Variable Initialization
4. Return values
Fibonacci Sequence
8. Fibonacci Sequence – Recursive
• A Fibonacci sequence is F(n) = F(n-1) + F(n-2)
• Recursive Algorithm
1. Where F(0) = 0, F(1) = 1
2. F(n) = F(n-1) + F(n-2), where n >= 2
def fibonacci(n):
# Where F(0) = 0, F(1) = 1
if n == 0:
return 0
if n == 1:
return 1
# Recursion when n >= 2
return fibonacci(n – 1) + fibonacci(n – 2)
Recursion
Function Definition
9. Fibonacci Sequence - Iterative
• Iterative Algorithm
1. Where F(0) = 0, F(1) = 1
2. F(n) = F(n-1) + F(n-2), where n >= 2
def fibonacci(n):
# Where F(0) = 0, F(1) = 1
if n == 0:
return 0
if n == 1:
return 1
fn = 0 # current value for F(n)
f_minus_1 = 1 # current value for F(n-1)
f_minus_2 = 0 # current value for F(n-2)
for i in range(2, n+1):
# F(n) = F(n-1) + F(n-2) for current iteration
fn = f_minus_1 + f_minus_2
# Calculate F(n-1) and F(n-2) for next iteration
f_minus_2 = f_minus_1
f_minus_1 = fn
return fn
Initialize accumulators with n = 2
Range is always one less than the endpoint
Next F(n-1), F(n-2) would equal the current
F(n), F(n-1)
10. Coding Challenge
• Python Language Constructs Covered:
1. Static vs. Dynamic Array
2. Linked Lists
3. Class Definition
4. Class Constructor
5. Class Methods
6. Null (None) pointer
7. List Traversal
Dynamic Arrays
11. Dynamic Array
• An Array which can dynamically resize itself (i.e., linked list).
1. Add or Insert into the array (i.e., expand).
2. Remove any element in the array (i.e., shorten).
Static Array
0
Dynamically added element
3
1 2 3
Array is a contiguous block of memory,
with each element of fixed size.
Index of Element
Address of element is:
Address of start of array + ( index * element_size )
Dynamic Array
0 1 2
Link Link Link
Array is a non-contiguous block of memory,
With each element chained together by a link.
12. Dynamic Array
class Entry(object): # Definition for an array element
def __init__(self, data):
self.data = data # Entry data
self.link = None # Link to next Entry in Array
class Array(object):
def __init__(self):
self.array= None # initialize array to empty
# Add element an element to the end of the array
def add(self, data):
# Empty Array
if self.array is None:
self.array = Entry(data)
# Non-empty array
else:
# Find the last entry in the array
prev = self.array
while prev.link is not None:
prev = prev.link
# Add the element to the end of the list
prev.link = Entry( data )
Definition for an entry in
the dynamic array to hold
the entry data and link.
None is the null pointer.
Set array to a single entry
Remember last entry visited
In the linked list of entries.
When the link member is
None (null), you are at the
end of the linked list.
13. Dynamic Array - Improvement
class Array(object):
last = None # last entry in array
def __init__( self ):
self.array= None # initialize array to empty
# Add element an element to the end of the array
def add( self, data ):
entry = Entry( data )
# Empty Array
if self.last is None:
self.array = entry
# Non-empty array
else:
self.last.link = entry
# Set last entry to the newly added entry
self.last = entry
Keep location of last
entry in array.
14. Dynamic Array – Time Complexity
• Add
1. By maintaining pointer to the end, does not need to traverse the array
O(1)
• Find
1. Must traverse the links in the array (index-1) times for the index, where 0 < index < n
O(n/2) = O(n)
• Delete
1. Must traverse the links in the array (index-1) times for the index, where 0 < index < n
O(n/2) = O(n)
In complexity notation (Omega), multiplication and
division by a constant is removed
Omega
In complexity notation (Omega), 1 is used to represent
constant time.
In complexity notation (Omega), n is the number of
elements.
15. Coding Challenge
• Python Language Constructs Covered:
1. First In, First Out
2. Python Dynamic (builtin) Arrays
3. append() array method
4. len() object method
5. Copying elements
6. del operator
Queue
16. Queue
• FIFO (First In, First Out) – Data Structure
1. Enqueue – add an element to the back of the list
2. Dequeue – remove an element from the front of the list
x1
x2
Enqueue
Each element
is added to the
end of the queue
x2
Dequeue
x3
x3
Each element is
removed from the
front of the queue
x3 x1
17. Queue
class Queue(object):
def __init__(self):
self.queue = [] # initialize queue to empty dynamic array
# Add element to queue
def enqueue( self, element ):
self.queue.append( element )
# Remove element from front of the queue
def dequeue( self ):
# Empty Queue condition
if len( self.queue ) == 0:
return None
# Get (remember) the first element from the queue
element = self.queue[ 0 ]
# Remove (drop) the first element in the queue
del self.queue[ 0 ]
# Return the first element
return element
append() method adds an element to end of array/list.
len() function returns the number of
elements in an array/list.
Makes a local copy of the first element.
The del operator will remove an element
in an array/list at the specified location.
Notation for empty list/array.
18. Coding Challenge
• Python Language Constructs Covered:
1. Last In, Last Out
2. insert() array method
Stack
19. Stack
• LIFO (Last In, First Out) – Data Structure
1. Push – add an element to the front of the list
2. Pop – remove an element from the front of the list
x3
x2
Push
Each element is
added to the front
of the stack
x2
Pop
x1
x3
Each element is
removed from the
front of the stack
x3 x3
20. Stack
class Stack(object):
def __init__( self ):
self.stack = [] # initialize stack to empty dynamic array
# Add element to the stack
def push( self, element ):
self.stack.insert( 0, element )
# Remove element from front of the stack
def pop( self ):
# Empty Stack condition
if len( self.stack ) == 0:
return None
# Get (remember) the first element from the stack
element = self.stack[ 0 ]
# Remove (drop) the first element in the stack
del self.stack[ 0 ]
# Return the first element
return element
insert() method inserts an element to an array/list
at the specified index.
21. Coding Challenge
• Python Language Constructs Covered:
1. Importing a library
2. Prioritized Queue : heappush(), heappop()
Heap
22. Heap
• Prioritized Queue (Sorted by value) – Data Structure
1. Push – add an element to the sorted position in the list
2. Pop – remove an element from the front of the list
x3
x3
Push
Each element is
added at it’s
sorted location
In the queue
x2
Pop
x1
x3
Each element is
removed from the
front of the queue
x3 x3
23. Heap
from heapq import heappush, heappop
class Heap(object):
def __init__( self ):
self.heap = [] # initialize heap to empty dynamic array
# Add element to the (sorted) heap
def push( self, element ):
heappush( self.heap, element )
# Remove element from front of the (sorted) heap
def pop( self ):
# Empty Heap condition
if len( self.heap ) == 0:
return None
# Get the first element from the heap
element = heappop( self.heap )
# Return the first element
return element
heappush() function inserts an element to a sorted array/list.
Heappop() function removes the first element from a
sorted array/list.
Import the classes heappush and heappop
from the library heapq.
24. Queue, Stack, Heap -Time Complexity
• Queue
Enqueue O(1)
Dequeue O(1)
• Stack
Push O(1)
Pop O(1)
• Heap
Push O(n)
Pop O(1)
Must traverse array to find location
to insert.
25. Coding Challenge
• Python Language Constructs Covered:
1. Arithmetic Assignment
2. Recurring back in Recursion
StackChain
26. StackChain
• Chain of Stacks of Fixed Size
1. When an element is pushed to a stack that has reached its maximum (fixed) size, the
bottom of the stack is removed and pushed to the top of the next stack on the chain.
2. Likewise, when an element is popped from the stack, the top of the next stack that is
chained to it is popped and added to the bottom of the stack, and so forth.
x4
x3
Push
x2
x4
x1
Fixed Size
(e.g., 3) Removed
from the
bottom and
pushed to
top of the
next stack.
x3
Pop
x2
x3
x1
Removed
from the
top and
pushed to
top of the
previous stack.
27. StackChain
class StackChain(object):
def __init__( self, max ):
self.max = max # maximum size of a stack
self.stack = [] # initialize this stack to empty list/array.
self.chain = None # next stack in chain
# Add element to the stack chain
def push( self, element ):
self.stack.insert( 0, element )
# stack is less than full
if len( self.stack ) < self.max:
self.max += 1
# stack is full
else:
# Allocate the next stack in chain, if there is not one already.
if self.chain == None:
self.chain = stackChain( self.max )
# Get (remember) the element from the bottom of the stack
element = self.stack[ self.max - 1 ]
# Remove the element
del self.stack[ self.max - 1 ]
# push the element to the next stack in the chain
self.chain.stack.push( element )
No increment/decrement in Python.
Recursive call, will cascade
until the last stack in chain is less
than full.
28. StackChain
class StackChain(object):
# Remove element from the stack chain
def pop( self ):
# stack is empty
if len( self.stack ) == 0:
return None
# Get (Remember) top element in stack
element = self.stack[ 0 ]
# Remove the element from the stack
del self.stack[ 0 ]
# There is another stack in the chain
if self.chain is not None:
# Pop the top element from the next stack in the chain
bottom = pop( self.chain.stack )
# Add the element to the bottom of this stack
self.stack.append( bottom )
# Return the top of the stack
return element
Recursive call, will cascade to the last stack
and recur backwards moving the top of the
stack to the bottom of the previous stack.
29. Coding Challenge
• Python Language Constructs Covered:
1. Initializing size of an array
2. Recursive Sub-Solutions
Towers of Hanoi
30. Towers of Hanoi - Recursion
• Three Towers, stack of disks on start Tower, each disk smaller than
proceeding disk. Move the disks to the end Tower.
1. You move one disc at a time from the top of one tower to the top of another tower.
2. You can not place a larger disc on top of a smaller disc.
Start Intermediate End
Solve for N-1
Discs
Move disc N to End
StartIntermediate End
Move disc N to EndSolve for N-1
Discs
Recursion
31. Towers of Hanoi
class Hanoi(object):
towers = [ None ] * 3 # Initialize 3 towers with no discs on them
for i in range( 0, 3 ):
towers[ i ] = Stack()
def __init__(self, ndiscs ):
self.ndiscs = ndiscs # the number of discs
# initialize the first tower with discs in ascending order.
for i in range ( ndiscs, 0, -1 ):
self.towers[ 0 ].push( i )
# Recursive method to move ndiscs from start to end
def move( self, ndiscs, start, intermediate, end ):
# if single disk left, move it from start to end
if ndiscs == 1:
end.push( start.pop() )
else:
# move the remainder of the tower to the intermediate tower
self.move( ndiscs - 1, start, end, intermediate )
# move the bottom disc to the end tower
end.push( start.pop() )
# move the remainder of the intermediate tower to the end tower
self.move( ndiscs - 1, intermediate, start, end )
def play( self ):
self.move( self.ndiscs, self.towers[ 0 ], self.towers[ 1 ], self.towers[ 2 ] )
Can initialize class member variables
Outside of the constructor (__init__)
Notation for initializing an array of fixed
size (e.g., 3).
Recursively
solve
sub-problems
33. Binary Tree
• A Binary Tree is a type of directed graph tree where each node
contains at most two branches (subtrees), commonly referred to as
the left and right branch.
1. The recursive definition is a binary tree is either empty, a single node, where the left
and right branches are binary subtrees.
A
B C
D E
Left
Left
Root
Right
Right
Nodes
Leaves
Binary
subtree
34. Binary Tree
class BinaryTree(object):
# Constructor: set the node data and left/right subtrees to null
def __init__(self, key):
self.left = None # left binary subtree
self.right = None # right binary subtree
self.key = key # node data
# Get ot Set Left Binary Subtree
def Left(self, left = None):
if left is None:
return self.left
self.left = left
# Get or Set Right Binary Subtree
def Right(self, right = None):
if right is None:
return self.right
self.right = right
# Get ot Set Node Data
def Key(self, key = None):
if key is None:
return self.key
self.key = key
Good Practice to have
parent classes explicitly
Inherit the object class,
which all classes
implicitly inherit.
Default parameter. If
not specified, will
default to None.
Technique to emulate (fake) method overloading
using default parameter. If parameter not
specified, then it’s a getter[ otherwise (if
specified), it’s a setter.
35. Coding Challenge
• Python Language Constructs Covered:
1. is operator vs. ==
2. Default Parameters
3. Recursion (more)
4. Returning multiple values and Assignment of multiple
variables
Binary Tree Traversals
36. Binary Tree Traversals
• Binary Trees can be traversed either breadth first (BFS) or
depth first (DFS).
• Breadth First Search – tree is traversed one level at a time.
• The root node (level 1) is first visited, then the left node, then
the right node (level 2) of the root, and then the left and right
nodes of the these subtrees (level 3), and so forth.
• Depth First Search – tree is searched either inorder,
preorder, or postorder.
• Inorder : left (node), root, right
• Preorder : root, left, right
• Postorder: left, right, root
37. BFS Traversal
# Breadth First Search
def BFS( root ):
# Check if tree is empty
if root is None:
return
# list of nodes to visit in node level order
visit = []
visit.append( root )
# sequentially visit each node in level order as it is dynamically added to the list
i = 0
while i < len( visit ):
# Add to the list the child siblings of this node
if visit[ i ].Left() is not None:
visit.append( visit[ i ].Left() )
if visit[ i ].Right() is not None:
visit.append( visit[ i ].Right() )
i += 1
Visit is a dynamic array
Good practice when comparing
to None to use ‘is’ instead of ==
Good practice when comparing
to None to use ‘is not’ instead of
!=
38. DFS Traversal
Recursive Algorithms
# InOrder Traversal
def InOrder(root):
if root is None:
return
InOrder( root.Left() )
root.Action()
InOrder( root.Right() )
# PreOrder Traversal
def PreOrder(root):
if root is None:
return
root.Action()
PreOrder( root.Left() )
PreOrder( root.Right() )
# PostOrder Traversal
def PostOrder(root):
if root is None:
return
PostOrder( root.Left() )
PostOrder( root.Right() )
root.Action() The action to take when a node is visited.
Pre, In and Post refer to when
you visit the root (parent) node:
Pre = First
In = Middle
Post = Last
39. Binary Tree Max/Min Depth
• Binary Tree – Maximum/Minimum depth algorithm
1. Do a preorder traversal of the tree starting from the root.
2. When a node is visited, increment the depth count by 1.
3. Recursively apply the algorithm to the left and right nodes.
4. When returning from a child to a parent node, pass back the node depth of the child.
5. Return the maximum and minimum depth from the left and right child (or the parent if
there are no children).
A
B C
D E
Left
Left
Root
Right
Right
depth = 3 depth = 3
max = 3,
min = 3
max =2,
min = 2
max = 3,
min = 2
40. Binary Tree Maximum Depth
class BinaryTree(object):
# Maximum/Minimum depth of a binary tree
def MaxMinDepth( self, max ):
max += 1 # Increment by one level for the node
# Initialize the left and right branch max/min depth to the current max depth
lmax = lmin = max
rmax = rmin = max
# Calculate the maximum depth along the left binary subtree
if self.Left() is not None:
lmax, lmin = self.Left().MaxMinDepth( max )
# Calculate the maximum depth along the left binary subtree
if self.Right() is not None:
rmax , rmin = self.Right().MaxMinDepth( max )
# return the greater (max) and lessor (min) of the left and right subtrees
return ( rmax if rmax > lmax else lmax ), ( rmin if rmin < lmin else lmin )
Ternary conditional operator:
true_clause if condition else false_clause
Visited the root first.
Return max and min as a list
Can assign multiple
values on LHS
when list is returned.
41. Binary Tree Max/Min Value
• Binary Tree – Maximum/Minimum depth algorithm
1. Use either BFS or DFS/postorder traversal
2. Postorder: Recursively apply the algorithm to the left and right nodes.
3. When returning from a child to a parent node, pass back the max/min of the child.
4. Return the maximum or minimum value from the left and right child and parent.
5
4 3
5 8
Left
Left
Root
Right
Right
max = 5,
min = 5
max = 8,
min = 8
max = 8,
min = 4
max = 5,
min = 3
max = 8,
min = 3
42. Binary Tree Max/Min Value
class BinaryTree(object):
# Maximum/Minimum of a binary tree
def MaxMinValue( self ):
# Initialize the left and right branch max/min values to +/- infinity
lmax = rmax = -2147483647
lmin = rmin = 2147483648
# Calculate the maximum depth along the left binary subtree
if self.Left() is not None:
lmax, lmin = self.Left().MaxMinValue( )
# Calculate the maximum depth along the left binary subtree
if self.Right() is not None:
rmax , rmin = self.Right().MaxMinValue( )
# Compare max/min of child with parent
if rmax < self.Value():
rmax = self.Value()
if rmin > self.Value():
rmin = self.Value()
# return the greater (max) and lessor (min) of the left and right subtrees
return ( rmax if rmax > lmax else lmax ), ( rmin if rmin < lmin else lmin )
Visited the root last
43. Coding Challenge
• Python Language Constructs Covered:
1. Ternary Conditional operator
2. Local Variables
3. elif statement
4. Removing Links
Binary Search Tree
44. Binary Search Tree - Insert
• Binary Search Tree – Insert algorithm
1. A sorted tree where at each node, the data value of the left branch (child) is less than
the data value of the node, and the right node is greater than, and where there are
no duplicate values.
1. Insert: if the root is null (None), add it as the root; otherwise, traverse the tree.
2. If the value is less than the node (branch), traverse left; otherwise traverse right.
3. If there is no node (branch) to traverse, then add it as a new node.
6
4 8
2 5
Left
Left
Root
Right
Right
7
Left
7
Insert
7 > 6, go right
7 < 8, go left
No node, insert
45. Binary Search Tree - Insert
class BinarySearchTree(object):
root = None # root of the search tree
# Insert a node into a binary search tree
def Insert( self, node ):
# If tree is empty, make the root the first node
if self.root is None:
self.root = node
return
# Follow a path to insert the node
curr = self.root
while True:
# if value is less than node, traverse left branch
if node.value < curr.value:
# if no left branch, set node as left branch
if curr.Left() is None:
curr.Left( node )
return
curr = curr.Left()
# otherwise, traverse right branch :
elif curr.Right() is None:
curr.Right( node )
return
else:
curr = curr.Right()
Local variable, created
on first use.
Loop forever
Format of:
else if statement
Add code here to
check for duplicate
46. Binary Search Tree - Find
• Binary Search Tree – Find algorithm
1. If the root is null (None), return None.
2. If value is equal to the node, return the node.
3. If the value is less than the node (branch), traverse left; otherwise traverse right.
4. If there is no node (branch) to traverse, then return None.
6
4 8
2 5
Left
Left
Root
Right
Right
7
Left
Find value = 7
7 > 6, go right
7 < 8, go left
Node Found
47. Binary Search Tree - Find
class BinarySearchTree(object):
root = None # root of the search tree
# Find a node into a binary search tree
def Find( self, value ):
# If tree is empty, return None
if self.root is None:
return None
# Follow a path to find the node
curr = self.root
while True:
# Node Found
if curr.value == value:
return curr
# if value is less than node, traverse left branch
if value < curr.value:
# if no left branch, return not found
if curr.Left() is None:
return None
curr = curr.Left()
# otherwise, traverse right branch :
elif curr.Right() is None:
return None
else:
curr = curr.Right()
48. Binary Search Tree - Delete
• Binary Search Tree – Delete algorithm
1. If the root is null (None), return.
2. While remembering the parent node, If the value is less than the node (branch),
traverse left; otherwise traverse right.
3. If the value equals the node value, set the parent left branch to null if left branch;
Otherwise set parent right branch to null.
4. Reinsert the left and right branches of the removed node.
6
4 8
2 5
Left
Left
Root
Right
Right
7
Left
Remove value = 8
7 > 6, go right
Parent = 6
Remove Link
6
4
2 5
Left
Left
Right
Right
7
Reinserted
Node
49. Binary Search Tree - Delete
class BinarySearchTree(object):
root = None # root of the search tree
# Find a node into a binary search tree
def Delete( self, value ):
# If tree is empty, return None
if self.root is None:
return None
# Follow a path to find the node to delete
curr = self.root
prev = self.root
while True:
# Node Found
if curr.value == value:
if left == True: # delete the left branch of the parent
prev.left = None
else: # delete the right branch of the parent
prev.right = None
if curr.Left(): # re-insert left branch of deleted node
self.Insert( curr.left )
if curr.Right(): # re-insert right branch of delete node
self.Insert( curr.right )
return
# if value is less than node, traverse left branch
if value < curr.value:
# if no left branch, return not found
if curr.Left() is None:
return None
curr = curr.Left()
left = True # traversed left branch
# otherwise, traverse right branch :
elif curr.Right() is None:
return None
else:
curr = curr.Right()
left = False # traversed right branch
51. Arithmetic - Multiply
• Algorithm to implement multiply with only addition
and equality operator.
1. Initialize accumulators for result and repeat to 0.
2. Loop indefinitely for ‘x * y’
1. If repeat accumulator equals zero, stop.
2. Increment the repeat accumulator by one.
3. Add x to the result.
Repeaty ->
y > 0
result
No
Yes y-- result += x
52. Arithmetic - Multiply
def Mul( x, y ):
# multiple by a negative number
if y < 0:
y = -y # turn y into positive number for loop increment
x = -x # turn x into negative number for result accumulator
# repeat adding x to result y times
result = 0
for i in range( 0, y ):
result += x
return result
53. Arithmetic - Exponent
• Algorithm to implement exponent with only addition
and equality operator.
1. If the exponent is zero, return 1.
2. Initialize accumulators for result and repeat to 0.
3. Loop indefinitely for 'x power e‘
1. If repeat accumulator equals zero, stop.
2. Increment the repeat accumulator by one.
3. Update the result to Mul( result, x ).
Repeaty ->, result = 1
y > 0
result
No
Yes y-- result = Mul(result, x)
54. Arithmetic - Exponent
def Exp( x, y ):
# initialize result to 1
result = 1
# repeat multiplying result by x, y times
for i in range( 0, y ):
result = Mul( result, x )
return result
Does not handle negative exponents.
55. GCD – Iterative Solution
• Euclid’s Algorithm for Greatest Common Denominator
1. Calculate the remainder of dividing the 2nd number by the first number (y % x).
2. Swap the value of the first number (x) with the second number (y).
3. Set the second number (y) to the remainder.
4. Iteratively repeat the process until the 2nd number (y) is zero.
5. Return the value of first number (x) when the 2nd number is zero (y).
Repeatx, y ->
y > 0
x
No
rem = y % x
x = y; y = rem
Yes
56. Arithmetic – GCD Iterative
def GCD( x, y ):
# continue until the division of of the two numbers does not leave a remainder (evenly divisible)
while y > 0:
# calculate the remainder of the division by between x and y
remainder = ( y % x )
# swap the value of x with y
x = y
# set y to the remainder
y = remainder
return x
57. GCD – Recursive Solution
• Euclid’s Algorithm for Greatest Common Denominator
1. When the 2nd number (y) is reduced to zero, return the current value of the first
number (x).
2. Otherwise, swap the first number (x) with the second number (y) and set the 2nd
number (y) to the remainder of the division of the 2nd number by the first number (x % y).
3. Recursively call GCD() with the updated first and second numbers.
GCDx, y ->
y > 0
x
No
Yes rem = y % x
x = y; y = rem
Call
GCD(x,
y)
58. Arithmetic – GCD Recursive
def GCDR( x, y ):
# return the current value of x when y is reduced to zero.
if y == 0:
return x
# recursive call, swapping x with y, and setting y to remainder of y divided by x
return GCDR( y, ( y % x ) )
59. LCM
• Euclid’s Algorithm for Least Common Multiple
1. Multiple the first and second number.
2. Divide the result by the GCD of the two numbers.
LCMx, y ->
x
mul = x * y
Result = mul / GCD(x,y)
62. Bubble Sort
• Bubble Sort Algorithm
1. Make a pass through the list of values.
• Compare adjacent values.
• If the first value is less than the second value, swap the values.
2. If one of more values were swapped, repeat the process of making a pass through the
list.
4 2 1 3
Forward Scan
2 4 1 3 2 1 4 3 2 1 3 4
2 1 3 4 1 2 3 4
Repeat Cycle
1 2 3 4 1 2 3 4
63. Bubble Sort
def BubbleSort( data ):
length = len( data )
swapped = True
# continue to repeat until no more adjacent values are swapped
while swapped:
swapped = False
# Make a scan through the list
for i in range( 0, length - 1 ):
# Compare adjacent values. If the first value > second value, swap the values.
if data[ i ] > data[ i + 1 ]:
swap = data[ i ]
data[ i ] = data[ i + 1 ]
data[ i + 1 ] = swap
swapped = True
return data
Since we are comparing index with
index + 1, we stop one entry short
of the end of the array.
Swap: 1. save the first element in a
temporary variable.
2. Set the first element to the
value of the second element.
3. Set the second element to the
value of the temporary variable
(which was the former value of
first element).
Space Complexity: O(1) – except for swap variable, no extra space needed
Time Complexity : O(n2) – n is number of elements, n scans * n elements.
65. Insertion Sort
• Insertion Sort Algorithm
1. Iterate through the list of elements.
• Scan through the list one element at a time.
• From current element, move backwards to the beginning, swapping adjacent
elements when not sorted.
4 3 2 1
Forward Scan
3 4 2 1 2 3 4 1 1 2 3 4
3 2 4 1Move Backwards 2 3 1 4
2 1 3 4
66. Insertion Sort
def InsertionSort( data ):
length = len( data )
# iterate through the list for each element except the first element
for i in range( 1, length ):
# starting with the current element, remove/insert proceeding
# elements so they are in sorted order
for j in range( i, 0, -1):
# swap adjacent elements
if data[ j ] < data[ j - 1 ]:
temp = data[ j ]
data[ j ] = data[ j -1 ]
data[ j - 1 ] = temp
return data
Start at position 1,
not 0 – nothing to
swap with at first
element.
Space Complexity: O(1) – except for swap variable, no extra space needed
Time Complexity : O(n2) – n is number of elements, n scans * n elements.
Descending count
in for loop. Loop
from ‘n’ to 0 in -1
(descend) steps.
67. Quick Sort
• Quick Sort Algorithm
1. Calculate a midpoint in the list. The value at the midpoint is the pivot value.
2. Move all values in the first partition that are not less than the pivot to the second
partition.
3. Move all values in the second partition that are not greater than or equal to the pivot
to the first partition.
4. Recursively apply the algorithm to the two partitions.
3 2 4 5 18 67
3 21 5 8 674
21 3 4 65 7 8
68. Quick Sort
def QuickSort( data ):
qSort( data, 0, len( data ) - 1 )
return data
def qSort( data, low, high ):
i = low # starting lower index
j = high # starting higher index
mid = int( low + ( high - low ) / 2 ) # midway index
pivot = data[ mid ] # pivot, value at the midway index
# Divide the array into two partitions
while i <= j:
# keep advancing (ascending) the lower index until we find a value that is not less than the pivot
# we will move this value to the right half partition.
while data[ i ] < pivot:
i += 1
# keep advancing (descending) the higher index until we find a value that is not greater than the pivot
# we will move this value to the left half partition.
while data[ j ] > pivot:
j -= 1
# if the lower index has past the higher index, there is no values to swap
# otherwise, swap the values and continue
if i <= j:
# swap the higher than pivot value on the left side with the lower than pivot value on the right side
temp = data[ i ]
data[ i ] = data[ j ]
data[ j ] = temp
# advance the lower and higher indexes accordingly and continue
i += 1
j -= 1
# recursively sort the two partitions if the index has not crossed over the pivot index
if low < j:
qSort( data, low, j )
if i < high:
qSort( data, i, high )
69. Merge Sort
• Merge Sort Algorithm
1. Allocate space for a temporary copy of the array.
2. Recursively split the data into two partitions (halves), until each partition is a
single element.
3. Merge and sort each pair of partitions.
2 3 4 5 61 87
3 42 1 5 768
83 2 4 51 6 7
Split into
halves
38 2 4 15 7 6
Merge halves
and sort
70. Merge Sort
def MergeSort( data ):
# allocate space for a temporary copy of the data
tdata = [ 0 ] * len( data );
# sort the data (pass in the temporary copy so routine is thread safe)
mSort( data, 0, len( data ) - 1, tdata )
return data
def mSort( data, low, high, tdata ):
# if the partition has more than one element, then recursively divide the partition and merge the parts back in
if low < high:
mid = int( low + ( high - low ) / 2 ) # midway index
# sort the lower (first) half partition
mSort( data, low, mid, tdata )
# sort the upper (second) half partition
mSort( data, mid + 1, high, tdata )
# merge the partitions together
merge( data, low, mid, high, tdata )
def merge( data, low, mid, high, tdata ):
# make a temporary copy of the two separately sorted partitions
for i in range( low, high + 1 ):
tdata[ i ] = data[ i ]
# starting from the beginning of the first partition, iteratively search for the next lowest
# number from the lower (first) and higher (second) and move into current position in the
# lower (first) partition
i = low
k = low
j = mid + 1
while i <= mid and j <= high:
if tdata[ i ] <= tdata[ j ]:
data[ k ] = tdata[ i ]
i += 1
else:
data[ k ] = tdata[ j ]
j += 1
k += 1
# Copy any remaining elements back into the first partition
while i <= mid:
data[ k ] = tdata[ i ]
k += 1
i += 1
Logical operators are the
keywords:
and
or
71. Quick / Sort Merge - Complexity
• Merge
Space Complexity: O(n)
Time Complexity : O(n * logn)
• Quick
Space Complexity: O(n)
Time Complexity : O(n * logn)
72. Coding Challenge
• Python Language Constructs Covered:
1. Modulo Operator
2. Squashing into a range
3. Collision Handling
4. Complexity
Hashing
73. Hashing
• Hashing is used to solve indexing lookups without the overhead of
sequential scanning and name comparisons. The most basic use of
hashing is insertion and lookup in a key-value(s) dictionary.
• Common Issues:
1. Handling of collisions when two keys mapped to the same index.
2. Efficiency of the hashing algorithm.
3. The frequency of collisions.
4. The sparseness of the memory allocated for the index.
74. Integer Hash
• Integer Hash Algorithm
1. Map each integer value into a smaller fixed size integer range using the modulo operator.
2. If there is no entry at the index, add the key/value to the index as the first entry in the
chain.
3. If there are entries there, and the key is the same as one of the entries (duplicate),
update the value.
4. If there are entries there, and the key is not the same (collision) as any entry, add the key
to the chain of entries.
0
1
2
3
4
n
***
Range
None (no entry at index)
A
A B
Single Entry (no collision)
Chain of Entries (collisions)
Index = (key % range)
75. Integer Hash (part 1)
class Hash( object ):
RANGE = 0 # the range of the index.
index = [] # the index
# constructor
def __init__( self, range ):
# set the index range and allocate the index
self.RANGE = range
self.index = [None] * self.RANGE
# Map the key into an index within the set range
def Index( self, key ):
return key % self.RANGE
Module operator, returns the
remainder of an integer division.
76. Integer Hash (part 2)
class Hash( object ):
# Add a key/value entry to the index
def Add( self, key, value ):
ix = self.Index( key )
# there is no entry at this index, add the key/value
if self.index[ ix ] is None:
self.index[ ix ] = Entry( key, value )
else:
# See if the key already exists in the chain
next = self.index[ ix ]
while next is not None:
# Entry found, update the value
if next.Compare( key ):
next.Value( value )
break
next = next.Next()
# no entry found, add one
if next is None:
# Add the entry to the front of the chain
add = Entry( key, value )
add.Next( self.index[ ix ] )
self.index[ ix ] = add
Class specific implementation
Of comparing two keys.
77. Integer Hash (part 3)
class Hash( object ):
# Get the value for the key
def Get( self, key ):
ix = self.Index( key )
# See if the key exists in the chain at this entry in the index
next = self.index[ ix ]
while next is not None:
# Entry found, update the value
if next.Compare( key ):
return next.Value()
next = next.Next()
# not found
return None
Time Complexity : O(1) – no collisions (sparse)
O(n) – collisions
78. String (Object) Hash
• String (Object) Hash Algorithm
1. Convert the key to an integer value, which then can be divided by the range to get the
remainder (modulo).
2. In Python, the equivalent is the builtin function hash().
0
1
2
3
4
n
***
Range
None (no entry at index)
A
A B
Single Entry (no collision)
Chain of Entries (collisions)
Index = hash( value )
“my name”
79. Hash Table with Linear Probing
• A hash table without linked lists and instead handle collisions with
linear probing. In this case, we assume that the size of the table will
be greater than or equal to the number of keys.
1. Map each value into a fixed size integer range using a hash function.
2. If there is no entry at the index, add the key/value to the index.
3. If there is an entry and the key matches the entry (duplicate), then update the value.
4. If there is an entry and the key does not match the entry, then probe downward in
a linear fashion.
• If the entry is empty, add the key/value pair to the entry.
• If a key matches (duplicate), then update the entry.
• If the key does not match, continue to the next entry.
100 (index = )
202 (index = 2)
302 (index = 2)
n
***
Range
(e.g., 100)
Probe, 302 collides with 202 (index = 2)
80. Hash Table with Linear Probing
class HashLP( object ):
# Add a key/value entry to the index
def Add( self, key, value ):
# Linear probe the entries for an empty or matching slot.
for ix in range( self.Index( key ), self.RANGE ):
# there is no entry at this index, add the key/value
if self.index[ ix ] is None:
self.index[ ix ] = Entry( key, value )
break
# Entry found, update the value
if self.index[ ix ].Compare( key ):
self.index[ ix ].Value( value )
break
# Get the value for the key
def Get( self, key ):
ix = self.Index( key )
# Linear probe the entries for an empty or matching slot.
for ix in range( self.Index( key ), self.RANGE ):
# there is no entry at this index, return not found
if self.index[ ix ] is None:
return None
# Entry found
if self.index[ ix ].Compare( key ):
return self.index[ ix ].Value();
# not found
return None
81. Coding Challenge
• Python Language Constructs Covered:
1. Ord() builtin function
2. Bitwise-Mask
String Manipulation
82. Reverse String
• Reverse String - Iterative
1. Create a StringBuffer (or character array) to hold the reversed string.
2. Starting at the end of the string and moving backwards, append each character to
the reversed string.
• Reverse String – Recursive
1. If the original string is one character, if so then return the string.
2. Otherwise, break the string into two parts: the first character and the remainder of
the string.
3. Make a recursive call with the remaining string and append the first character to the
return from the call.
S t r i n g
g n i r t S
Backward Scan
Forward Copy
Copy Buffer
Original
Iterative
83. Reverse String
def ReverseString( original ):
reversed = “” # copy for reversed string
length = len( original ) # length of original string
for ix in range( length-1, -1, -1 ):
reversed += original[ ix ]
return reversed
Iterative
def ReverseStringR( original ):
if len( original ) > 1:
return ReverseStringR( original[1:] ) + original[ 0 ]
return original
Recursive
84. Palindrome - Word
• Palindrome - the same word/phrase spelled forward or backwards,
such as: madam, civic, racecar.
• Solution without making a copy of the string.
1. Iterate through the first half of the string. When the string is an odd number of
characters, skip the middle character.
2. On each iteration, compare the current character at the front of the string to the
same position but from the rear of the string.
3. If they do not much, it is not a palindrome.
r a c e c a
Backward ScanForward Scan
middle
r
85. Palindrome - Phrase
• Solve the same for phrases, regardless of the positioning of spaces,
punctuation and capitalizing, such as: My gym.
• Solution without making a copy of the string.
1. Iterate simultaneously from the front (forward) and back (backward) of the string,
until the two iterators meet.
2. If current character of either iterator is a punctuation or space character, then
advance the corresponding iterator.
3. Otherwise, if the lowercase value of the current character from both iterators do
not equal, then it is not a palindrome.
4. Advance both iterators and repeat.
M y g y m
Backward ScanForward Scan
middle
.
m
86. Palindrome
def Palindrome( s ):
length = len( s )
for i in range( 0, int( length / 2 ) ):
if s[ i ] != s[ length - i - 1 ]:
return False
return True
def PalindromeP( s ):
length = len( s )
i = 0
j = length - 1
while i < j:
if isPunctOrSpace( s[ i ] ):
i += 1
continue
if isPunctOrSpace( s[ j ] ):
j -= 1
continue
if s[ i ].lower() != s[ j ].lower():
return False
i += 1
if j != i:
j -= 1
return True
Word
Phrase
Calculate the reverse (backward) distance
Builtin string routine to lowercase a character.
87. Character Count
• Count all occurrences of every character in a string.
1. Create a counter for the 96 ASCII printable characters.
2. Iterate through the string, incrementing the character specific index in the counter
for each character.
r a c e c a
Forward Scan
r
Counter
88. Duplicate Character Count
• Count all occurrences of duplicate characters in a string.
1. Make a pass over the string to generate a character count index.
2. Make a pass over the character count index using a bitwise mask to mask out
single character occurrences (leaving only duplicates with non-zero values).
r a c e c a
Forward Scan
r
a=2 c=2 e=1b=0 d=0 r=2***
Counter
a=1 c=1 e=0b=0 d=0 r=1***
Mask &= ~0x01
Duplicates: Non-Zero value
89. Character and Duplicate Counts
def CharOccur( s ):
counter = [0] * 96 # codes 32 .. 127 are printable (so skip first 32)
length = len(s)
# use counter as an accumulator while we count each character in string
for i in range( 0, length):
counter[ ord( s[ i ] ) - 32 ] += 1 # offset ascii code by 32
return counter
Character Count
Builtin function that returns the ASCII value of the character.
def DupChar( s ):
# Get the character occurrences
dup = CharOccur( s )
# Mask out all single count occurrences
length = len( dup )
for i in range( 0, length):
dup[ i ] &= ~0x01;
return dup
Duplicate Count
A mask is the complement (inverse) of the value to remove