What are ADTs, STL Intro, vector, list, queue, stack Learning & Development Team Telerik Software Academy.

Slides:



Advertisements
Similar presentations
Windows Basic and Dynamic Disk Borislav Varadinov Telerik Software Academy academy.telerik.com System Administrator Marian Marinov CEO of 1H Ltd.
Advertisements

HTML Forms, GET, POST Methods Tran Anh Tuan Edit from Telerik Academy
Make swiftly iOS development Telerik Academy Telerik Academy Plus.
Amazon S 3, App Engine Blobstore, Google Cloud Storage, Azure Blobs Svetlin Nakov Telerik Software Academy academy.telerik.com.
RPN and Shunting-yard algorithm Ivaylo Kenov Telerik Software Academy academy.telerik.com Technical Assistant
Shortest paths in edge-weighted digraph Krasin Georgiev Technical University of Sofia g.krasin at gmail com Assistant Professor.
Telerik Software Academy Telerik School Academy.
Asynchronous Programming with C# and WinRT
Unleash the Power of JavaScript Tooling Telerik Software Academy End-to-end JavaScript Applications.
Touch and Gestures with Xamarin Forms
Character sequences, C-strings and the C++ String class, Working with Strings Learning & Development Team Telerik Software Academy.
Hybrid or Native?! Doncho Minkov Telerik Software Academy Senior Technical Trainer
Done already for your convenience! Telerik School Academy Unity 2D Game Development.
Processing Sequences of Elements Telerik School Academy C# Fundamentals – Part 1.
With Mocha and Karma Telerik Academy Telerik Software Academy.
C# Fundamentals – Part I
Welcome to the JSON-stores world Telerik Software Academy Databases.
NoSQL Concepts, Redis, MongoDB, CouchDB
Telerik Software Academy Telerik School Academy Creating E/R Diagrams with SQL Server.
The Business Plan and the Business Model Margarita Antonova Volunteer Telerik Academy academy.telerik.com Business System Analyst Telerik Corporation.
Making JavaScript code by template! Learning & Development Team Telerik Software Academy.
Svetlin Nakov Telerik Software Academy academy.telerik.com Manager Technical Training Who, What, Why?
Lists, Stacks, Queues Svetlin Nakov Telerik Corporation
Access to known folders, using pickers, writing to and reading from files, caching files for future access George Georgiev Telerik Software Academy academy.telerik.com.
Processing Matrices and Multidimensional Tables Svetlin Nakov Telerik Software Academy academy.telerik.com Technical Trainer
Learning & Development Telerik Software Academy.
Reading and Writing Text Files Svetlin Nakov Telerik Software Academy academy.telerik.com Technical Trainer
Classical OOP in JavaScript Classes and stuff Telerik Software Academy
Optimization problems, Greedy Algorithms, Optimal Substructure and Greedy choice Learning & Development Team Telerik Software.
Using Selenium for Mobile Web Testing Powered by KendoUI Telerik QA Academy Atanas Georgiev Senior QA Engineer KendoUI Team.
NoSQL Concepts, Redis, MongoDB, CouchDB Svetlin Nakov Telerik Software Academy academy.telerik.com Manager Technical Training
New features: classes, generators, iterators, etc. Telerik Academy Plus JavaScript.Next.
Throwing and Catching Exceptions Tran Anh Tuan Edit from Telerik Software Academy
Loops, Conditional Statements, Functions Tran Anh Tuan Edit from Telerik Academy
Private/Public fields, Module, Revealing Module Learning & Development Team Telerik Software Academy.
Building Data-Driven ASP.NET Web Forms Apps Telerik Software Academy ASP.NET Web Forms.
Telerik Software Academy End-to-end JavaScript Applications.
What is a Database, MySQL Specifics Trần Anh Tuấn Edit from Telerik Software Academy
Planning and Tracking Software Quality Yordan Dimitrov Telerik Corporation Team Leader, Team Pulse, Team Leader, Team Pulse, Telerik Corporation,
Language enhancements and additions Learning & Development Team Telerik Software Academy.
What you need to know Ivaylo Kenov Telerik Corporation Telerik Academy Student.
Data binding concepts, Bindings in WinJS George Georgiev Telerik Software Academy academy.telerik.com Technical Trainer itgeorge.net.
Pavel Kolev Telerik Software Academy Senior.Net Developer and Trainer
Objects, Properties, Primitive and Reference Types Learning & Development Team Telerik Software Academy.
When and How to Refactor? Refactoring Patterns Alexander Vakrilov Telerik Corporation Senior Developer and Team Leader.
Free Training and Job for Software Engineers Svetlin Nakov, PhD Manager Technical Training Telerik Corp. Telerik Software Academy.
Access to known folders, using pickers, writing to and reading from files, caching files for future access George Georgiev Telerik Software Academy academy.telerik.com.
Doing the Canvas the "easy way"! Learning & Development Telerik Software Academy.
Creating and Running Your First C# Program Svetlin Nakov Telerik Software Academy academy.telerik.com Manager Technical Training
Subroutines in Computer Programming Telerik School Academy C# Fundamentals – Part 1.
Data Types, Primitive Types in C++, Variables – Declaration, Initialization, Scope Telerik Software Academy academy.telerik.com Learning and Development.
The past, the present, the future Learning & Development Team Telerik Software Academy.
Connecting, Queries, Best Practices Tran Anh Tuan Edit from Telerik Software Academy
Processing Sequences of Elements Telerik Software Academy C# Fundamentals – Part 2.
Telerik JavaScript Framework Telerik Software Academy Hybrid Mobile Applications.
Telerik Software Academy Databases.
Things start to get serious Telerik Software Academy JavaScript OOP.
Learning & Development Mobile apps for iPhone & iPad.
Processing Matrices and Multidimensional Tables Telerik Software Academy C# Fundamentals – Part 2.
Nikolay Kostov Telerik Software Academy academy.telerik.com Team Lead, Senior Developer and Trainer
Functions and Function Expressions Closures, Function Scope, Nested Functions Telerik Software Academy
Implementing Control Logic in C# Svetlin Nakov Telerik Software Academy academy.telerik.com Manager Technical trainer
Inheritance, Abstraction, Encapsulation, Polymorphism Telerik Software Academy Mobile apps for iPhone & iPad.
Mocking tools for easier unit testing Telerik Software Academy High Quality Code.
Creating and Initializing Arrays, Accessing Elements, Multiple Dimensions Learning & Development Team Telerik Software Academy.
Data Structures and Algorithms Telerik Software Academy
What why and how? Telerik School Academy Unity 2D Game Development.
Windows Security Model Borislav Varadinov Telerik Software Academy academy.telerik.com System Administrator
Lists, Stacks, Queues Svetlin Nakov Telerik Software Academy Manager Technical Trainer
Definition, Constructors, Methods, Access Modifiers, Static/Instance members, Learning & Development Team Telerik Software Academy.
Presentation transcript:

What are ADTs, STL Intro, vector, list, queue, stack Learning & Development Team Telerik Software Academy

1. Basic Abstract Data Types 1.List 2.Linked List 3.Stack 4.Queue 2. ADTs in STL 1.STL Intro 2.Iterators 3.Vector, list, stack, queue 2

Basic Data Structures

 An Abstract Data Type (ADT) is a data type together with the operations, whose properties are specified independently of any particular implementation  ADT are set of definitions of operations  Can have several different implementations  Different implementations can have different efficiency

 Linear structures  Lists: fixed size and variable size  Stacks: LIFO (Last In First Out) structure  Queues: FIFO (First In First Out) structure  Trees  Binary, ordered, balanced, etc.  Dictionaries (maps)  Contain pairs (key, value)  Hash tables: use hash functions to search/insert

 Data structure (container) that contains a sequence of elements  Can have variable size  Elements are arranged linearly, in sequence  Can be implemented in several ways  Statically (using array  fixed size)  Dynamically (linked implementation)  Using resizable array

 Implemented by an array  Direct access by index (fast)  Insertion and deletion and resizing are slow operations L

 Dynamic (pointer-based) implementation  Direct access to first/last element  No access by index  go through all previous elements (slow)  Insertion and deletion are fast  Resizing – add new element at the end or beginning 2next7next head4next5next null

 LIFO (Last In First Out) structure  Elements inserted (push) at “top”  Elements removed (pop) from “top”  Useful in many situations  E.g. the execution stack of the program  Can be implemented in several ways  Statically (using array)  Dynamically (linked implementation)

 FIFO (First In First Out) structure  Elements inserted at the tail (Enqueue)  Elements removed from the head (Dequeue)  Useful in many situations  Print queues, message queues, etc.  Can be implemented in several ways  Statically (using array)  Dynamically (using pointers)

Introduction, Basic ADT Implementations

 Standard Template Library  C++ Library  Implements a lot of computer science fundamentals  Container classes, Algorithms  Iterators  Mostly template-based  Algorithms decoupled from containers through iterators 15

 Containers  Data structures, hold collections of elements  Different benefits and downsides  Implement fundamental Abstract Data Types  Sequence, Associative, String, Adaptors…  Iterators  Provide access to container elements  Used to "traverse" containers 16

 Algorithms  Fundamental algorithms over collections or single  Hook up with iterators to access container elements  Function objects  Wrap functions/methods into objects  Implement () operator – called like functions  Called by algorithms and containers to act over elements (elements passed as parameters) 17

Live Demo

Mechanism for traversing container elements

 "Smart" pointers to objects  Specific for each container type  Each container defines how it’s iterators work  If we have an iterator to one element  Increase/decrease it to get the other elements  Types:  Input, Output  Forward iterator, Bidirectional iterator  Random access iterator 20

Fast data structures to store elements

 Store collections of other objects  Has methods to access elements  Types  By traversability:  Forward – elements ordered, Forward Iterators  Reversible – have Bidirectional iterators  Random access – have Random access iterators  By storage:  sequence, adaptors, associative 22

Vector, List, Deque, Queue, Stack

 Vector ( #include )  Defined: template vector  Sequence, Random Access  Stores a sequence of elements in contiguous memory  Manages memory effectively  Fast at retrieving elements by index and adding elements at the end  Slow insertion/deletion in middle or beginning 24

 Declaring and initializing a vector  Vector size and is obtained by calling size() #include //required header … vector numbers; numbers.push_back(42); //numbers is now {42} numbers.push_back(13); //numbers is now {42, 13} int consoleNumber; cin>>consoleNumber; numbers.push_back(consoleNumber) vector numbers; numbers.push_back(42);numbers.push_back(13); cout<<numbers.size(); //prints 2

 Accessing vector elements  Done the same way as with arrays, i.e. []  Traversing a vector is the same as traversing an array (e.g. with a for loop)  Element access does not depend on vector size vector numbers; numbers.push_back(42);numbers.push_back(13); cout<<numbers[1]; //prints 13 cout<<endl; numbers[1] = numbers[0]; cout<<numbers[1]; //prints 42

Live Demo

 List ( #include )  Defined: template list  Sequence, Reversible  Stores a sequence of elements in a doubly- linked list  Fast at deletion/insertion anywhere  No random access to elements  Have to traverse list to get to an item 28

 Declaring and initializing a list  List size and is obtained by calling size()  List elements can be removed from front and back fast list numbers; numbers.push_back(2);numbers.push_front(1);numbers.push_back(3); numbers.pop_front();numbers.pop_back();

 Accessing list elements  front and back methods provide first and last element access  Only way to get access to all elements – traversal by iterator cout<<numbers.front();cout<<numbers.back(); list ::iterator numbersIterator; for(numbersIterator = numbers.begin(); numbersIterator != numbers.end(); numbersIterator != numbers.end(); numbersIterator++) numbersIterator++){ cout<<*numbersIterator<<endl; cout<<*numbersIterator<<endl;}

Live Demo

 Queue ( #include )  Defined: template queue  Sequence Adaptor  First in, First out structure (FIFO)  Stores a sequence of elements  Provides access only to first element  Can remove only at front  Can add only at back 32

 Declaring and initializing a queue  Queue size is obtained by calling size()  Queues allow removing elements only from the front of the sequence queue q; q.push(1);q.push(2);q.push(3); q.pop();

 Accessing queue elements  front and back methods provide first and last element access  Other types of access to queue elements are meaningless  The idea of the queue is to restrict access and be FIFO cout<<q.front();cout<<q.back();

Live Demo

 Stack ( #include )  Defined: template stack  Sequence adaptor  Last in, First out structure (LIFO)  Stores a sequence of elements  Provides access only to last element  Can remove or add elements only at back/top 36

 Declaring and initializing a stack  Stack size is obtained by calling size()  Stacks allow removing elements only from the back (top) of the sequence stack s; s.push(1);s.push(2);s.push(3); s.pop();

 Accessing stack elements  top method provides first element access  Other types of access to stack elements are meaningless  The idea of the stack is to restrict access and be LIFO cout<<s.top();

Live Demo

форум програмиране, форум уеб дизайн курсове и уроци по програмиране, уеб дизайн – безплатно програмиране за деца – безплатни курсове и уроци безплатен SEO курс - оптимизация за търсачки уроци по уеб дизайн, HTML, CSS, JavaScript, Photoshop уроци по програмиране и уеб дизайн за ученици ASP.NET MVC курс – HTML, SQL, C#,.NET, ASP.NET MVC безплатен курс "Разработка на софтуер в cloud среда" BG Coder - онлайн състезателна система - online judge курсове и уроци по програмиране, книги – безплатно от Наков безплатен курс "Качествен програмен код" алго академия – състезателно програмиране, състезания ASP.NET курс - уеб програмиране, бази данни, C#,.NET, ASP.NET курсове и уроци по програмиране – Телерик академия курс мобилни приложения с iPhone, Android, WP7, PhoneGap free C# book, безплатна книга C#, книга Java, книга C# Николай Костов - блог за програмиране

41 1. …