Useful Data Structures in C++ and Java. Useful Data Structures in C++ (1) Templates are C++’s mechanism to define abstract objects which can be parameterized.

Slides:



Advertisements
Similar presentations
Lecture 3 Introduction to Collections Advanced Java Programming 1 dr inż. Wojciech Bieniecki
Advertisements

Working With Collections in the AP ™ Java Subset 2003 ACTE Convention © 2003 by Kenneth A. Lambert.
Stacks and Queues Sections 3.6 and 3.7. Stack ADT Collections:  Elements of some proper type T Operations:  void push(T t)  void pop()  T top() 
CS 307 Fundamentals of Computer Science 1 Abstract Data Types many slides taken from Mike Scott, UT Austin.
1 L43 Collections (3). 2 OBJECTIVES  To use the collections framework interfaces to program with collections polymorphically.  To use iterators to “walk.
Main Index Contents 11 Main Index Contents Model for a Queue Model for a Queue The Queue The Queue ADTQueue ADT (3 slides) Queue ADT Radix Sort Radix Sort.
1 Data Structures  We can now explore some advanced techniques for organizing and managing information  Chapter 12 of the book focuses on: dynamic structures.
Standard Template Library (STL) Overview – Part 1 Yngvi Bjornsson.
1 Stack Data : a collection of homogeneous elements arranged in a sequence. Only the first element may be accessed Main Operations: Push : insert an element.
Introduction to Data Structure, Fall 2006 Slide- 1 California State University, Fresno Introduction to Data Structure Chapter 8 Ming Li Department of.
Chapter 24 Dispensers and dictionaries. This chapter discusses n Dictionaries n Dispensers u stacks u queues u priority queues.
Java Collections. Collections, Iterators, Algorithms CollectionsIteratorsAlgorithms.
Java's Collection Framework
Lists, Stacks, Queues Svetlin Nakov Telerik Corporation
SEG4110 – Advanced Software Design and Reengineering TOPIC G Java Collections Framework.
Lecture 11 Standard Template Library Stacks, Queue, and Deque Lists Iterators Sets Maps.
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.
DATA STRUCTURES ACM EXECUTIVE BODY 2k11.  A series of elements of same type  Placed in contiguous memory locations  Can be individually referenced.
Lecture 4 The Java Collections Framework. Java Container Classes.
Stacks and queues Basic operations Implementation of stacks and queues Stack and Queue in java.util Data Structures and Algorithms in Java, Third EditionCh04.
1 Stacks Stack Examples Stack API More Examples/Uses Base Conversion Activation Records RPN Implementing a Stack Stacks.
Programming Interest Group Tutorial Two Data Structures.
Chapter 3 List Stacks and Queues. Data Structures Data structure is a representation of data and the operations allowed on that data. Data structure is.
Data Structures and Abstract Data Types "Get your data structures correct first, and the rest of the program will write itself." - David Jones.
Java™ How to Program, 9/e Presented by: Dr. José M. Reyes Álamo © Copyright by Pearson Education, Inc. All Rights Reserved.
Stacks and Queues Introduction to Computing Science and Programming I.
Jan 12, 2012 Introduction to Collections. 2 Collections A collection is a structured group of objects Java 1.2 introduced the Collections Framework Collections.
The Java Collections Framework (JCF) Introduction and review 1.
Big Java Chapter 16.
Some Other Collections: Bags, Sets, Queues and Maps COMP T2 Lecture 4 School of Engineering and Computer Science, Victoria University of Wellington.
CSE 373: Data Structures and Algorithms Lecture 1: Introduction; ADTs; Stacks; Eclipse.
Computer Science 209 Software Development Java Collections.
CSS446 Spring 2014 Nan Wang  Java Collection Framework ◦ LinkedList ◦ Set ◦ Map 2.
HIT2037- HIT6037 Software Development in Java 22 – Data Structures and Introduction.
Chapter 12: Collections by Lewis and Loftus (Updated by Dan Fleck) Coming up: Collections.
Introduction to the Standard Template Library (STL) A container class holds a number of similar objects. Examples: –Vector –List –Stack –Queue –Set –Map.
Collections Data structures in Java. OBJECTIVE “ WHEN TO USE WHICH DATA STRUCTURE ” D e b u g.
1 Queues Queue API Application: Radix Sort Implementation: Using Deque Using Deque Circular Array Circular Array Priority Queue Priority Queue API Implementation.
Some Other Collections: Bags, Sets, Queues and Maps COMP T2 Lecture 4 School of Engineering and Computer Science, Victoria University of Wellington.
Data-structure-palooza Checkout DataStructures from SVN.
C++ Review STL CONTAINERS.
1 Java's Collection Framework Map and Sets. 2 Collection Framework  A collections framework is a unified architecture for representing and manipulating.
CPS Review of Data Structures l We’ve studied concrete data structures/type (CDT)  Vectors Homogeneous aggregates supporting random access  Linked.
CSE 373 Data Structures and Algorithms Lecture 1: Introduction; ADTs; Stacks; Eclipse.
Stacks Chapter 5 © 2015 Pearson Education, Inc., Upper Saddle River, NJ. All rights reserved. Data Structures and Abstractions with Java, 4e Frank Carrano.
CS-2851 Dr. Mark L. Hornick 1 Stacks and Queues Behavior vs. Structure.
Copyright © Curt Hill STL Priority Queue A Heap-Like Adaptor Class.
3-1 Java's Collection Framework Another use of polymorphism and interfaces Rick Mercer.
COMP 103 Maps and Queues. RECAP  Iterators (for-each loop)  Bag, Sets, and Stacks - a class, not interface TODAY  Maps and Queues 2 RECAP-TODAY QUICK.
Introduction to Java Collection. Java Collections What are they? –A number of pre-packaged implementations of common ‘container’ classes, such as LinkedLists,
1 The Standard Template Library The STL is a collection of Container classes These are class templates for containers. A container is an object that stores.
Using the Java Collection Libraries COMP 103 # T2
G64ADS Advanced Data Structures
Set Collection A Bag is a general collection class that implements the Collection interface. A Set is a collection that resembles a Bag with the provision.
Chapter 12: Data Structures
Priority Queues Sections 6.1 to 6.5.
Road Map CS Concepts Data Structures Java Language Java Collections
Road Map CS Concepts Data Structures Java Language Java Collections
structures and their relationships." - Linus Torvalds
Java Collections Overview
structures and their relationships." - Linus Torvalds
Welcome to CSE 143! Go to pollev.com/cse143.
Road Map CS Concepts Data Structures Java Language Java Collections
Lab4 problems More about templates Some STL
CS 240 – Advanced Programming Concepts
structures and their relationships." - Linus Torvalds
Abstract Data Types (ADTs)
© 2016 Pearson Education, Ltd. All rights reserved.
Introduction to Java Collection
Presentation transcript:

Useful Data Structures in C++ and Java

Useful Data Structures in C++ (1) Templates are C++’s mechanism to define abstract objects which can be parameterized by type. The C++ Standard Template Library (STL) provides implementations of many useful data structures, such as stacks, queues, dictionaries, priority queues, and sets.

Useful Data Structures in C++ (3) Stack – S.push(), S.top(), S.pop(), S.empty(). You should always top on pop because top returns but does not remove the element on top, while pop removes but does not return the element. Queue – Q.front(), Q.back(), Q.push(), Q.pop(), and Q.empty(). Queue have the same idiosyncrasies as stack.

Useful Data Structures in C++ (3) Dictionary – STL contains a wide variety of containers, including hash_map, a hashed associative container binding keys to data items. Methods include H.erase(), H.find(), and H.insert() Priority Queue – Declared priority-queue Q;, methods include Q.top(), Q.push, Q.pop(), and Q.empty(). Set – Sets are represented as sorted associative containers, declared set S;. Set algorithms include set_union and set_intersection, as well as other standard set operators.

Useful Data Structures in Java (1) Useful standard Java objects appear in the java.util package. Below are some useful objects related to data structures. To use java.util include import java.util.*; at the beginning of your program to improt the whole package.

Useful Data Structures in Java (2) Data Structure Abstract class Concrete class Methods StackNoStackpop,push, empty, peek QueueListArrayList, LinkedList add, remove, clear DictionaryMapHashMap, Hashtable put, get, contains Priority Queue SortedMapTreeMapfirstKey, lastKey, heapMap Set HashSetadd, remove, contains

Useful Data Structures in Java (3) You can declare a data structure object with an interface or abstract class and instantiate it using a concrete class, like Map myMap = new HashMap(); Or you can declare a data structure object and instantiate it with a concrete class, like HashMap myMap = new HashMap();