Computational Complexity of Fundamental Data Structures, Choosing a Data Structure.

Slides:



Advertisements
Similar presentations
Computational Complexity, Choosing Data Structures Svetlin Nakov Telerik Corporation
Advertisements

Lists, Stacks, Queues Svetlin Nakov Telerik Corporation
Dictionaries, Hash Tables, Collisions Resolution, Sets Svetlin Nakov Telerik Corporation
Data Structures and Collections
Svetlin Nakov Telerik Software Academy academy.telerik.com Technical Trainer Wintellect Power Collections, C 5 Collections.
Lecture - 1 on Data Structures. Prepared by, Jesmin Akhter, Lecturer, IIT,JU Data Type and Data Structure Data type Set of possible values for variables.
Midterm 2 Overview Fawzi Emad Chau-Wen Tseng Department of Computer Science University of Maryland, College Park.
Java Collections. Collections, Iterators, Algorithms CollectionsIteratorsAlgorithms.
Lists, Stacks, Queues Svetlin Nakov Telerik Corporation
Trees, Tre-Like Structures, Binary Search Trees, Balanced Trees, Tree Traversals, DFS and BFS Svetlin Nakov Telerik Software Academy academy.telerik.com.
Java Collections Framework A presentation by Eric Fabricant.
Abstract Data Types (ADTs) Data Structures The Java Collections API
Overview of Data Structures and Basic Algorithms. Computational Complexity. Asymptotic Notation Svetlin Nakov Telerik Software Academy academy.telerik.com.
Copyright © Wondershare Software Introduction to Data Structures Prepared by: Eng. Ahmed & Mohamed Taha.
CS 221 Analysis of Algorithms Data Structures Dictionaries, Hash Tables, Ordered Dictionary and Binary Search Trees.
Comp 249 Programming Methodology Chapter 15 Linked Data Structure - Part B Dr. Aiman Hanna Department of Computer Science & Software Engineering Concordia.
FEN 2012UCN Technology - Computer Science 1 Data Structures and Collections Principles revisited.NET: –Two libraries: System.Collections System.Collections.Generics.
1 Hash Tables  a hash table is an array of size Tsize  has index positions 0.. Tsize-1  two types of hash tables  open hash table  array element type.
ISOM MIS 215 Module 3 – Stacks and Queues. ISOM Where are we? 2 Intro to Java, Course Java lang. basics Arrays Introduction NewbieProgrammersDevelopersProfessionalsDesigners.
Liang, Introduction to Java Programming, Sixth Edition, (c) 2007 Pearson Education, Inc. All rights reserved Chapter 22 Java Collections.
Liang, Introduction to Java Programming, Eighth Edition, (c) 2011 Pearson Education, Inc. All rights reserved Chapter 22 Java Collections.
Course Program, Evaluation, Exams, Resources Telerik Software Academy Data structures and algorithms.
Dictionaries, Hash Tables, Hashing, Collisions, Sets Svetlin Nakov Telerik Software Academy academy.telerik.com Technical Trainer
ADT Table and Heap Ellen Walker CPSC 201 Data Structures Hiram College.
Java Collections An Introduction to Abstract Data Types, Data Structures, and Algorithms David A Watt and Deryck F Brown © 2001, D.A. Watt and D.F. Brown.
Jan 12, 2012 Introduction to Collections. 2 Collections A collection is a structured group of objects Java 1.2 introduced the Collections Framework Collections.
Data structures and algorithms in the collection framework 1 Part 2.
Week 6 - Friday.  What did we talk about last time?  Recursive running time  Fast exponentiation  Merge sort  Introduced the Master theorem.
CS212: DATA STRUCTURES Lecture 1: Introduction. What is this course is about ?  Data structures : conceptual and concrete ways to organize data for efficient.
Collection Data Structures and Libraries
111 © 2002, Cisco Systems, Inc. All rights reserved.
CSS446 Spring 2014 Nan Wang.  Java Collection Framework ◦ Set ◦ Map 2.
Object Oriented Programming Ders 10: Data Structures Mustafa Emre İlal
Multidimensional Arrays, Sets, Dictionaries Processing Matrices, Multidimensional Arrays, Dictionaries, Sets SoftUni Team Technical Trainers Software University.
Data structures Abstract data types Java classes for Data structures and ADTs.
HIT2037- HIT6037 Software Development in Java 22 – Data Structures and Introduction.
Data structures and algorithms in the collection framework 1.
Computational Complexity, Choosing Data Structures Svetlin Nakov Telerik Corporation
“Enthusiasm releases the drive to carry you over obstacles and adds significance to all you do.” – Norman Vincent Peale Thought for the Day.
Computer Science 112 Fundamentals of Programming II Implementation Strategies for Unordered Collections.
Data Structures academy.zariba.com 1. Lecture Content 1.Linear Data Structures 2.Trees and Graphs* 3.Dictionaries and Hash Tables 4.Homework 2.
Interface: (e.g. IDictionary) Specification class Appl{ ---- IDictionary dic; dic= new XXX(); application class: Dictionary SortedDictionary ----
Building Java Programs Bonus Slides Hashing. 2 Recall: ADTs (11.1) abstract data type (ADT): A specification of a collection of data and the operations.
Collections Data structures in Java. OBJECTIVE “ WHEN TO USE WHICH DATA STRUCTURE ” D e b u g.
Collections Mrs. C. Furman April 21, Collection Classes ArrayList and LinkedList implements List HashSet implements Set TreeSet implements SortedSet.
Dictionaries, Hash Tables, Collisions Resolution, Sets Svetlin Nakov Telerik Corporation
Data Structures and Collections Principles.NET: –Two libraries: System.Collections System.Collections.Generics FEN 2014UCN Teknologi/act2learn1 Deprecated.
Data-structure-palooza Checkout DataStructures from SVN.
C++ Review STL CONTAINERS.
Data Structures What The Course Is About Data structures is concerned with the representation and manipulation of data.
1 Principles revisited.NET: Two libraries: System.Collections System.Collections.Generics Data Structures and Collections.
CSE 143 Lecture 11: Sets and Maps reading:
LINQ and Lambda Expressions Telerik Software Academy LINQ Overview.
Copyright © 2009 Curt Hill Look Ups A Recurring Theme.
3-1 Java's Collection Framework Another use of polymorphism and interfaces Rick Mercer.
Sets, Dictionaries SoftUni Team Technical Trainers Software University
Dictionaries, Hash Tables and Sets Dictionaries, Hash Tables, Hashing, Collisions, Sets SoftUni Team Technical Trainers Software University
SoftUni Team Technical Trainers Software University Trees and Tree-Like Structures Trees, Tree-Like Structures, Binary Search Trees,
Computational Complexity, Choosing Data Structures Svetlin Nakov Telerik Software Academy Manager Technical Trainer
Combining Data Structures
Multidimensional Arrays, Sets, Dictionaries
Algorithms Complexity and Data Structures Efficiency
Road Map CS Concepts Data Structures Java Language Java Collections
structures and their relationships." - Linus Torvalds
CS313D: Advanced Programming Language
structures and their relationships." - Linus Torvalds
14.1 The java.util Package.
Introduction to Data Structures
structures and their relationships." - Linus Torvalds
Presentation transcript:

Computational Complexity of Fundamental Data Structures, Choosing a Data Structure

1. Fundamental Data Structures – Comparison  Arrays  Lists  Trees  Hash-Tables  Sets  Bags 2. Choosing Proper Data Structure 2

Time Complexity of Basic Operations

Data Structure AddFindDelete Get-by- index Array ( T[] ) O(n)O(n)O(n)O(1) Linked list ( LinkedList ) O(1)O(n)O(n)O(n) Resizable array list ( List ) O(1)O(n)O(n)O(1) Stack ( Stack ) O(1)-O(1)- Queue ( Queue ) O(1)-O(1)- 4

Data Structure AddFindDelete Get-by- index Hash table ( Dictionary ) O(1)O(1)O(1)- Tree-based dictionary ( Sorted Dictionary ) O(log n) - Hash table based set ( HashSet ) O(1)O(1)O(1)- Tree based set ( SortedSet ) O(log n) - 5

 Arrays ( T[] )  Use when fixed number of elements should be processed by index  Resizable array lists ( List )  Use when elements should be added and processed by index  Linked lists ( LinkedList )  Use when elements should be added at the both sides of the list  Otherwise use resizable array list ( List ) 6

 Stacks ( Stack )  Use to implement LIFO (last-in-first-out) behavior  List could also work well  Queues ( Queue )  Use to implement FIFO (first-in-first-out) behavior  LinkedList could also work well  Hash table based dictionary ( Dictionary )  Use when key-value pairs should be added fast and searched fast by key  Elements in a hash table have no particular order 7

 Balanced search tree based dictionary ( SortedDictionary )  Use when key-value pairs should be added fast, searched fast by key and enumerated sorted by key  Hash table based set ( HashSet )  Use to keep a group of unique values, to add and check belonging to the set fast  Elements are in no particular order  Search tree based set ( SortedSet )  Use to keep a group of ordered unique values 8

 Algorithm complexity is rough estimation of the number of steps performed by given computation  Complexity can be logarithmic, linear, n log n, square, cubic, exponential, etc.  Allows to estimating the speed of given code before its execution  Different data structures have different efficiency on different operations  The fastest add / find / delete structure is the hash table – O(1) for all these operations 9

Questions?

1. A text file students.txt holds information about students and their courses in the following format: Using SortedDictionary print the courses in alphabetical order and for each of them prints the students ordered by family and then by name: 11 Kiril | Ivanov | C# Stefka | Nikolova | SQL Stela | Mineva | Java Milena | Petrova | C# Ivan | Grigorov | C# Ivan | Kolev | SQL C#: Ivan Grigorov, Kiril Ivanov, Milena Petrova Java: Stela Mineva SQL: Ivan Kolev, Stefka Nikolova

2. A large trade company has millions of articles, each described by barcode, vendor, title and price. Implement a data structure to store them that allows fast retrieval of all articles in given price range [x…y]. Hint: use OrderedMultiDictionary from Wintellect's Power Collections for.NET. Wintellect's Power Collections for.NET.Wintellect's Power Collections for.NET. 3. Implement a class BiDictionary that allows adding triples {key1, key2, value} and fast search by key1, key2 or by both key1 and key2. Note: multiple values can be stored for given key. 12

 C# Telerik Academy  csharpfundamentals.telerik.com csharpfundamentals.telerik.com  Telerik Software Academy  academy.telerik.com academy.telerik.com  Telerik Facebook  facebook.com/TelerikAcademy facebook.com/TelerikAcademy  Telerik Software Academy Forums  forums.academy.telerik.com forums.academy.telerik.com