In this chapter we will compare the data structures we have learned so far by the performance (execution speed) of the basic operations (addition, search, deletion, etc.). We will give specific tips in what situations what data structures to use.
In this chapter we are going to get familiar with some of the basic presentations of data in programming: lists and linear data structures. Very often in order to solve a given problem we need to work with a sequence of elements. For example, to read completely this book we have to read sequentially each page, i.e. to traverse sequentially each of the elements of the set of the pages in the book. Depending on the task, we have to apply different operations on this set of data. In this chapter we will introduce the concept of abstract data types (ADT) and will explain how a certain ADT can have multiple different implementations. After that we shall explore how and when to use lists and their implementations (linked list, doubly-linked list and array-list). We are going to see how for a given task one structure may be more convenient than another. We are going to consider the structures "stack" and "queue", as well as their applications. We are going to get familiar with some implementations of these structures.
In this chapter we will learn about arrays as a way to work with sequences of elements of the same type. We will explain what arrays are, how we declare, create, instantiate and use them. We will examine one-dimensional and multidimensional arrays. We will learn different ways to iterate through the array, read from the standard input and write to the standard output. We will give many example exercises, which can be solved using arrays and we will show how useful they really are.
This document provides an overview of Java collections basics, including arrays, lists, strings, sets, and maps. It defines each type of collection and provides examples of how to use them. Arrays allow storing fixed-length sequences of elements and can be accessed by index. Lists are like resizable arrays that allow adding, removing and inserting elements using the ArrayList class. Strings represent character sequences and provide various methods for manipulation and comparison. Sets store unique elements using HashSet or TreeSet. Maps store key-value pairs using HashMap or TreeMap.
This document provides an overview of dictionaries, hash tables, and sets. It discusses the dictionary abstract data type and how it can be implemented using hash tables. It covers hashing, collision resolution strategies, and the .NET Dictionary<TKey, TValue> class. It also discusses sets and the HashSet<T> and SortedSet<T> classes, comparing their time complexities.
This document discusses collections and queries in Java, including associative arrays (maps), lambda expressions, and the stream API. It provides examples of using maps like HashMap, LinkedHashMap and TreeMap to store key-value pairs. Lambda expressions are introduced as anonymous functions. The stream API is shown processing collections through methods like filter, map, sorted and collect. Examples demonstrate common tasks like finding minimum/maximum values, summing elements, and sorting lists.
In this chapter we will review how to work with text files in C#. We will explain what a stream is, what its purpose is, and how to use it. We will explain what a text file is and how can you read and write data to a text file and how to deal with different character encodings. We will demonstrate and explain the good practices for exception handling when working with files. All of this will be demonstrated with many examples in this chapter
In this chapter we will explore strings. We are going to explain how they are implemented in Java and in what way we can process text content. Additionally, we will go through different methods for manipulating a text: we will learn how to compare strings, how to search for substrings, how to extract substrings upon previously settled parameters and last but not least how to split a string by separator chars. We will demonstrate how to correctly build strings with the StringBuilder class. We will provide a short but very useful information for the most commonly used regular expressions.
In this chapter we are going to get familiar with recursion and its applications. Recursion represents a powerful programming technique in which a method makes a call to itself from within its own method body. By means of recursion we can solve complicated combinatorial problems, in which we can easily exhaust different combinatorial configurations, e.g. generating permutations and variations and simulating nested loops. We are going to demonstrate many examples of correct and incorrect usage of recursion and convince you how useful it can be.
Chapter 22. Lambda Expressions and LINQIntro C# Book
In this chapter we will become acquainted with some of the advanced capabilities of the C# language. To be more specific, we will pay attention on how to make queries to collections, using lambda expressions and LINQ, and how to add functionality to already created classes, using extension methods. We will get to know the anonymous types, describe their usage briefly and discuss lambda expressions and show in practice how most of the built-in lambda functions work. Afterwards, we will pay more attention to the LINQ syntax – we will learn what it is, how it works and what queries we can build with it. In the end, we will get to know the meaning of the keywords in LINQ, and demonstrate their capabilities with lots of examples.
Here we are going to take a look how to use for loop, foreach loop and while loop. Also we are going to learn how to use and invoke methods and how to define classes in Java programming language.
In this chapter we will explore strings. We are going to explain how they are implemented in C# and in what way we can process text content. Additionally, we will go through different methods for manipulating a text: we will learn how to compare strings, how to search for substrings, how to extract substrings upon previously settled parameters and last but not least how to split a string by separator chars. We will demonstrate how to correctly build strings with the StringBuilder class. We will provide a short but very useful information for the most commonly used regular expressions. We will discuss some classes for efficient construction of strings. Finally, we will take a look at the methods and classes for achieving more elegant and stricter formatting of the text content.
19. Data Structures and Algorithm ComplexityIntro C# Book
In this chapter we will compare the data structures we have learned so far by the performance (execution speed) of the basic operations (addition, search, deletion, etc.). We will give specific tips in what situations what data structures to use. We will explain how to choose between data structures like hash-tables, arrays, dynamic arrays and sets implemented by hash-tables or balanced trees. Almost all of these structures are implemented as part of NET Framework, so to be able to write efficient and reliable code we have to learn to apply the most appropriate structures for each situation.
In this chapter we will examine the loop programming constructs through which we can execute a code snippet repeatedly. We will discuss how to implement conditional repetitions (while and do-while loops) and how to work with for-loops. We will give examples of different possibilities to define loops, how to construct them and some of their key usages. Finally, we will discuss the foreach-loop construct and how we can use multiple loops placed inside each other (nested loops).
In this chapter we will get familiar with primitive types and variables in Java – what they are and how to work with them. First we will consider the data types – integer types, real types with floating-point, Boolean, character, string and object type. We will continue with the variables, with their characteristics, how to declare them, how they are assigned a value and what is variable initialization.
Learn how to use arrays in Java, how to enter array, how to traverse an array, how to print array and more array operations.
Watch the video lesson and access the hands-on exercises here: https://softuni.org/code-lessons/java-foundations-certification-arrays
The document discusses various concepts related to abstraction in software development including project architecture, code refactoring, enumerations, and the static keyword in Java. It describes how to split code into logical parts using methods and classes to improve readability, reuse code, and avoid repetition. Refactoring techniques like extracting methods and classes are presented to restructure code without changing behavior. Enumerations are covered as a way to represent numeric values from a fixed set as text. The static keyword is explained for use with classes, variables, methods, and blocks to belong to the class rather than object instances.
Java Foundations: Data Types and Type ConversionSvetlin Nakov
Learn how to use data types and variables in Java, how variables are stored in the memory and how to convert from one data type to another.
Watch the video lesson and access the hands-on exercises here: https://softuni.org/code-lessons/java-foundations-certification-data-types-and-variables
This document provides an overview of machine learning concepts and techniques using the scikit-learn library in Python. It begins with introductions to different types of machine learning problems including supervised learning tasks like classification and regression as well as unsupervised learning problems like clustering and dimensionality reduction. It then discusses common machine learning algorithms such as support vector machines, k-means clustering, random forests, and principal component analysis. The document also covers best practices for developing machine learning models including data preprocessing, evaluating model performance, and tuning hyperparameters.
The document discusses defining and using methods in Java. It defines what a method is and its key components like the method signature, return type, parameters, and body. It then demonstrates a sample max method to return the maximum of two numbers and traces the steps of invoking the method from the main method, including passing arguments, executing the method body, and returning the result. The document aims to explain the basics of methods in Java, including how to define reusable methods and invoke them to perform certain tasks.
The document discusses arrays and motivates their use. It explains that arrays allow storing a large number of values in a program and accessing them through indices. Arrays solve the problem of having to declare many individual variables to store multiple values. The document then introduces the concept of arrays, how to declare and initialize array variables, and how to access elements within an array using indices. It provides examples of declaring, initializing, and accessing one-dimensional and two-dimensional arrays.
Learn how to use lists in Java, how to use List<T> and ArrayList<T>, how to process lists of elements.
Watch the video lesson and access the hands-on exercises here: https://softuni.org/code-lessons/java-foundations-certification-lists
1. Classes allow the creation of user-defined data types through the grouping of related data members and member functions.
2. Class members can be declared as private, public or protected and determine accessibility outside the class.
3. Methods are defined similarly to regular functions but can access any member of the class without passing them as parameters.
03 and 04 .Operators, Expressions, working with the console and conditional s...Intro C# Book
The document discusses Java syntax and concepts including:
1. It introduces primitive data types in Java like int, float, boolean and String.
2. It covers variables, operators, and expressions - how they are used to store and manipulate data in Java.
3. It explains console input and output using Scanner and System.out methods for reading user input and printing output.
4. It provides examples of using conditional statements like if and if-else to control program flow based on conditions.
This document discusses parameters and return values in Java methods. It provides examples of parameterized methods that take int, double, and String parameters. These include methods that draw lines and boxes of stars of varying lengths/sizes. The document also covers returning values from methods, including examples using Math class methods. Common errors around not storing return values are discussed.
In this lesson you will learn how to use basic syntax, conditions, if-else statements and loops (for-loop, while-loop and do-while-loop) in Java and how to use the debugger.
Watch the video lesson and access the hands-on exercises here: https://softuni.org/code-lessons/java-foundations-certification-basic-syntax-conditions-and-loops
This document provides an overview of primitive data types, expressions, and definite loops (for loops) in Java. It discusses Java's primitive types like int, double, char, and boolean. It covers arithmetic operators, precedence rules, and mixing numeric types. It also introduces variables, declarations, assignments, and using variables in expressions. Finally, it explains the syntax of for loops using initialization, a test condition, and an update to repeat a block of code a specified number of times.
The document discusses algorithms complexity and data structures efficiency, explaining that algorithm complexity can be measured using asymptotic notation like O(n) or O(n^2) to represent operations scaling linearly or quadratically with input size, and different data structures have varying time efficiency for operations like add, find, and delete.
In this chapter we are going to get familiar with recursion and its applications. Recursion represents a powerful programming technique in which a method makes a call to itself from within its own method body. By means of recursion we can solve complicated combinatorial problems, in which we can easily exhaust different combinatorial configurations, e.g. generating permutations and variations and simulating nested loops. We are going to demonstrate many examples of correct and incorrect usage of recursion and convince you how useful it can be.
Chapter 22. Lambda Expressions and LINQIntro C# Book
In this chapter we will become acquainted with some of the advanced capabilities of the C# language. To be more specific, we will pay attention on how to make queries to collections, using lambda expressions and LINQ, and how to add functionality to already created classes, using extension methods. We will get to know the anonymous types, describe their usage briefly and discuss lambda expressions and show in practice how most of the built-in lambda functions work. Afterwards, we will pay more attention to the LINQ syntax – we will learn what it is, how it works and what queries we can build with it. In the end, we will get to know the meaning of the keywords in LINQ, and demonstrate their capabilities with lots of examples.
Here we are going to take a look how to use for loop, foreach loop and while loop. Also we are going to learn how to use and invoke methods and how to define classes in Java programming language.
In this chapter we will explore strings. We are going to explain how they are implemented in C# and in what way we can process text content. Additionally, we will go through different methods for manipulating a text: we will learn how to compare strings, how to search for substrings, how to extract substrings upon previously settled parameters and last but not least how to split a string by separator chars. We will demonstrate how to correctly build strings with the StringBuilder class. We will provide a short but very useful information for the most commonly used regular expressions. We will discuss some classes for efficient construction of strings. Finally, we will take a look at the methods and classes for achieving more elegant and stricter formatting of the text content.
19. Data Structures and Algorithm ComplexityIntro C# Book
In this chapter we will compare the data structures we have learned so far by the performance (execution speed) of the basic operations (addition, search, deletion, etc.). We will give specific tips in what situations what data structures to use. We will explain how to choose between data structures like hash-tables, arrays, dynamic arrays and sets implemented by hash-tables or balanced trees. Almost all of these structures are implemented as part of NET Framework, so to be able to write efficient and reliable code we have to learn to apply the most appropriate structures for each situation.
In this chapter we will examine the loop programming constructs through which we can execute a code snippet repeatedly. We will discuss how to implement conditional repetitions (while and do-while loops) and how to work with for-loops. We will give examples of different possibilities to define loops, how to construct them and some of their key usages. Finally, we will discuss the foreach-loop construct and how we can use multiple loops placed inside each other (nested loops).
In this chapter we will get familiar with primitive types and variables in Java – what they are and how to work with them. First we will consider the data types – integer types, real types with floating-point, Boolean, character, string and object type. We will continue with the variables, with their characteristics, how to declare them, how they are assigned a value and what is variable initialization.
Learn how to use arrays in Java, how to enter array, how to traverse an array, how to print array and more array operations.
Watch the video lesson and access the hands-on exercises here: https://softuni.org/code-lessons/java-foundations-certification-arrays
The document discusses various concepts related to abstraction in software development including project architecture, code refactoring, enumerations, and the static keyword in Java. It describes how to split code into logical parts using methods and classes to improve readability, reuse code, and avoid repetition. Refactoring techniques like extracting methods and classes are presented to restructure code without changing behavior. Enumerations are covered as a way to represent numeric values from a fixed set as text. The static keyword is explained for use with classes, variables, methods, and blocks to belong to the class rather than object instances.
Java Foundations: Data Types and Type ConversionSvetlin Nakov
Learn how to use data types and variables in Java, how variables are stored in the memory and how to convert from one data type to another.
Watch the video lesson and access the hands-on exercises here: https://softuni.org/code-lessons/java-foundations-certification-data-types-and-variables
This document provides an overview of machine learning concepts and techniques using the scikit-learn library in Python. It begins with introductions to different types of machine learning problems including supervised learning tasks like classification and regression as well as unsupervised learning problems like clustering and dimensionality reduction. It then discusses common machine learning algorithms such as support vector machines, k-means clustering, random forests, and principal component analysis. The document also covers best practices for developing machine learning models including data preprocessing, evaluating model performance, and tuning hyperparameters.
The document discusses defining and using methods in Java. It defines what a method is and its key components like the method signature, return type, parameters, and body. It then demonstrates a sample max method to return the maximum of two numbers and traces the steps of invoking the method from the main method, including passing arguments, executing the method body, and returning the result. The document aims to explain the basics of methods in Java, including how to define reusable methods and invoke them to perform certain tasks.
The document discusses arrays and motivates their use. It explains that arrays allow storing a large number of values in a program and accessing them through indices. Arrays solve the problem of having to declare many individual variables to store multiple values. The document then introduces the concept of arrays, how to declare and initialize array variables, and how to access elements within an array using indices. It provides examples of declaring, initializing, and accessing one-dimensional and two-dimensional arrays.
Learn how to use lists in Java, how to use List<T> and ArrayList<T>, how to process lists of elements.
Watch the video lesson and access the hands-on exercises here: https://softuni.org/code-lessons/java-foundations-certification-lists
1. Classes allow the creation of user-defined data types through the grouping of related data members and member functions.
2. Class members can be declared as private, public or protected and determine accessibility outside the class.
3. Methods are defined similarly to regular functions but can access any member of the class without passing them as parameters.
03 and 04 .Operators, Expressions, working with the console and conditional s...Intro C# Book
The document discusses Java syntax and concepts including:
1. It introduces primitive data types in Java like int, float, boolean and String.
2. It covers variables, operators, and expressions - how they are used to store and manipulate data in Java.
3. It explains console input and output using Scanner and System.out methods for reading user input and printing output.
4. It provides examples of using conditional statements like if and if-else to control program flow based on conditions.
This document discusses parameters and return values in Java methods. It provides examples of parameterized methods that take int, double, and String parameters. These include methods that draw lines and boxes of stars of varying lengths/sizes. The document also covers returning values from methods, including examples using Math class methods. Common errors around not storing return values are discussed.
In this lesson you will learn how to use basic syntax, conditions, if-else statements and loops (for-loop, while-loop and do-while-loop) in Java and how to use the debugger.
Watch the video lesson and access the hands-on exercises here: https://softuni.org/code-lessons/java-foundations-certification-basic-syntax-conditions-and-loops
This document provides an overview of primitive data types, expressions, and definite loops (for loops) in Java. It discusses Java's primitive types like int, double, char, and boolean. It covers arithmetic operators, precedence rules, and mixing numeric types. It also introduces variables, declarations, assignments, and using variables in expressions. Finally, it explains the syntax of for loops using initialization, a test condition, and an update to repeat a block of code a specified number of times.
The document discusses algorithms complexity and data structures efficiency, explaining that algorithm complexity can be measured using asymptotic notation like O(n) or O(n^2) to represent operations scaling linearly or quadratically with input size, and different data structures have varying time efficiency for operations like add, find, and delete.
The document discusses data structures and algorithms. It defines key concepts like primitive data types, data structures, static vs dynamic structures, abstract data types, algorithm design, analysis of time and space complexity, recursion, stacks and common stack operations like push and pop. Examples are provided to illustrate factorial calculation using recursion and implementation of a stack.
The document discusses data structures and algorithms. It defines key concepts like primitive data types, data structures, static vs dynamic structures, abstract data types, algorithm analysis including time and space complexity, and common algorithm design techniques like recursion. It provides examples of algorithms and data structures like stacks and using recursion to calculate factorials. The document covers fundamental topics in data structures and algorithms.
The document discusses data structures and algorithms. It defines key concepts like primitive data types, data structures, static vs dynamic structures, abstract data types, algorithm design, analysis of time and space complexity, and recursion. It provides examples of algorithms and data structures like stacks and using recursion to calculate factorials. The document covers fundamental topics in data structures and algorithms.
The document discusses data structures and algorithms. It defines key concepts like primitive data types, data structures, static vs dynamic structures, abstract data types, algorithm design, analysis of time and space complexity, and recursion. It provides examples of algorithms and data structures like arrays, stacks and the factorial function to illustrate recursive and iterative implementations. Problem solving techniques like defining the problem, designing algorithms, analyzing and testing solutions are also covered.
The document discusses data structures and algorithms. It defines key concepts like primitive data types, data structures, static vs dynamic structures, abstract data types, algorithm design, analysis of time and space complexity, and recursion. It provides examples of algorithms and data structures like stacks and using recursion to calculate factorials. The document covers fundamental topics in data structures and algorithms.
This document discusses data structures and algorithms. It begins by defining data structures as the logical organization of data and primitive data types like integers that hold single pieces of data. It then discusses static versus dynamic data structures and abstract data types. The document outlines the main steps in problem solving as defining the problem, designing algorithms, analyzing algorithms, implementing, testing, and maintaining solutions. It provides examples of space and time complexity analysis and discusses analyzing recursive algorithms through repeated substitution and telescoping methods.
Bsc cs ii dfs u-1 introduction to data structureRai University
This document provides an introduction to data structures. It defines data structures as a way of organizing and storing data in a computer so it can be used efficiently. The document discusses different types of data structures including primitive, non-primitive, linear and non-linear structures. It provides examples of common data structures like arrays, linked lists, stacks, queues and trees. It also covers important concepts like time and space complexity analysis and Big O notation for analyzing algorithm efficiency.
The document discusses algorithms and data structures. It begins by introducing common data structures like arrays, stacks, queues, trees, and hash tables. It then explains that data structures allow for organizing data in a way that can be efficiently processed and accessed. The document concludes by stating that the choice of data structure depends on effectively representing real-world relationships while allowing simple processing of the data.
Bca ii dfs u-1 introduction to data structureRai University
This document provides an introduction to data structures. It defines data structures as a way of organizing and storing data in a computer so it can be used efficiently. There are two main types: primitive data structures like integers and characters that are directly operated on by the CPU, and non-primitive structures like arrays and linked lists that are more complex. Key aspects of data structures covered include operations, properties, performance analysis using time and space complexity, and examples of linear structures like arrays and non-linear structures like trees. Common algorithms are analyzed based on their asymptotic worst-case running times.
Mca ii dfs u-1 introduction to data structureRai University
This document provides an introduction to data structures. It defines data structures as a way of organizing and storing data in a computer so that it can be used efficiently. The document discusses different types of data structures including primitive, non-primitive, linear and non-linear structures. It provides examples of various data structures like arrays, linked lists, stacks, queues and trees. It also covers important concepts like time complexity, space complexity and Big O notation for analyzing algorithms. Common operations on data structures like search, insert and delete are also explained.
This document outlines a course on programming and data structures in C. It discusses key concepts like abstract data types, asymptotic analysis, various data structures like arrays, stacks, queues, linked lists, trees, and graphs. It covers different algorithms for searching, sorting and indexing of data. The objectives are to learn a program-independent view of data structures and their usage in algorithms. Various data structures, their representations and associated operations are explained. Methods for analyzing algorithms to determine their time and space complexity are also presented.
This document provides an overview of algorithm analysis and asymptotic notation. It discusses analyzing algorithms based on problem size and using Big-O notation to characterize runtime. Specifically, it introduces the concepts of best, worst, and average case analysis. It also covers properties of Big-O, like how operations combine asymptotically. Examples analyze the runtime of prefix averages algorithms and solving recursive equations using repeated substitution or telescoping. Finally, it discusses abstract data types and how to design new data types through specification, application, and implementation.
This document discusses various techniques for optimizing Python code, including:
1. Using the right algorithms and data structures to minimize time complexity, such as choosing lists, sets or dictionaries based on needed functionality.
2. Leveraging Python-specific optimizations like string concatenation, lookups, loops and imports.
3. Profiling code with tools like timeit, cProfile and visualizers to identify bottlenecks before optimizing.
4. Optimizing only after validating a performance need and starting with general strategies before rewriting hotspots in Python or other languages. Premature optimization can complicate code.
17. Java data structures trees representation and traversalIntro C# Book
In this chapter we will discuss tree data structures, like trees and graphs. The abilities of these data structures are really important for the modern programming. Each of this data structures is used for building a model of real life problems, which are efficiently solved using this model.
In this chapter we will discuss one recommended practice for efficiently solving computer programming problems and make a demonstration with appropriate examples. We will discuss the basic engineering principles of problem solving, why we should follow them when solving computer programming problems (the same principles can also be applied to find the solutions of many mathematical and scientific problems as well) and we will make an example of their use. We will describe the steps, in which we should go in order to solve some sample problems and show the mistakes that can occur when we do not follow these same steps. We will pay attention to some important steps from the methodology of problem solving, that we usually skip, e.g. the testing. We hope to be able to prove you, with proper examples, that the solving of computer programming problems has a "recipe" and it is very useful.
In this chapter we review the basic rules and recommendations for writing quality program code. We pay attention to naming the identifiers in the program (variables, methods, parameters, classes, etc.), formatting and code organization rules, good practices for composing methods, and principles for writing quality documentation.
This document discusses polymorphism, abstract classes, and abstract methods. It defines polymorphism as an object's ability to take on many forms and describes how it allows reference variables to refer to objects of child classes. It also distinguishes between method overloading and overriding, and explains the rules for each. Abstract classes are introduced as classes that cannot be instantiated directly but can be inherited from, and it is noted they may or may not contain abstract methods.
Here we are going to learn why is a good practice to use interfaces and how they are different from abstraction classes. Further more we are going to see how which one of them to use.
Encapsulation provides benefits such as reducing complexity, ensuring structural changes remain local, and allowing for validation and data binding. It works by hiding implementation details and wrapping code and data together. Objects use private fields and public getters/setters for access. Access modifiers like private, protected, and public control visibility. Validation occurs in setters through exceptions. Mutable objects can be modified after creation while immutable objects cannot. The final keyword prevents inheritance, method overriding, or variable reassignment.
Inheritance allows classes to extend and inherit properties from base classes. This creates class hierarchies where subclasses inherit and can override methods from superclasses. Inheritance promotes code reuse through extension when subclasses share the same role as the base class. Composition and delegation are alternative approaches to code reuse that may be preferable in some cases over inheritance.
In this chapter we will understand how to define custom classes and their elements. We will learn to declare fields, constructors and properties for the classes. We will revise what a method is and we will broaden our knowledge about access modifiers and methods.
In this chapter we will discuss exceptions in the object-oriented programming and in Java in particular. We will learn how to handle exceptions using the try-catch construct, how to pass them to the calling methods and how to throw standard or our own exceptions using the throw construct.
01. Introduction to programming with javaIntro C# Book
In this chapter we will take a look at the basic programming terminology and we will write our first Java program. We will familiarize ourselves with programming – what it means and its connection to computers and programming languages.
In this chapter we will discuss one recommended practice for efficiently solving computer programming problems and make a demonstration with appropriate examples. We will discuss the basic engineering principles of problem solving, why we should follow them when solving computer programming problems (the same principles can also be applied to find the solutions of many mathematical and scientific problems as well) and we will make an example of their use. We will describe the steps, in which we should go in order to solve some sample problems and show the mistakes that can occur when we do not follow these same steps. We will pay attention to some important steps from the methodology of problem solving, that we usually skip, e.g. the testing. We hope to be able to prove you, with proper examples, that the solving of computer programming problems has a "recipe" and it is very useful
In this chapter we review the basic rules and recommendations for writing quality program code. We pay attention to naming the identifiers in the program (variables, methods, parameters, classes, etc.), formatting and code organization rules, good practices for composing methods, and principles for writing quality documentation. We describe the official "Design Guidelines for Developing Class Libraries for .NET" from Microsoft. In the meantime we explain how the programming environment can automate operations such as code formatting and refactoring.
This chapter is a kind of continuation of the previous one – “Object-Oriented Programming Principles”. The reader is expected to be familiar with the basic OOP principles: abstraction, inheritance, polymorphism, encapsulation and exception handling. Those do greatly affect the quality of the code.
This document provides an overview of trees and tree-like data structures. It discusses trees and related terminology like nodes, edges, and traversals. It also covers implementing trees recursively and with a Tree<T> class. Binary trees and different traversal orders are explained. Balanced search trees like AVL trees, red-black trees, and B-trees are introduced for maintaining search trees in a balanced way. Finally, graphs are defined as a set of nodes connected by edges.
In this chapter we will understand how to define custom classes and their elements. We will learn to declare fields, constructors and properties for the classes. We will revise what a method is and we will broaden our knowledge about access modifiers and methods. We will observe the characteristics of the constructors and we will set out how the program objects coexist in the dynamic memory and how their fields are initialized. Finally, we will explain what the static elements of a class are – fields (including constants), properties and methods and how to use them properly. In this chapter we will also introduce generic types (generics), enumerated types (enumerations) and nested classes.
挂科无法毕业鉴于此购买文凭【q薇1954292140】一比一原版(UoN毕业证)北安普顿大学毕业证如何办理改成绩单GPA,文凭购买,毕业证办理,文凭办理只是基础业务。【q薇1954292140】一比一还原国外大学毕业证,定制国外大学学历,制作国外大学文凭,复刻国外大学毕业证书。学位证1:1完美还原海外各大学毕业材料上的工艺:水印,阴影底纹,钢印LOGO烫金烫银,LOGO烫金烫银复合重叠。文字图案浮雕、激光镭射、紫外荧光、温感、复印防伪等防伪工艺。
【办理北安普顿大学成绩单Buy The University of Northampton Transcripts】
购买日韩成绩单、英国大学成绩单、美国大学成绩单、澳洲大学成绩单、加拿大大学成绩单(q微1954292140)新加坡大学成绩单、新西兰大学成绩单、爱尔兰成绩单、西班牙成绩单、德国成绩单。成绩单的意义主要体现在证明学习能力、评估学术背景、展示综合素质、提高录取率,以及是作为留信认证申请材料的一部分。
北安普顿大学成绩单能够体现您的的学习能力,包括北安普顿大学课程成绩、专业能力、研究能力。(q微1954292140)具体来说,成绩报告单通常包含学生的学习技能与习惯、各科成绩以及老师评语等部分,因此,成绩单不仅是学生学术能力的证明,也是评估学生是否适合某个教育项目的重要依据!
Buy The University of Northampton Diploma《正式成绩单论文没过》有文凭却得不到认证。又该怎么办?鉴于此,购买英国毕业证【q微1954292140】英国文凭购买,英国文凭购买,英国文凭定制,英国文凭补办。专业在线定制英国大学文凭,定做英国本科文凭,【q微1954292140】复制英国The University of Northampton completion letter。在线快速补办英国本科毕业证、硕士文凭证书,购买英国学位证、北安普顿大学Offer,英国大学文凭在线购买。
【主营项目】
一、工作未确定,回国需先给父母、亲戚朋友看下文凭的情况,办理毕业证|办理北安普顿大学毕业证(UoN毕业证书)文凭: 买大学毕业证|买大学文凭【q薇1954292140】学位证明书如何办理申请?
二、回国进私企、外企、自己做生意的情况,这些单位是不查询毕业证真伪的,而且国内没有渠道去查询国外文凭的真假,也不需要提供真实教育部认证。鉴于此,办理北安普顿大学毕业证【q薇1954292140】英国学位证(UoN毕业证书)北安普顿大学毕业证书如何办理国外大学毕业证, 文凭办理, 国外文凭办理, 留信网认证
三.材料咨询办理、认证咨询办理北安普顿大学毕业证(UoN毕业证书)请加学历顾问【微信:1954292140】毕业证购买指大学文凭购买,毕业证办理和文凭办理。学院文凭定制,学校原版文凭补办,扫描件文凭定做,100%文凭复刻。经常操作的国家有美国毕业证,英国毕业证,澳洲毕业证,加拿大毕业证,以及德国毕业证,法国毕业证、荷兰毕业证、瑞士毕业证、日本毕业证、韩国毕业证、新西兰毕业证、新加坡毕业证、泰国毕业证、马来西亚毕业证等。包括了本科毕业证,硕士毕业证。
挂科无法毕业鉴于此购买文凭【q薇1954292140】一比一原版(UIC毕业证)加泰罗尼亚国际大学毕业证如何办理改成绩单GPA,文凭购买,毕业证办理,文凭办理只是基础业务。【q薇1954292140】一比一还原国外大学毕业证,定制国外大学学历,制作国外大学文凭,复刻国外大学毕业证书。学位证1:1完美还原海外各大学毕业材料上的工艺:水印,阴影底纹,钢印LOGO烫金烫银,LOGO烫金烫银复合重叠。文字图案浮雕、激光镭射、紫外荧光、温感、复印防伪等防伪工艺。
【办理加泰罗尼亚国际大学成绩单Buy Universitat Internacional de Catalunya Transcripts】
购买日韩成绩单、英国大学成绩单、美国大学成绩单、澳洲大学成绩单、加拿大大学成绩单(q微1954292140)新加坡大学成绩单、新西兰大学成绩单、爱尔兰成绩单、西班牙成绩单、德国成绩单。成绩单的意义主要体现在证明学习能力、评估学术背景、展示综合素质、提高录取率,以及是作为留信认证申请材料的一部分。
加泰罗尼亚国际大学成绩单能够体现您的的学习能力,包括加泰罗尼亚国际大学课程成绩、专业能力、研究能力。(q微1954292140)具体来说,成绩报告单通常包含学生的学习技能与习惯、各科成绩以及老师评语等部分,因此,成绩单不仅是学生学术能力的证明,也是评估学生是否适合某个教育项目的重要依据!
Buy Universitat Internacional de Catalunya Diploma《正式成绩单论文没过》有文凭却得不到认证。又该怎么办?鉴于此,购买西班牙毕业证【q微1954292140】西班牙文凭购买,西班牙文凭购买,西班牙文凭定制,西班牙文凭补办。专业在线定制西班牙大学文凭,定做西班牙本科文凭,【q微1954292140】复制西班牙Universitat Internacional de Catalunya completion letter。在线快速补办西班牙本科毕业证、硕士文凭证书,购买西班牙学位证、加泰罗尼亚国际大学Offer,西班牙大学文凭在线购买。
【主营项目】
一、工作未确定,回国需先给父母、亲戚朋友看下文凭的情况,办理毕业证|办理加泰罗尼亚国际大学毕业证(UIC毕业证书)文凭: 买大学毕业证|买大学文凭【q薇1954292140】学位证明书如何办理申请?
二、回国进私企、外企、自己做生意的情况,这些单位是不查询毕业证真伪的,而且国内没有渠道去查询国外文凭的真假,也不需要提供真实教育部认证。鉴于此,办理加泰罗尼亚国际大学毕业证【q薇1954292140】西班牙学位证(UIC毕业证书)加泰罗尼亚国际大学毕业证书如何办理国外大学毕业证, 文凭办理, 国外文凭办理, 留信网认证
三.材料咨询办理、认证咨询办理加泰罗尼亚国际大学毕业证(UIC毕业证书)请加学历顾问【微信:1954292140】毕业证购买指大学文凭购买,毕业证办理和文凭办理。学院文凭定制,学校原版文凭补办,扫描件文凭定做,100%文凭复刻。经常操作的国家有美国毕业证,英国毕业证,澳洲毕业证,加拿大毕业证,以及德国毕业证,法国毕业证、荷兰毕业证、瑞士毕业证、日本毕业证、韩国毕业证、新西兰毕业证、新加坡毕业证、泰国毕业证、马来西亚毕业证等。包括了本科毕业证,硕士毕业证。
DDos Mitigation Strategie, presented at bdNOG 19APNIC
Awal Haolader, Network Analyst / Technical Trainer at APNIC, presented on 'DDoS Mitigation Strategies' at bdNOG 19 held in Dhaka, Bangladesh from 21 to 24 May 2025.
Cloud Computing – iCloud
Cloud computing is a modern technology that allows users to store and access data over the internet instead of using local storage devices. One of the most popular cloud services is Apple's iCloud, which is specially designed for Apple users.
iCloud helps users keep their data safe, accessible, and synchronized across all Apple devices like iPhones, iPads, and MacBooks. It is simple to use, secure, and saves time by automatically backing up important information.
On the 29th of June, 1936, Pius XI addressed a pontifical encyclical entitled "Vigilanti Cura" to all the Catholic bishops in the United States. This encyclical was dedicated to "The Motion Picture" and justified his intervention by "the lamentable progress of the motion picture art and industry in the portrayal of sin and vice". I've appropriated the title of his encyclical for my film, putting it to a completely different use to that originally intended. The 'photogenic quality' of the Latin terminology has, however, been preserved and, as per Adorno: "like a neon light which has just been switched on, the commercial and promotional nature of contemporary culture glows brightly". Vigilanti Cura is an irreverent film; insolent and deliberately confusing; a grab-bag of immorality. The montage combines a range of archival imagery from Humanite magazine with images sourced from the media (the military parade of the 14th of July, the current sorry crop of political celebrities ...) or from the cinema (the automatic writing of a puzzle composed of motifs borrowed from existing films). Vigilanti Cura ... or merely a tacit admission of the downfall of contemporary man, drowning in a sea of political, social and religious fundamentalisms. Where is he to be found? Locked in a vis-a-vis with depression and ego. Psychoanalysis no longer serves as a pretext for the dissolution of sexual and social taboos; it now provokes withdrawal into an auto-reflexive isolation, to the extent that societal problems get frozen in the mirror of Auto-Medusification. The mirror has become our idol - let's destroy it!
Fast Reroute in SR-MPLS, presented at bdNOG 19APNIC
Md Abdullah Al Naser, Learning Content Developer at APNIC, presented on Fast Reroute (FRR) mechanisms within SR-MPLS at bdNOG 19 held in Dhaka, Bangladesh from 21 to 24 May 2025.
What to Expect When Hiring Shopify Development Services_ A Technical Walkthro...CartCoders
Get custom Shopify development services tailored to your store’s needs. From theme setup to full-scale integrations, our Shopify experts help create reliable, fast-loading, and conversion-focused online stores that fit your brand and drive more sales.
3D Graphics means creating images that look real and have depth, height, and width, just like real-life objects. These graphics are made using special software and help to make things look more realistic and detailed in games, movies, design, and much more.
Darley - BSides Nairobi (2025-06-07) Epochalypse 2038 - Time is Not on Our Si...treyka
Epochalypse 2038: Time is Not on Our Side
Presented by Trey Darley, Founder – Threshold Continuity Alliance
BSides Nairobi – 2025-06-07
The Year 2038 Problem is real — and it's already here.
At exactly 03:14:07 UTC on January 19, 2038, 32-bit signed Unix time overflows. Systems that use 32-bit time_t will reset to 1901 and/or fail outright. But this isn’t just about old embedded gear. It’s about trust, cryptographic integrity, log coherence, financial timestamps, system coordination, and the fragile scaffolding of global infrastructure.
This talk explores a dangerous and still largely invisible class of vulnerabilities: timestamp fragility and time synchronization failure.
We cover:
- Why over 60% of global software systems still depend on Unix epoch time
- How 2038 bugs can manifest subtly — without a crash, and without warning
- Why critical infrastructure (energy, telecom, aviation, finance) is especially at risk
- How even modern firmware is being shipped today with latent Y2038 bugs
- The implications for TLS certificates, forensic timelines, billing systems, and safety-critical protocols
- How time can be maliciously spoofed, delayed, or misaligned — and why legacy NTP is often unauthenticated
- A pragmatic call for 2038 rollover testbeds, code audits, and hardened time infrastructure
- Recommendations for deploying secure time protocols (NTS, RFC 8915), GPS + Rubidium/Cesium fallback, and air-gapped sync
You’ll leave with a grounded understanding of:
- Why time isn’t just an input — it’s an untrusted vector
- What engineers, regulators, and defenders must do now to avert a long-tail catastrophe
- How underserved regions may suffer disproportionately — but also leap ahead by refusing to inherit broken time
About the Speaker
Trey Darley is the founder of the Threshold Continuity Alliance (TCA), an initiative focused on strategic risk, infrastructure integrity, and time-based vulnerability remediation. A long-time figure in the global cybersecurity community, Trey works at the intersection of symbolic systems, resilience engineering, and future ethics.
Unlocking Business Growth Through Targeted Social EngagementDigital Guider
Facebook marketing allows businesses to connect with their ideal audience through precise targeting and engaging content. By leveraging advanced tools like custom audiences, Facebook Ads, and real-time analytics, brands can build strong relationships, increase visibility, and drive measurable results. It’s not just about reaching people—it’s about reaching the right people and turning engagement into growth.
https://digitalguider.com/digital-advertising/facebook-advertising-services/
Unlocking Business Growth Through Targeted Social EngagementDigital Guider
19. Java data structures algorithms and complexity
1. SoftUni Team
Technical Trainers
Software University
http://softuni.bg
Data Structures,
Algorithms and Complexity
Analyzing Algorithm Complexity.
Asymptotic Notation
2. Table of Contents
1. Data Structures
Linear Structures, Trees, Hash Tables, Others
2. Algorithms
Sorting and Searching, Combinatorics,
Dynamic Programming, Graphs, Others
3. Complexity of Algorithms
Time and Space Complexity
Mean, Average and Worst Case
Asymptotic Notation O(g)
2
6. 6
Examples of data structures:
Person structure (first name + last name + age)
Array of integers – int[]
List of strings – List<string>
Queue of people – Queue<Person>
What is a Data Structure?
“In computer science, a data structure is a particular
way of storing and organizing data in a computer so
that it can be used efficiently.” -- Wikipedia
7. 7
Student Data Structure
struct Student {
string Name { get; set; }
short Age { get; set; } // Student age (< 128)
Gender Gender { get; set; }
int FacultyNumber { get; set; }
};
enum Gender
{
Male,
Female,
Other
}
Student
Name Maria Smith
Age 23
Gender Female
FacultyNumber SU2007333
9. 9
Stack
class Stack<T>
{
// Pushes an elements at the top of the stack
void Push(T data);
// Extracts the element at the top of the stack
T Pop();
// Checks for empty stack
bool IsEmpty();
}
// The type T can be any data structure like
// int, string, DateTime, Student
15. 15
Queue
class Queue<T>
{
// Appends an elements at the end of the queue
void Enqueue(T data);
// Extracts the element from the start of the queue
T Dequeue();
// Checks for empty queue
bool IsEmpty();
}
// The type T can be any data structure like
// int, string, DateTime, Student
20. 20
Binary Tree
data
left link
.......
NULL
tree root
right link
data
left link
right link
data
left link
right link
data
left link
right link
data
left link
right link
.......
NULL
NULL
.......
.......
27. 27
Data structures and algorithms are the foundation of computer
programming
Algorithmic thinking, problem solving and data structures are
vital for software engineers
C# developers should know when to use T[], LinkedList<T>,
List<T>, Stack<T>, Queue<T>, Dictionary<K, T>,
HashSet<T>, SortedDictionary<K, T> and SortedSet<T>
Computational complexity is important for algorithm design and
efficient programming
Why Are Data Structures So Important?
28. Primitive data types
Numbers: int, float, double, decimal, …
Text data: char, string, …
Simple structures
A group of primitive fields stored together
E.g. DateTime, Point, Rectangle, Color, …
Collections
A set / sequence of elements (of the same type)
E.g. array, list, stack, queue, tree, hashtable, bag, …
Primitive Types and Collections
29. An Abstract Data Type (ADT) is
A data type together with the operations, whose properties are
specified independently of any particular implementation
ADT is a set of definitions of operations
Like the interfaces in C# / Java
Defines what we can do with the structure
ADT can have several different implementations
Different implementations can have different efficiency, inner
logic and resource needs
Abstract Data Types (ADT)
30. Linear structures
Lists: fixed size and variable size sequences
Stacks: LIFO (Last In First Out) structures
Queues: FIFO (First In First Out) structures
Trees and tree-like structures
Binary, ordered search trees, balanced trees, etc.
Dictionaries (maps, associative arrays)
Hold pairs (key value)
Hash tables: use hash functions to search / insert
Basic Data Structures
31. 31
Sets, multi-sets and bags
Set – collection of unique elements
Bag – collection of non-unique elements
Ordered sets and dictionaries
Priority queues / heaps
Special tree structures
Suffix tree, interval tree, index tree, trie, rope, …
Graphs
Directed / undirected, weighted / unweighted,
connected / non-connected, cyclic / acyclic, …
Basic Data Structures (2)
33. 33
The term "algorithm" means "a sequence of steps"
Derived from Muḥammad Al-Khwārizmī', a Persian mathematician
and astronomer
He described an algorithm for solving quadratic equations in 825
What is an Algorithm?
“In mathematics and computer science, an algorithm is
a step-by-step procedure for calculations. An algorithm
is an effective method expressed as a finite list of well-
defined instructions for calculating a function.”
-- Wikipedia
34. 34
Algorithms are fundamental in programming
Imperative (traditional, algorithmic) programming means to
describe in formal steps how to do something
Algorithm == sequence of operations (steps)
Can include branches (conditional blocks) and repeated logic (loops)
Algorithmic thinking (mathematical thinking, logical thinking,
engineering thinking)
Ability to decompose the problems into formal sequences of steps
(algorithms)
Algorithms in Computer Science
35. 35
Algorithms can be expressed as pseudocode, through flowcharts or
program code
Pseudocode and Flowcharts
BFS(node)
{
queue node
while queue not empty
v queue
print v
for each child c of v
queue c
}
Pseudo-code Flowchart
public void DFS(Node node)
{
Print(node.Name);
for (int i = 0; i < node.
Children.Count; i++)
{
if (!visited[node.Id])
DFS(node.Children[i]);
}
visited[node.Id] = true;
}
Source code
36. Sorting and searching
Dynamic programming
Graph algorithms
DFS and BFS traversals
Combinatorial algorithms
Recursive algorithms
Other algorithms
Greedy algorithms, computational geometry, randomized
algorithms, parallel algorithms, genetic algorithms
36
Some Algorithms in Programming
39. 39
Why should we analyze algorithms?
Predict the resources the algorithm will need
Computational time (CPU consumption)
Memory space (RAM consumption)
Communication bandwidth consumption
The expected running time of an algorithm is:
The total number of primitive operations executed
(machine independent steps)
Also known as algorithm complexity
Algorithm Analysis
40. 40
What to measure?
CPU time
Memory consumption
Number of steps
Number of particular operations
Number of disk operations
Number of network packets
Asymptotic complexity
Algorithmic Complexity
41. 41
Worst-case
An upper bound on the running time for any input of given size
Typically algorithms performance is measured for their worst case
Average-case
The running time averaged over all possible inputs
Used to measure algorithms that are repeated many times
Best-case
The lower bound on the running time (the optimal case)
Time Complexity
42. Sequential search in a list of size n
Worst-case:
n comparisons
Best-case:
1 comparison
Average-case:
n/2 comparisons
The algorithm runs in linear time
Linear number of operations
42
Time Complexity: Example
… … … … … … …
n
45. 45
Algorithm complexity is a rough estimation of the number of steps
performed by given computation, depending on the size of the input
Measured with asymptotic notation
O(g) where g is a function of the size of the input data
Examples:
Linear complexity O(n)
All elements are processed once (or constant number of times)
Quadratic complexity O(n2)
Each of the elements is processed n times
Algorithms Complexity
46. 46
Asymptotic upper bound
O-notation (Big O notation)
For a given function g(n), we denote by O(g(n)) the set of functions
that are different than g(n) by a constant
Examples:
3 * n2 + n/2 + 12 ∈ O(n2)
4*n*log2(3*n+1) + 2*n-1 ∈ O(n * log n)
Asymptotic Notation: Definition
O(g(n)) = {f(n): there exist positive constants c and n0
such that f(n) <= c*g(n) for all n >= n0}
49. 49
Complexity Notation Description
constant O(1)
Constant number of operations, not
depending on the input data size, e.g.
n = 1 000 000 1-2 operations
logarithmic O(log n)
Number of operations proportional to
log2(n) where n is the size of the input
data, e.g.
n = 1 000 000 000 30 operations
linear O(n)
Number of operations proportional to the
input data size, e.g. n = 10 000 5 000
operations
Typical Complexities
50. 50
Complexity Notation Description
quadratic O(n2)
Number of operations proportional to the
square of the size of the input data, e.g.
n = 500 250 000 operations
cubic O(n3)
Number of operations propor-tional to
the cube of the size of the input data, e.g.
n = 200 8 000 000 operations
exponential
O(2n),
O(kn),
O(n!)
Exponential number of operations, fast
growing, e.g. n = 20 1 048 576
operations
Typical Complexities (2)
52. 52
Time Complexity and Program Speed
Complexity 10 20 50 100 1 000 10 000 100 000
O(1) < 1 s < 1 s < 1 s < 1 s < 1 s < 1 s < 1 s
O(log(n)) < 1 s < 1 s < 1 s < 1 s < 1 s < 1 s < 1 s
O(n) < 1 s < 1 s < 1 s < 1 s < 1 s < 1 s < 1 s
O(n*log(n)) < 1 s < 1 s < 1 s < 1 s < 1 s < 1 s < 1 s
O(n2) < 1 s < 1 s < 1 s < 1 s < 1 s 2 s 3-4 min
O(n3) < 1 s < 1 s < 1 s < 1 s 20 s 5 hours 231 days
O(2n) < 1 s < 1 s 260 days hangs hangs hangs hangs
O(n!) < 1 s hangs hangs hangs hangs hangs hangs
O(nn) 3-4 min hangs hangs hangs hangs hangs hangs
54. 54
Complexity can be expressed as a formula of multiple variables, e.g.
Algorithm filling a matrix of size n * m with the natural numbers 1,
2, … n*m will run in O(n*m)
Algorithms to traverse a graph with n vertices and m edges will
take O(n + m) steps
Memory consumption should also be considered, for example:
Running time O(n) & memory requirement O(n2)
n = 50 000 OutOfMemoryException
Time and Memory Complexity
BTW: Is it possible in
practice? In theory?
56. 56
A linear algorithm could be slower than a quadratic algorithm
The hidden constant could be significant
Example:
Algorithm A performs 100*n steps O(n)
Algorithm B performs n*(n-1)/2 steps O(n2)
For n < 200, algorithm B is faster
Real-world example:
The "insertion sort" is faster than "quicksort" for n < 9
The Hidden Constant
57. 57
Amortized Analysis
Worst case: O(n2)
Average case: O(n) – Why?
void AddOne(char[] chars, int m)
{
for (int i = 0; 1 != chars[i] && i < m; i++)
{
c[i] = 1 - c[i];
}
}
59. 59
Just calculate and print sum = n * (n + 1) * (2n + 1) / 6
Using a Barometer
uint sum = 0;
for (i = 0; i < n; i++)
{
for (j = 0; j < i*i; j++)
{
sum++;
}
}
Console.WriteLine(sum);
60. 60
A polynomial-time algorithm has worst-case time complexity
bounded above by a polynomial function of its input size
Examples:
Polynomial time: 2n, 3n3 + 4n
Exponential time: 2n, 3n, nk, n!
Exponential algorithms hang for large input data sets
Polynomial Algorithms
W(n) ∈ O(p(n))
64. Runs in O(n) where n is the size of the array
The number of elementary steps is ~ n
Complexity Examples
int FindMaxElement(int[] array)
{
int max = array[0];
for (int i=1; i<array.length; i++)
{
if (array[i] > max)
{
max = array[i];
}
}
return max;
}
65. Runs in O(n2) where n is the size of the array
The number of elementary steps is ~ n * (n+1) / 2
Complexity Examples (2)
long FindInversions(int[] array)
{
long inversions = 0;
for (int i=0; i<array.Length; i++)
for (int j = i+1; j<array.Length; i++)
if (array[i] > array[j])
inversions++;
return inversions;
}
66. Runs in cubic time O(n3)
The number of elementary steps is ~ n3
Complexity Examples (3)
decimal Sum3(int n)
{
decimal sum = 0;
for (int a=0; a<n; a++)
for (int b=0; b<n; b++)
for (int c=0; c<n; c++)
sum += a*b*c;
return sum;
}
67. Runs in quadratic time O(n*m)
The number of elementary steps is ~ n*m
Complexity Examples (4)
long SumMN(int n, int m)
{
long sum = 0;
for (int x=0; x<n; x++)
for (int y=0; y<m; y++)
sum += x*y;
return sum;
}
68. Runs in quadratic time O(n*m)
The number of elementary steps is ~ n*m + min(m,n)*n
Complexity Examples (5)
long SumMN(int n, int m)
{
long sum = 0;
for (int x=0; x<n; x++)
for (int y=0; y<m; y++)
if (x==y)
for (int i=0; i<n; i++)
sum += i*x*y;
return sum;
}
69. Runs in exponential time O(2n)
The number of elementary steps is ~ 2n
Complexity Examples (6)
decimal Calculation(int n)
{
decimal result = 0;
for (int i = 0; i < (1<<n); i++)
result += i;
return result;
}
70. Runs in linear time O(n)
The number of elementary steps is ~ n
Complexity Examples (7)
decimal Factorial(int n)
{
if (n==0)
return 1;
else
return n * Factorial(n-1);
}
71. Runs in exponential time O(2n)
The number of elementary steps is ~ Fib(n+1)
where Fib(k) is the kth Fibonacci's number
Complexity Examples (8)
decimal Fibonacci(int n)
{
if (n == 0)
return 1;
else if (n == 1)
return 1;
else
return Fibonacci(n-1) + Fibonacci(n-2);
}
78. 78
Data structures organize data in computer systems for efficient use
Abstract data types (ADT) describe a set of operations
Collections hold a group of elements
Algorithms are sequences of steps for calculating / doing something
Algorithm complexity is a rough estimation of the number of steps
performed by given computation
Can be logarithmic, linear, n log n, square, cubic, exponential, etc.
Complexity predicts the speed of given code before its execution
Summary
81. License
This course (slides, examples, labs, videos, homework, etc.)
is licensed under the "Creative Commons Attribution-
NonCommercial-ShareAlike 4.0 International" license
81
Attribution: this work may contain portions from
"Fundamentals of Computer Programming with C#" book by Svetlin Nakov & Co. under CC-BY-SA license
"Data Structures and Algorithms" course by Telerik Academy under CC-BY-NC-SA license
82. Free Trainings @ Software University
Software University Foundation – softuni.org
Software University – High-Quality Education,
Profession and Job for Software Developers
softuni.bg
Software University @ Facebook
facebook.com/SoftwareUniversity
Software University @ YouTube
youtube.com/SoftwareUniversity
Software University Forums – forum.softuni.bg
#79: (c) 2007 National Academy for Software Development - http://academy.devbg.org. All rights reserved. Unauthorized copying or re-distribution is strictly prohibited.*