Unit 10: Data Structures CS 101, Fall 2018

Similar documents
Unit 7: Algorithms and Python CS 101, Fall 2018

Unit 2: Data Storage CS 101, Fall 2018

Unit 5: Computer Networking CS 101, Fall 2018

Unit 11: Database Systems CS 101, Fall 2018

Unit 8: Programming Languages CS 101, Fall 2018

CS 240 Fall Mike Lam, Professor. Just-for-fun survey:

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)

Structure and Interpretation of Computer Programs

CSC 101: Lab #5 Prelab Boolean Logic Practice Due Date: 5:00pm, day after lab session

Structure and Interpretation of Computer Programs

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

Programming with Arrays Intro to Pointers CS 16: Solving Problems with Computers I Lecture #11

Intensive Introduction to Computer Science. Course Overview Programming in Scratch

15-110: Principles of Computing, Spring 2018

Linked lists Tutorial 5b

CS Introduction to Programming Fall 2016

Beijing Jiaotong University CS-23: C++ Programming Summer, 2019 Course Syllabus

COMP Analysis of Algorithms & Data Structures

Quiz 1. Queues , Fall 2007 Recitation 10 Solutions 1

Chapter 8: Data Abstractions

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

COMP Data Structures

COMP Data Structures

CENG 707 Data Structures and Algorithms

Lecture 2: Variables & Assignments

Linked lists. Prof. Noah Snavely CS1114

Lecture 34. Wednesday, April 6 CS 215 Fundamentals of Programming II - Lecture 34 1

Ascii Art. CS 1301 Individual Homework 7 Ascii Art Due: Monday April 4 th, before 11:55pm Out of 100 points

! Mon, May 5, 2:00PM to 4:30PM. ! Closed book, closed notes, clean desk. ! Comprehensive (covers entire course) ! 30% of your final grade

CS 241 Data Organization. August 21, 2018

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

Cpt S 122 Data Structures. Course Review Midterm Exam # 1

CSE115 Lab 2 Fall 2016

PUBLISHING 1231 Intermediate New Media Publishing (FLASH) Instructor: Mak (Mahmoud) Abdel-Hai Office: A248 Phone: 604-3

CSCI-1200 Data Structures Fall 2017 Lecture 7 Order Notation & Basic Recursion

CS115 - Module 10 - General Trees

Lecture 17: Hash Tables, Maps, Finish Linked Lists

Implementing Hash and AVL

EECE.2160: ECE Application Programming Spring 2017

CS 101: Computer Programming and Utilization. Abhiram Ranade

We don t have much time, so we don t teach them [students]; we acquaint them with things that they can learn. Charles E. Leiserson

I. PREREQUISITE For information regarding prerequisites for this course, please refer to the Academic Course Catalog.

Ashish Gupta, Data JUET, Guna

CSCI-1200 Data Structures Spring 2017 Lecture 5 Pointers, Arrays, Pointer Arithmetic

CSCI-1200 Data Structures Spring 2014 Lecture 5 Pointers, Arrays, Pointer Arithmetic

CSE 332 Spring 2013: Midterm Exam (closed book, closed notes, no calculators)

Information Science 2

Organizing Data The Power of Structure...

MULTIMEDIA COLLEGE JALAN GURNEY KIRI KUALA LUMPUR

Spring 2003 Instructor: Dr. Shahadat Hossain. Administrative Matters Course Information Introduction to Programming Techniques

CPSC 221: Algorithms and Data Structures Lecture #0: Introduction. Come up and say hello! Fibonacci. Fibonacci. Fibonacci. Fibonacci. (Welcome!

Welcome to CS61A! Last modified: Thu Jan 23 03:58: CS61A: Lecture #1 1

Operations on Heap Tree The major operations required to be performed on a heap tree are Insertion, Deletion, and Merging.

(More) Fun with Pointers and Linked Lists! CS 16: Solving Problems with Computers I Lecture #17

Closed Computer and Book 1 Double-sided sheet of notes allowed staple to your test when done

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

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

15-122: Principles of Imperative Computation, Fall 2015

CoSci 440 SYLLABUS Programming in C++ INSTRUCTOR Mari Rettke cell SECTION : and 13345

Cpt S 122 Data Structures. Course Review FINAL. Nirmalya Roy School of Electrical Engineering and Computer Science Washington State University

lecture24: Disjoint Sets

* Due 11:59pm on Sunday 10/4 for Monday lab and Tuesday 10/6 Wednesday Lab

Elementary Computing CSC /01/2015 M. Cheng, Computer Science 1

Homework: More Abstraction, Trees, and Lists

Beginning Programming (Two Semesters) Semester One. Module One: Intro to Beginning Programming. Module Two: Computer Careers

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

CS 112 Final May 8, 2008 (Lightly edited for 2012 Practice) Name: BU ID: Instructions

Ministry of Higher Education and Scientific research

Functions and the MIPS Calling Convention 2 CS 64: Computer Organization and Design Logic Lecture #11

CS 61B Summer 2005 (Porter) Midterm 2 July 21, SOLUTIONS. Do not open until told to begin

CS 432 Fall Mike Lam, Professor. Compilers. Advanced Systems Elective

CS270 Computer Organization Fall 2017

Overview of the ECE Computer Software Curriculum. David O Hallaron Associate Professor of ECE and CS Carnegie Mellon University

What is an algorithm?

CS/ENGRD 2110 Object-Oriented Programming and Data Structures Spring 2012 Thorsten Joachims

CS 3030 Scripting Languages Syllabus

CS-301 Data Structure. Tariq Hanif

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

CS 240 Fall 2015 Section 004. Alvin Chao, Professor

CSE 114, Computer Science 1 Course Information. Spring 2017 Stony Brook University Instructor: Dr. Paul Fodor

CS 3516: Advanced Computer Networks

Data Abstractions. National Chiao Tung University Chun-Jen Tsai 05/23/2012

Review for the Final Exam CS 8: Introduction to Computer Science, Winter 2018 Lecture #15

CSCI 204 Introduction to Computer Science II

Upcoming ACM Events Linux Crash Course Date: Time: Location: Weekly Crack the Coding Interview Date:

CS115 - Module 8 - Binary trees

Review: Classes and Object Instances. Review: Creating an Object. Using Multiple Objects. DrawingGizmo pencil; pencil = new DrawingGizmo();

QUIZ How do we implement run-time constants and. compile-time constants inside classes?

Welcome to! 4DN4! Advanced Internet Communications"

CS 3516: Computer Networks

CMPUT 391 Database Management Systems. Fall Semester 2006, Section A1, Dr. Jörg Sander. Introduction

Physics 2660: Fundamentals of Scientific Computing. Lecture 7 Instructor: Prof. Chris Neu

COLLEGE OF DUPAGE CIS 2542 Advanced C++ with Data Structure Applications Course Syllabus

3D Graphics Programming Mira Costa High School - Class Syllabus,

Lab Exercise 8 Binary Search Trees

Introduction to Databases Fall-Winter 2010/11. Syllabus

CS2013 Course Syllabus Spring 2017 Lecture: Friday 8:00 A.M. 9:40 A.M. Lab: Friday 9:40 A.M. 12:00 Noon

61A LECTURE 1 FUNCTIONS, VALUES. Steven Tang and Eric Tzeng June 24, 2013

Assignment 1 What is a Computer?

BIRLA INSTITUTE OF TECHNOLOGY AND SCIENCE, Pilani Pilani Campus Instruction Division. SECOND SEMESTER Course Handout Part II

Transcription:

Unit 10: Data Structures CS 101, Fall 2018 Learning Objectives After completing this unit, you should be able to: Define and give everyday examples of arrays, stacks, queues, and trees. Explain what a pointer is and why it s fundamental to data structures. Use Python lists to store and manipulate one and two-dimensional data. Trace the recursive implementation of a binary search tree in Python. Draw linked lists and binary trees that correspond to memory contents. Insert, delete, and find nodes (by hand) in linked lists and binary trees. Summarize the pros and cons of using contiguous vs linked structures. Textbook Sections 8.1 Basic Data Structures 8.2 Related Concepts 8.3 Implementing Data Structures 8.4 A Short Case Study Video Lectures Data Structures Binky Pointer Fun Assignments Act10 Data Structures; Chapter 8 Problems Lab10 Codecademy (5 & 6); Visualizing binary trees

CS 101 Unit 10: Data Structures Before Wednesday Date Completed FINISH models 1 and 2 of Data Structures READ textbook 8.1 Basic Data Structures ANSWER questions 1 and 3 in your notes READ textbook 8.2 Related Concepts ANSWER questions 2 and 3 in your notes READ textbook 8.4 A Short Case Study ANSWER questions 1 and 2 in your notes WATCH video lecture: Data Structures START Lab10: Visualizing binary trees (10 pts) Before Friday Date Completed READ textbook 8.3 Implementing Data Structures ANSWER questions 4 and 9 in your notes DO tutorial: Codecademy (5. Lists & Dictionaries) DO tutorial: Codecademy (6. Student Becomes the Teacher) START Act10 exercises (complete at least 75%) (10 pts) Before Monday Date Completed COMPARE your Lab10 and Act10 with the solutions in Canvas SUBMIT Quiz10 1st attempt closed: see what you don t know STUDY your notes, ask questions on Piazza, meet with the TAs SUBMIT Quiz10 2nd attempt open: try to get the full 10 points (10 pts)

Activity 10: Data Structures Model 1 Array Consider a list of numbers: lucky = [29, 16, 23, 47, 37] The easiest way to store these numbers in memory is to put them side by side. For example, if the list were to begin at memory address 40: Address: 40 41 42 43 44 45 46 47 48 49 Value: 29 16 23 47 37 Index: When programming, we can access individual numbers by their index. For example, the value of lucky[1] is 16, and lucky[5] is out of range. Questions (10 min) Start time: 1. In the diagram above, write the index below each value. 2. We call the beginning of the list the head and the end of the list the tail. a) What is the address of the head? b) What is the address of the tail? c) What is the index of the head? d) What is the index of the tail? 3. What is the relationship between the index and the corresponding memory address? 4. Based on your answer to the previous question, why do indexes start at 0 instead of 1?

5. There are (currently) five numbers in the list. Why is lucky[5] out of range? 6. The statement lucky.insert(2, 13) changes the list to [29, 16, 13, 23, 47, 37]. What is the address of the head and tail after inserting 13? 7. In terms of memory operations, what does it take to insert values in the middle of an array? Model 2 Linked List A more flexible strategy for storing a list of numbers in memory is to use pointers. A pointer is a memory address for the next item in the list. For example, the list [10, 20, 30, 40] could be stored in memory this way: Address: 74 75 76 77 78 79 80 81 82 83 Value: 30 78 10 80 40 0 20 74 Index: We use the memory address 0 to represent the null pointer. Questions (10 min) Start time: 8. How many memory cells are needed for each list item? 9. In the diagram above, write the index of each list item below the corresponding memory cell. Note there are only four items in the list, so you should only have four indexes.

10. Is there a relationship between the index and the corresponding memory address? Why or why not? 11. What is the purpose of the null pointer? 12. The statement lucky.insert(2, 25) changes the list to [10, 20, 25, 30, 40]. In Model 2, change the values of memory cells 81, 82, and 82 to perform this insertion. 81 82 83 13. What memory operations does it take to insert a value in the middle of a linked list? 14. Summarize the pros and cons of using an array versus a linked list to represent a list of numbers.

Chapter 8: Data Abstractions Complete the following Chapter Review Problems on pages 396 399. #6 (inserting in contiguous array) #7 (create a linked list in memory) 11 12 13 14 15 16 17 18 19 20 21 22 The head pointer should contain. #8 (update a linked list in memory) circle the values that change After removing N: 30 31 32 33 34 35 36 37 38 39 40 41 After inserting G: 30 31 32 33 34 35 36 37 38 39 40 41 #20 (arrangements using stacks) #25 (queue pointer arithmetic)

#29 (draw a picture of a tree) #30 (fill in memory for a tree) 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 The root pointer should contain. #35 (assume root is stored at 10) 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24