Logistics. Half of the people will be in Wu & Chen The other half in DRLB A1 Will post past midterms tonight (expect similar types of questions)

Similar documents
Data Structures. Outline. Introduction Linked Lists Stacks Queues Trees Deitel & Associates, Inc. All rights reserved.

Course Review for. Cpt S 223 Fall Cpt S 223. School of EECS, WSU

Unit 10: Data Structures CS 101, Fall 2018

3. Fundamental Data Structures

CS301 - Data Structures Glossary By

ECE Spring 2018 Problem Set #0 Due: 1/30/18

Lecture 17: Hash Tables, Maps, Finish Linked Lists

Overview of Data. 1. Array 2. Linked List 3. Stack 4. Queue

CS 350 : Data Structures B-Trees

Summer Final Exam Review Session August 5, 2009

Linked lists. Prof. Noah Snavely CS1114

Discussion 2C Notes (Week 3, January 21) TA: Brian Choi Section Webpage:

Computer Science 9608 (Notes) Chapter: 4.1 Computational thinking and problem-solving

CS350: Data Structures B-Trees

CSE373: Data Structures & Algorithms Lecture 5: Dictionary ADTs; Binary Trees. Linda Shapiro Spring 2016

CS532: Design and Analysis of Algorithms. Overview. Linked Lists. Data Structures Intro. Classes, Objects, and Pointers.

CS 222: Linked Lists, Queues, Stacks

Computer Science 210 Data Structures Siena College Fall Topic Notes: Linear Structures

Algorithms in Systems Engineering IE172. Midterm Review. Dr. Ted Ralphs

Information Science 2

12 Abstract Data Types

Linked Lists in C and C++

Dynamic Data Structures

CSE 2123: Collections: Priority Queues. Jeremy Morris

CSC148H Week 3. Sadia Sharmin. May 24, /20

Computer Science 210 Data Structures Siena College Fall Topic Notes: Trees

Cpt S 223 Fall Cpt S 223. School of EECS, WSU

CS 106B Lecture 26: Esoteric Data Structures: Skip Lists and Bloom Filters

Basic Data Structures (Version 7) Name:

/633 Introduction to Algorithms Lecturer: Michael Dinitz Topic: Priority Queues / Heaps Date: 9/27/17

CS61C : Machine Structures

Maintain binary search tree property nodes to the left are less than the current node, nodes to the right are greater

Data Structure. IBPS SO (IT- Officer) Exam 2017

3. Priority Queues. ADT Stack : LIFO. ADT Queue : FIFO. ADT Priority Queue : pick the element with the lowest (or highest) priority.

III Data Structures. Dynamic sets

Administrivia. Tree-Structured Indexes. Review. Today: B-Tree Indexes. A Note of Caution. Introduction

BINARY SEARCH TREES cs2420 Introduction to Algorithms and Data Structures Spring 2015

The questions will be short answer, similar to the problems you have done on the homework

CSE 373: Data Structures and Algorithms

CSE 373 OCTOBER 11 TH TRAVERSALS AND AVL

Algorithms and Data Structures

Course Review. Cpt S 223 Fall 2010

BINARY HEAP cs2420 Introduction to Algorithms and Data Structures Spring 2015

Course Review. Cpt S 223 Fall 2009

CP2 Revision. theme: dynamic datatypes & data structures

Lecture 7: Data Structures. EE3490E: Programming S1 2017/2018 Dr. Đào Trung Kiên Hanoi Univ. of Science and Technology

4.1 COMPUTATIONAL THINKING AND PROBLEM-SOLVING

Linked lists. Yet another Abstract Data Type Provides another method for providing space-efficient storage of data

CS 171: Introduction to Computer Science II. Linked List. Li Xiong

CS251-SE1. Midterm 2. Tuesday 11/1 8:00pm 9:00pm. There are 16 multiple-choice questions and 6 essay questions.

CSC148 Week 6. Larry Zhang

TREES cs2420 Introduction to Algorithms and Data Structures Spring 2015

MULTIMEDIA COLLEGE JALAN GURNEY KIRI KUALA LUMPUR

Hash Tables. CS 311 Data Structures and Algorithms Lecture Slides. Wednesday, April 22, Glenn G. Chappell

Dynamic Memory Allocation

MIDTERM EXAMINATION Spring 2010 CS301- Data Structures

Abstract Data Structures IB Computer Science. Content developed by Dartford Grammar School Computer Science Department

CS 225. Nov. 13 Introduction to Graphs. Data Structures. Wade Fagen-Ulmschneider

An AVL tree with N nodes is an excellent data. The Big-Oh analysis shows that most operations finish within O(log N) time

CS61BL. Lecture 3: Asymptotic Analysis Trees & Tree Traversals Stacks and Queues Binary Search Trees (and other trees)

CS24 Week 8 Lecture 1

XML Query Processing. Announcements (March 31) Overview. CPS 216 Advanced Database Systems. Course project milestone 2 due today

QUIZ QuickSort (Ch.7)

lecture notes September 2, How to sort?

Section 4 SOLUTION: AVL Trees & B-Trees

CSE373: Data Structures & Algorithms Lecture 5: Dictionaries; Binary Search Trees. Aaron Bauer Winter 2014

CMPSCI 187: Programming With Data Structures. Review for Final Exam David Mix Barrington 10 December 2012

CS1210 Lecture 28 Mar. 27, 2019

B-Trees. Version of October 2, B-Trees Version of October 2, / 22

Data Structure (CS301)

CS350 - Exam 1 (100 Points)

[2:3] Linked Lists, Stacks, Queues

CMSC 341 Priority Queues & Heaps. Based on slides from previous iterations of this course

CS 231 Data Structures and Algorithms Fall Algorithm Analysis Lecture 16 October 10, Prof. Zadia Codabux

CSE Data Structures and Introduction to Algorithms... In Java! Instructor: Fei Wang. Mid-Term Exam. CSE2100 DS & Algorithms 1

Lecture 6. COMP1006/1406 (the OOP course) Summer M. Jason Hinek Carleton University

EC8393FUNDAMENTALS OF DATA STRUCTURES IN C Unit 3

ECE 550D Fundamentals of Computer Systems and Engineering. Fall 2017

9/26/2018 Data Structure & Algorithm. Assignment04: 3 parts Quiz: recursion, insertionsort, trees Basic concept: Linked-List Priority queues Heaps

Computer Science Foundation Exam. Dec. 19, 2003 COMPUTER SCIENCE I. Section I A. No Calculators! KEY

DDS Dynamic Search Trees

CS 270 Algorithms. Oliver Kullmann. Binary search. Lists. Background: Pointers. Trees. Implementing rooted trees. Tutorial

Section 05: Solutions

Programming Abstractions

CSE373: Data Structures & Algorithms Lecture 4: Dictionaries; Binary Search Trees. Kevin Quinn Fall 2015

Notes slides from before lecture. CSE 21, Winter 2017, Section A00. Lecture 10 Notes. Class URL:

COP 3502 Spring 2018 Study Union Review

CS4961 Parallel Programming. Lecture 12: Advanced Synchronization (Pthreads) 10/4/11. Administrative. Mary Hall October 4, 2011

UNIT III BALANCED SEARCH TREES AND INDEXING

HASH TABLES cs2420 Introduction to Algorithms and Data Structures Spring 2015

CS 225. April 6 Disjoint Sets Implementation. Data Structures. Wade Fagen-Ulmschneider

Balanced Search Trees

What is an algorithm?

PRIORITY QUEUES AND HEAPS

CSE 373 APRIL 17 TH TREE BALANCE AND AVL

CSE332: Data Abstractions Lecture 4: Priority Queues; Heaps. James Fogarty Winter 2012

Announcements (March 31) XML Query Processing. Overview. Navigational processing in Lore. Navigational plans in Lore

Need Backtracking! L 0 A 1 B 2 K 3 P 4 C 5 I 6 Z 7 S 8 A 9 N 10 X 11 A 12 N 13 X 14 P 15

Abstract vs concrete data structures HEAPS AND PRIORITY QUEUES. Abstract vs concrete data structures. Concrete Data Types. Concrete data structures

DOWNLOAD PDF LINKED LIST PROGRAMS IN DATA STRUCTURE

Transcription:

Data Structures

Logistics Midterm next Monday Half of the people will be in Wu & Chen The other half in DRLB A1 Will post past midterms tonight (expect similar types of questions) Review on Wednesday Come with questions HW3 graded HW4 will be graded by the end of the week HW5 due Thursday next week (last homework on Python)

Why do we need data structures? Mostly, to store data in different ways Depending on the application, may emphasize different functionality We ve already seen some built-in Python structures Lists make it easy to access elements by using their index Dictionaries make it easy to map keys to values Sets are best for storing elements without duplicates Tuples store related things in one place Many other data structures exist in practice Any CS major includes (at least one) an entire course on this topic Will cover just some basic concepts today (also practice with classes/references)

Linked list One of the most widely used data structures Ordered similar to a standard Python list Makes it very easy to add/remove elements in arbitrary positions Each element in the list is called a Node The Node contains the actual data (e.g., city coordinates) Also a pointer to the next element Many variants of linked lists exist Today we ll cover stacks and queues

Linked list implementation Contains a head and a tail node First and last items in the list, respectively Depending on the convention, these nodes may or may not contain actual data Head Tail Each node contains a reference to the next node IDLE example: linkedlist.py

Adding/Removing Elements Depending on application, three options 1. Add to end, remove from the beginning Queue 2. Add to/remove from the beginning Stack 3. Add to/remove from other positions Non-standard but possible Might be slow

Queue Elements are added at the end and removed from the beginning Also known as a first-in-first-out (FIFO) data structure Very fast to add/remove elements A possible application is a website server Requests are handled in order of arrival IDLE example: queue.py

Stack Elements are added at the beginning and removed from the beginning Also known as a last-in-first-out (LIFO) data structure Also very fast to add/remove A possible application is an undo implementation Any change is pushed (i.e., added) to the stack If you press undo, the latest change is popped (i.e., removed) IDLE example: stack.py

Doubly-linked lists Each node may point not only to next but also to previous Implementation very similar to standard linked list Each node will two pointers instead of one More powerful than singly-linked list Can implement anything implemented by a singly-linked list Requires more memory for extra pointers A possible application would be undo + redo Upon undo, don t remove the latest item but just move the pointer to the previous item If redo later, can go back to undo -ed element

Pros and cons of linked lists Pros Add/remove at beginning/end is very fast Can grow arbitrarily (no need to reset length as with a standard list) No need to set an initial length of the list Cons Add/remove in the middle is slow (have to traverse the list to the item in question) Searching is slow (may have to traverse the whole list) Indexing is slow (have to traverse the list to the item in question)

Tree Another way of storing data If we don t want to store things chronologically (as in a list), we can store them based on some relation between the data This will make it easier to search for elements Trees also have nodes Instead of next/previous, a node has children Each Node contains that data, plus references to all its children Many types of trees Today we ll cover binary trees

Tree implementation The top Node is known as a root node The root may or may not contain data depending on the implementation The children of the root are roots of the branches of the tree Root IDLE example: tree.py Branches

Binary Tree A binary tree is a tree where each node has at most two children A balanced binary tree has the same number of nodes in each branch Not Balanced Binary trees are very useful structures An obvious application is searching Balanced Suppose all items in the left branch are smaller and all items in the right branch are bigger then searching would be very fast Implementation somewhat involved need to restructure the tree when inserting new items

Pros and cons of binary trees Pros Searching is fast (we always know which branch to follow) Can grow arbitrarily big Cons Add/delete is longer than with lists (need to restructure the tree) Not super slow! Depending on the sequence of inputs, the tree might not be naturally balanced (will have to restructure it to make it balanced) If tree is not balanced, searching will be slower (in the worst case, each node has only one child, and the tree will look like a list)