Data Structures Review 1 Vectors... 1 Linked List... 2 Trees... 2 Heaps... 2 Hash tables... 2

Similar documents
CSCI-1200 Data Structures Fall 2009 Lecture 25 Concurrency & Asynchronous Computing

1. Attempt any three of the following: 15

PROGRAMMING IN C++ (Regulation 2008) Answer ALL questions PART A (10 2 = 20 Marks) PART B (5 16 = 80 Marks) function? (8)

Preface... (vii) CHAPTER 1 INTRODUCTION TO COMPUTERS

G Programming Languages - Fall 2012

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

AP Computer Science 4325

Topics for CSCI 151 Final Exam Wednesday, May 10

CSCI-1200 Data Structures Fall 2011 Lecture 24 Garbage Collection & Smart Pointers

Vectors of Pointers to Objects. Vectors of Objects. Vectors of unique ptrs C++11. Arrays of Objects

CS2013 Course Syllabus Spring 2018 Lecture: Mon/Wed 2:00 P.M. 2:50 P.M. SH C259 Lab: Mon/Wed 2:50 P.M. 4:00 P.M. SH C259

Absolute C++ Walter Savitch

Big Java Late Objects

Dealing with Issues for Interprocess Communication

Data Structures Question Bank Multiple Choice

MARKING KEY The University of British Columbia MARKING KEY Computer Science 260 Midterm #2 Examination 12:30 noon, Thursday, March 15, 2012

CS 445: Data Structures Final Examination: Study Guide

- Alan Perlis. Topic 24 Heaps

Data Structures in C++ Using the Standard Template Library

OBJECT ORIENTED DATA STRUCTURE & ALGORITHMS

About this exam review

More Advanced Class Concepts

CSCI-1200 Data Structures Spring 2017 Lecture 27 Garbage Collection & Smart Pointers

REVIEW OF COMMONLY USED DATA STRUCTURES IN OS

CS250 Final Review Questions

CS250 Final Review Questions

Automatic Memory Management

AP COMPUTER SCIENCE JAVA CONCEPTS IV: RESERVED WORDS

WITH C+ + William Ford University of the Pacific. William Topp University of the Pacific. Prentice Hall, Englewood Cliffs, New Jersey 07632

Lock-Free and Practical Doubly Linked List-Based Deques using Single-Word Compare-And-Swap

IN COLLABORATION WITH IVTB. Diploma in Information Technology

Table of Contents. Chapter 1: Introduction to Data Structures... 1

CSCE 210/2201 Data Structures and Algorithms. Prof. Amr Goneid. Fall 2018

CS250 Final Review Questions

Fundamentals of Data Structure

Supplement I.A: Glossary. For Introduction to C++ Programming, Second Edition By Y. Daniel Liang

Memory Management. Memory Management... Memory Management... Interface to Dynamic allocation

CMSC 341 Leftist Heaps

+ Abstract Data Types

Overloading Operators in C++

THREADS & CONCURRENCY

CS301 - Data Structures Glossary By

2. Reachability in garbage collection is just an approximation of garbage.

CMSC 341 Lecture 15 Leftist Heaps

Supplement I.A: Glossary. For Introduction to C++ Programming, Third Edition By Y. Daniel Liang

DATA STRUCTURES THROUGH C++

Acknowledgements These slides are based on Kathryn McKinley s slides on garbage collection as well as E Christopher Lewis s slides

Lesson 12 - Operator Overloading Customising Operators

Dynamic Data Structures

Data Structures and Abstractions with Java

Supplement I.A: Glossary For Introduction to Programming and Data Structures with C++ Fourth Edition By Y. Daniel Liang

CSE 100: C++ TEMPLATES AND ITERATORS

MLR Institute of Technology

CMSC 341 Lecture 15 Leftist Heaps

Lecture 23: Object Lifetime and Garbage Collection

Garbage Collection Algorithms. Ganesh Bikshandi

Garbage Collection. Hwansoo Han

3137 Data Structures and Algorithms in C++

I BSc(IT) [ Batch] Semester II Core: Object Oriented Programming With C plus plus - 212A Multiple Choice Questions.

Java SE 7 Programming

Slide Set 14. for ENCM 339 Fall Steve Norman, PhD, PEng. Electrical & Computer Engineering Schulich School of Engineering University of Calgary

Selection, Bubble, Insertion, Merge, Heap, Quick Bucket, Radix

Acknowledgments I INTRODUCTION 1

CSCE 210/2201 Data Structures and Algorithms. Prof. Amr Goneid

9/29/2014. CS341: Operating System Mid Semester Model Solution Uploaded Semaphore ADT: wait(), signal()

Distance Learning Advanced C++ - Programming Models, boost and Parallel Computing

Lecture 13: Garbage Collection

Overloaded Operators, Functions, and Students

Thus, it is reasonable to compare binary search trees and binary heaps as is shown in Table 1.

Lecture Notes on Advanced Garbage Collection

Draw the resulting binary search tree. Be sure to show intermediate steps for partial credit (in case your final tree is incorrect).

Name: 1 stack<int> s; 2 s.push(9) 3 s.push(5) 4 s.push(10) 5 s.push(1) 6 s.pop() 7 s.pop() 8 s.push(0) 9 s.pop() 10 s.pop() 11 s.

Containers and the Standard Template Library (STL)

CSL 201 Data Structures Mid-Semester Exam minutes

An Introduction to Parallel Systems

abstract binary class composition diamond Error Exception executable extends friend generic hash implementation implements

CS 520 Theory and Practice of Software Engineering Fall 2018

Reference Counting. Reference counting: a way to know whether a record has other users

Total Score /15 /20 /30 /10 /5 /20 Grader

CS200 Final Exam Fall 2007

182 review 1. Course Goals

CSE Traditional Operating Systems deal with typical system software designed to be:

INSTITUTE OF AERONAUTICAL ENGINEERING (Autonomous) Dundigal, Hyderabad

CPSC 331 Term Test #2 March 26, 2007

APJ ABDUL KALAM TECHNOLOGICAL UNIVERSITY THIRD SEMESTER B.TECH DEGREE EXAMINATION, JULY 2017 CS205: DATA STRUCTURES (CS, IT)

Computer Science 302 Spring 2007 Practice Final Examination: Part I

Deadlock and Monitors. CS439: Principles of Computer Systems September 24, 2018

PRACTICAL LIST FOR EVEN SEMESTERS (PGDCA/MCA/MSC (CS))

CS/ENGRD 2110 Object-Oriented Programming and Data Structures Spring 2012 Thorsten Joachims. Lecture 25: Review and Open Problems

CSC 427: Data Structures and Algorithm Analysis. Fall 2004

Lecture 7: Binding Time and Storage

Total No. of Questions :09] [Total No. of Pages : 02. II/IV B.Tech. DEGREE EXAMINATIONS, NOV/DEC First Semester CSE/IT DATA STRUCTURES USING C

Object-Oriented Design (OOD) and C++

University of Waterloo Department of Electrical and Computer Engineering ECE 250 Data Structures and Algorithms. Final Examination T09:00

Introduction p. 1 Pseudocode p. 2 Algorithm Header p. 2 Purpose, Conditions, and Return p. 3 Statement Numbers p. 4 Variables p. 4 Algorithm Analysis

Operating Systems. Designed and Presented by Dr. Ayman Elshenawy Elsefy

CS365 Midterm -- Spring 2019

Computer Science 385 Design and Analysis of Algorithms Siena College Spring Lab 8: Greedy Algorithms Due: Start of your next lab session

Containers and genericity. A standardized naming scheme. Cursor properties. Lists. Adding a cell. A specific implementation: (singly) linked lists

BRONX COMMUNITY COLLEGE of the City University of New York DEPARTMENT OF MATHEMATICS AND COMPUTER SCIENCE. Sample Final Exam

Transcription:

Contents Data Structures Review 1 Vectors................................... 1 Linked List................................. 2 Trees..................................... 2 Heaps.................................... 2 Hash tables................................. 2 Miscellaneous Topics 3 Operator Overloading........................... 3 Inheritance................................. 3 Relationships............................. 3 Polymorphism............................. 4 Diamond Problem.......................... 4 Garbage Collection............................. 4 Reference Counting.......................... 4 Stop And Copy............................ 4 Mark And Sweep........................... 5 Concurrency and Asynchronous Computing............... 5 Acceptable behaviors of concurrent programs........... 5 Mutexes, Condition Variables.................... 5 Dining philosopher s problem.................... 5 Data Structures Review See problem: 9 Vectors See problems 1.1, 12 1

Linked List See problem: 5 Variations: singly linked, doubly linked. Implementations for stack, queue, deque. Trees See problems: 3, 13 Variations: binary tree, binary search tree, quad tree, red-black tree. Implementation for maps, sets. traversal in-order pre-order post-order meaning left, current, right left, right, current current, left, right Heaps See problems: 4, 14 Variations: min-heap, max-heap (priority queues), leftist heaps Can implement binary heap as array: size_t get_parent(size_t i) { return (i-1)/2; } size_t get_left(size_t i) { return 2*i+1; } size_t get_right(size_t i) { return 2*i+2; } Hash tables See problems: 8.4 Variations: separate chaining, open addressing. Index found by using hash function. m_hash(obj) % len 2

Miscellaneous Topics Note! misc problems for order notation: 10 Note!! misc memory-related problems: 11.1, 12, 16 Operator Overloading See problems: 2, 11.4 class Complex { public: Complex(double x=0, double y=0) : real_(x), imag_(y) {} Complex(Complex const& old) : real_(old.real_), imag_(old.imag_) {} Complex& operator= (Complex const& rhs); double Real() const; void SetReal(double x); double Imaginary() const; void SetImaginary(double y); double Magnitude() const; Complex operator+ (Complex const& rhs) const; Complex operator- () const; // (3) friend istream& operator>> (istream& istr, Complex& c); // (1) private: double real_, imag_; }; Complex operator- (Complex const& left, Complex const& right); ostream& operator<< (ostream& ostr, Complex const& c); // (2) Inheritance See problem: 15 Relationships 3

Relationship Is-A Has-A As-A Meaning C1 is a C2 C1 has a C2 C1 is implemented as a C2 Polymorphism Animal animal = Bird(); animal.doanimalnoise(); // does not work Animal *animal = new Bird(); animal->doanimalnoise(); // tweet For the curious: Upcasting, Object Slicing Diamond Problem A pokemon belongs to two egg groups Both egg groups subclass from the pokemon class Each egg group should virtually inherit from the egg superclass Garbage Collection See problems: 7, 8.1, 8.2 Reference Counting + Fast and Incremental Can t handle cyclical data structures!? Requires 33% extra memory (1 integer per node) Stop And Copy requires a long pause in program execution + can handle cyclical data structures! requires 100% extra memory (you can only use half) + runs fast if most of the memory is garbage (it only touches the nodes reachable from the root) 4

+ data is clustered together and memory is de-fragmented Mark And Sweep requres long pause in program execution + can handle cyclical data structures! + requires 1% extra memory (just one bit per node) runs the same speed regardless of how much memory is garbage. It must touch all nodes in the mark phase, and must link together all garbage nodes into a free list. Concurrency and Asynchronous Computing See problems: 6, 8.3 Acceptable behaviors of concurrent programs No two operations that change any shared state variables may occur at the same time. The concurrent system should produce the same result as if the threads/processes had run sequentially in some order. Mutexes, Condition Variables serialize non-atomic operations (std::map::operator[], std::priority_queue::pop()) behind mutex. condition variables mark end of concurrent operation; can move on. Dining philosopher s problem Deadlock occurs if we do not have global orderings of resources. i.e. the philosophers are all left handed, and will always wait on the chop stick to the left. 5