CS342 Data Structures End-of-semester Review S2002.

Slides:



Advertisements
Similar presentations
Chapter 1: INTRODUCTION TO DATA STRUCTURE
Advertisements

SEG4110 – Advanced Software Design and Reengineering TOPIC J C++ Standard Template Library.
1 abstract containers hierarchical (1 to many) graph (many to many) first ith last sequence/linear (1 to 1) set.
Priority Queues and Heaps. Overview Our last ADT: PriorityQueueADT A new data structure: heaps One more sorting algorithm: heapsort Priority Queues and.
Copyright © 2008 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Starting Out with C++ Early Objects Sixth Edition Chapter 17: Linked Lists.
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.
Main Index Contents 11 Main Index Contents Container Types Container Types Sequence Containers Sequence Containers Associative Containers Associative Containers.
Main Index Contents 11 Main Index Contents Container Types Container Types Sequence Containers Sequence Containers Associative Containers Associative Containers.
Starting Out with C++: Early Objects 5/e © 2006 Pearson Education. All Rights Reserved Starting Out with C++: Early Objects 5 th Edition Chapter 17 Linked.
© Copyright 1992–2004 by Deitel & Associates, Inc. and Pearson Education Inc. All Rights Reserved. Chapter 12 – Data Structures Outline 12.1Introduction.
Chapter 4 Linked Lists. © 2005 Pearson Addison-Wesley. All rights reserved4-2 Preliminaries Options for implementing an ADT List –Array has a fixed size.
1 abstract containers hierarchical (1 to many) graph (many to many) first ith last sequence/linear (1 to 1) set.
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.
DATA STRUCTURE Subject Code -14B11CI211.
Data Structures 1- Course Syllabus. 2- Introduction about Data Structures.
DATA STRUCTURES ACM EXECUTIVE BODY 2k11.  A series of elements of same type  Placed in contiguous memory locations  Can be individually referenced.
Data Structures Winter What is a Data Structure? A data structure is a method of organizing data. The study of data structures is particularly important.
Comp 245 Data Structures Stacks. What is a Stack? A LIFO (last in, first out) structure Access (storage or retrieval) may only take place at the TOP NO.
2 Preliminaries Options for implementing an ADT List Array has a fixed size Data must be shifted during insertions and deletions Linked list is able to.
Nirmalya Roy School of Electrical Engineering and Computer Science Washington State University Cpt S 122 – Data Structures Custom Templatized Data Structures.
Copyright © 2011 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Starting Out with C++ Early Objects Seventh Edition by Tony Gaddis, Judy.
Copyright © 2007 Pearson Education, Inc. Publishing as Pearson Addison-Wesley. Ver Chapter 4: Linked Lists Data Abstraction & Problem Solving with.
1 Chapter 3 Lists, Stacks, and Queues Abstract Data Types, Vectors Sections 3.1, 3.2, 3.3, 3.4 Abstract Data Types (ADT) Iterators Implementation of Vector.
Containers Overview and Class Vector
Copyright © 2007 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Chapter 13: Pointers and Dynamic Data Structures Problem Solving, Abstraction,
Stacks 1. Stack  What is a stack? An ordered list where insertions and deletions occur at one end called the top. Also known as last-in-first-out (LIFO)
Searching: Binary Trees and Hash Tables CHAPTER 12 6/4/15 Nyhoff, ADTs, Data Structures and Problem Solving with C++, Second Edition, © 2005 Pearson Education,
Introduction to STL and the vector container class CS342 Data Structures Based on Ford & Topp.
COP3530 Data Structures600 Stack Stack is one the most useful ADTs. Like list, it is a collection of data items. Supports “LIFO” (Last In First Out) discipline.
Main Index Contents 11 Main Index Contents Week 3 – The Vector Container.
Comp 245 Data Structures Linked Lists. An Array Based List Usually is statically allocated; may not use memory efficiently Direct access to data; faster.
CS162 - Topic #11 Lecture: Recursion –Problem solving with recursion –Work through examples to get used to the recursive process Programming Project –Any.
Data structures Abstract data types Java classes for Data structures and ADTs.
Midterm Review CS1220 Spring Disclaimer The following questions are representative of those that will appear on the midterm exam. They do not represent.
Today: Office hours –No tomorrow. M/T- 3-on. Overloading operators Inheritance Review.
Final Exam Review CS Total Points – 60 Points Writing Programs – 50 Points Tracing Algorithms, determining results, and drawing pictures – 50.
Slide 1 Linked Data Structures. Slide 2 Learning Objectives  Nodes and Linked Lists  Creating, searching  Linked List Applications  Stacks, queues.
Standard Template Library The Standard Template Library was recently added to standard C++. –The STL contains generic template classes. –The STL permits.
Introduction to the Standard Template Library (STL) A container class holds a number of similar objects. Examples: –Vector –List –Stack –Queue –Set –Map.
Starting Out with C++ Early Objects Seventh Edition by Tony Gaddis, Judy Walters, and Godfrey Muganda Chapter 17: Linked Lists.
Adapted from Data Structures with C++ using STL: Ford, Topp CS 362: Queues Dr. Nazli Mollah Overview of Lecture  Introduction  The Queue ADT  The Radix.
Copyright © 2002 Pearson Education, Inc. Slide 1.
12/23/2015Engineering Problem Solving with C++, second edition, J. Ingber 1 Engineering Problem Solving with C++, Etter/Ingber Chapter 9 An Introduction.
Data Structures. Abstract Data Type A collection of related data is known as an abstract data type (ADT) Data Structure = ADT + Collection of functions.
1 Queues Queue API Application: Radix Sort Implementation: Using Deque Using Deque Circular Array Circular Array Priority Queue Priority Queue API Implementation.
CISC220 Fall 2009 James Atlas Dec 07: Final Exam Review.
April 27, 2017 COSC Data Structures I Review & Final Exam
Copyright © 2011 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Starting Out with C++ Early Objects Seventh Edition by Tony Gaddis, Judy.
Data Structure and Algorithms
Copyright © 2014, 2008 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Starting Out with C++ Early Objects Eighth Edition by Tony Gaddis,
Main Index Contents 11 Main Index Contents Stacks Further Stack Examples Further Stack Examples Pushing/Popping a Stack Pushing/Popping a Stack Class StackClass.
Data Structures and Algorithm Analysis Dr. Ken Cosh Linked Lists.
 In general, Queue is line of person waiting for their turn at some service counter like ticket window at cinema hall, at bus stand or at railway station.
Chapter 3 Lists, Stacks, Queues. Abstract Data Types A set of items – Just items, not data types, nothing related to programming code A set of operations.
Chapter 12 – Data Structures
5.13 Recursion Recursive functions Functions that call themselves
CS 215 Final Review Ismail abumuhfouz Fall 2014.
Data Structure Interview Question and Answers
Midterm Review.
Homework 4 questions???.
Chapter 4 Linked Lists.
Data Structures Interview / VIVA Questions and Answers
Cinda Heeren / Geoffrey Tien
Introduction to C++ Recursion
Map interface Empty() - return true if the map is empty; else return false Size() - return the number of elements in the map Find(key) - if there is an.
Stack Lesson xx   This module shows you the basic elements of a type of linked list called a stack.
Lecture 13 – Heaps Container Adapters priority_queue – impl. with heap
CSS 342 Data Structures, Algorithms, and Discrete Mathematics I
Review & Lab assignments
Pointers & Dynamic Data Structures
Presentation transcript:

CS342 Data Structures End-of-semester Review S2002

Final Examination (open book, notes)  30-40% on low-level implementations of the operations of various data structures including stacks; queues and priority queues; lists; binary trees; sets and maps.  60-70% on high-level abstractions (STL) and applications of various data structures mentioned above.  Must know the “template” well.

Low level implementations Given a class interface such of any class or ADT: –implement member functions. –use the ADT to solve a particular problem.

The STL  Must know and be able to use the frequently used member functions of string, vector, list, stack, queue, priority queue, and set ADTs to solve some simple problems. You may also be asked to describe the action of a segment of code and analyze its efficiency in terms of Big-O notation.

Examples  Implement the push or pop function of a stack using dynamically allocated or static array storage.  Given nodes and pointers to nodes, implement a function or two to insert or delete a node under a specified condition.  etc.

STL examples  Vector: given the following function template void func(vector &v) { if(v.size( ) >=2) { v[v.size( ) – 2] = v.back( ); v.pop_back( ): }  What is the output of the following code? string str[ ] = {“AA”, “AB”, “AC”, “AD”, “AE”}; int strSize = sizeof(str) / sizeof(string); vector v(str, str + strSize); int i; func(v); for (i = 0; i < v.size( ); i++) cout << v[i] << ‘\t’;

STL examples  list: Display the list created by the following sequence of statements: intList.push_front(0); iter = intList.begin( ); for (int i = 1; i <= 4; i++) { intList.push_front(i); insert(iter, i); }  What if the arguments of insert function is replaced by (iter, *iter) ?

STL examples  Stack: trace the following program and answer some questions: template void f(stack &s, stack &t, int n); int main() { int arr[5] = {2, 1, 7, 4, 3}, i; stack s, t; for (i = 0; i < 5; i++) s.push(arr[i]); f(s, t, 4); outputStack(t);// display content of stack t one element at a time return 0; }

STL examples template void f(stack &s, stack &t, const T item) { T svalue; while (!s.empty( )) { svalue = s.top( ); s.pop( ); if (svalue < item) t.push(svalue); }  What is displayed by the outputStack( ) function?

STL examples  Given the definition of postfix expression (not given here), draw the sequence of stack configuration in the evaluation of the following postfix expression: * % 6 +

STL examples  Queue: what is the contents of the bins and the vector after pass 2 of the radix sort for the following three digit integer? Integers to be sorted:

STL examples  priority queue: use a priority queue object to reorder a vector of integers. What is the order of the vector v = {6, 12, 34, 15, 67, 45, 53, 3, 5} after the execution of function f( )? void f(vector<int &v) {priority_queue pq; int i; for (i = 0; i < v.size( ); i++) pq.push(v[i]); i = 0; while(!pq.empty( )) { v[i] = pq.top( ); pq.pop( ); i++; }

STL examples  linked list: trace the code in function f( ): template void f (node *front) { node *p = front; T value; if (front == NULL) return; while(p->next !=NULL) p = p->next; value = p->nodevalue p->nodeValue = front->nodeValue; front->nodeValue = value }  Assuming the list is front-> 7-> 2 -> 9 -> 5-> NULL, what is the new list?

STL examples  Binary tree: given a binary tree of any node type, what is the order in which nodes are visited in an LRN, LNR, or NLR scan?  A complete tree with 5125 nodes, what is its depth?  Implement a function countNodes( ) which returns the number of nodes in a binary tree as a reference argument: template void countNodes(tnode *t, int & count); // pointer t points to root

Other types of problems  Big-O  Recursive algorithms  Dynamic memory allocations  Graphs (if any, extra points problem)