# Overview of Data Structures

Save this PDF as:

Size: px
Start display at page:

## Transcription

1 UNIT 3 Concrete Data Types Classification of Data Structures Concrete vs. Abstract Data Structures Most Important Concrete Data Structures Arrays Records Linked Lists Binary Trees Overview of Data Structures There are two kinds of data types: simple or atomic structured data types or data structures An atomic data type represents a single data item. A data structure, on the other hand, has a number of components a structure a set of operations Next slide shows a classification of the most important data structures (according to some specific properties) Unit 3- Concrete Data Types 2

2 Data Structure Classification Unit 3- Concrete Data Types 3 Concrete Versus Abstract Types Concrete data types or structures (CDT's) are direct implementations of a relatively simple concept. Abstract Data Types (ADT's) offer a high level view (and use) of a concept independent of its implementation. Example: Implementing a student record: CDT: Use a struct with public data and no functions to represent the record does not hide anything ADT: Use a class with private data and public functions to represent the record hides structure of the data, etc. Concrete data structures are divided into: contiguous linked hybrid Some fundamental concrete data structures: arrays records, linked lists trees graphs. Unit 3- Concrete Data Types 4

3 C++ Arrays A C++ array has: a collection of objects of the same type a set of index values in the range [0,n] Structure: objects are stored in consecutive locations each object has a unique index Operations: [i] accesses the (i+1)th object E.g. In char word[8]; word is declared to be an array of 8 characters 8 is the dimension of the array dimension must be known at compile time. Unit 3- Concrete Data Types 5 C++ Arrays (cont d) Array indices (or subscripts ) start at 0. word 's elements are: word[0], word[1],..., word[7] An array can also be initialized, but with constants only int ia[] = {1,2,0}; Arrays cannot be assigned to one another; each element must be assigned in turn Unit 3- Concrete Data Types 6

4 Arrays & Pointers Are closely related. The declaration: type a[10] allocates space for 10 items of type type items are stored in consecutive memory locations Suppose we declare int a[10]; then C++ treats consecutive elements in the array as having consecutive addresses: &a[0] < &a[1] <... < &a[9] and &a[1] = &a[0] + 1 &a[i] = &a[i-1] + 1 a is a variable of type pointer to type, &a[i] is the same as a+i a[i] is the same as *(a+i) There are two ways to access the elements of an array. We can use either: array subscripts, or pointers Unit 3- Concrete Data Types 7 Example Suppose we declare: int i, a[10] The following two statements output the elements of a 1. for (i = 0; i < 10; i++) cout << a[i]; // using subscripts 2. for (i = 0; i < 10; i++) cout << *(a + i); // using pointers If int * p; then p = &a[i] or p = a + i makes p point to the i-th element of a. Straying beyond the range of an array results in a segmentation fault. Pointers are not integers Exception: NULL (which is 0) can be assigned to a pointer. NULL is the undefined pointer value Unit 3- Concrete Data Types 8

5 Dynamic arrays Are declared as pointers Space for these arrays is allocated later, when the size is known Example: Consider the declarations: int b[10]; int * a; a = new int[10]; Then: a and b are both arrays b is a fixed array ; a is a dynamic array [] can also be used on a a[2] is the third element of a BUT b has space for ten integers a has space for one pointer space for its elements must be allocated by new b is a constant pointer; a can be changed A dynamic array can be expanded I.e. to expand a we can write: int* temp = new int[10 + n]; for (int i = 0; i<10; i++) temp[i] = a[i]; delete a; a = temp; Example Using Dynamic Arrays: Implementation of EmployeeDB using dynamic arrays: EmployeeDB (Dynamic Array) Unit 3- Concrete Data Types 9 Passing Array Parameters Arrays are always passed by reference Suppose we declare, int a[10]; To pass array a to a function f, f may be declared as: type f( int d[], int size ) or type f( int* d, int size) In any case, f is called by f(a, sizeof a). Unit 3- Concrete Data Types 10

6 Multi-dimensional Arrays To store the temperature measured at each hour of each day for a week, we can declare : int temp[7][24]; temp is a 2-dimensional array. to get the temperature at noon on Monday, we can do: temp[1][11]; To pass a multi-dimensional array to a function, the first subscript can be free. i.e. To pass temp to f, f may been declared as... f(int t[][24], int size1); or... f(int (*t)[24], int size1); or... f(int** t, int size1, int size2) In the last declaration, t is a pointer to a pointer, while in the other two t is a pointer to an array of 24 integers Unit 3- Concrete Data Types 11 Multi-dimensional Arrays vs. Pointers Given the declarations: int t[7][24]; int* s[7]; int** r; we can allocate adequate space to s and r so that t, s and r behave as 2d arrays i.e t[3][4] s[3][4] r[3][4] all work fine But t is a true 2-dimensional array (has space allocated) s is an array of 7 pointers (each pointing to an array of 24 integers) r is a pointer to a pointer A use of semi-dynamic arrays: arrays with different row length i.e. char* day[8] = {"Illegal day name", "Sunday",..., "Friday"} Unit 3- Concrete Data Types 12

7 Features of Arrays Simple structures. Their size is fixed; dynamic arrays can be expanded, but expansion is expensive. Insertion and deletion in the middle is difficult. Algorithms are simple. Accessing the i-th element is very efficient Unit 3- Concrete Data Types 13 C++ Records (struct's) Records allow us to group data and use them together as a unit The record type has: a collection of objects of same or different type each object has a unique name.obname accesses the object with name obname. C++ uses "struct" for records. They are also called "structures" in C++. For instance, after declaring struct date { int day; char* month; int year; }; date is now a new type; it can be used as: date today = {20, "jun", 1993}; We can access the components of a structure using the select member operator ". E.g. today.month[2] // 'n' A C++ struct may also have function members. The difference between classes and records: by default, a class components are private, while a struct's components are public Unit 3- Concrete Data Types 14

8 C++ Records (cont ) Structures are commonly used to implement lists, trees, etc. An item of these types of structures usually looks like: struct item { int data; item* next; } ; We can then declare: item item1, item2, *head, *current; The physical structure of this would look like the following: Unit 3- Concrete Data Types 15 The operator -> Structure components can be accessed by pointers using the point at member operator "->". E.g. If we set head = &item1 then head -> data is the data field of item1. Structures can be copied member-wise : item2 = *head We can also pass a structure as a parameter to a function. However, it is usually more efficient to pass a structure by reference, or to pass a pointer to the structure instead. i.e. void f(const date& d ) or void f(const date* d ) Unit 3- Concrete Data Types 16

9 Linked Lists A (singly ) linked list is a sequence of nodes linked together: They represent sequences of data items. Each node in the list contains the item and a pointer to the next element. The last pointer is set to 0 (or NULL) to denote the end of the list. The whole list is defined by a pointer to the first item (called list here). In C++ the node and the list are defined as: or // TYPE is the type of our items typedef int TYPE; struct node { TYPE item; node* next; }; typedef int TYPE; class node { public: TYPE item; node* next; }; Unit 3- Concrete Data Types 17 Common Operations on Linked List Insert an item in the list. Many types of insertion: insert_first: insert item at the front of list insert_last: insert item at the end of the list insert_after: insert item in list after a certain node find: finds the node in the list with a given item delete_item: removes an item from the list printnode: prints the contents of a node A Singly Linked List Toolkit The following files contain an implementation of a module (or toolkit) for the singly linked list structure: Singly Linked List Example Using Linked Lists Implementation of EmployeeDB using singly linked lists: EmployeeDB (Linked List ) Unit 3- Concrete Data Types 18

10 Head Nodes Processing of this first node is different from processing of the other nodes. A head node is a dummy node at the beginning of the list. It is similar to the other nodes, except that it has a special value It is never deleted. Processing every actual node is the same. Usually, it is more confusing and it is not used. Unit 3- Concrete Data Types 19 Circular Linked Lists (or rings) A circular linked list looks like: A circular linked list is appropriate when there is no distinct first and last item. The algorithms for circular linked lists are similar to those for singly linked lists, except that none of the links is null the end of the list is reached when curr->next == head Unit 3- Concrete Data Types 20

12 Binary Trees A binary tree is a structure that is either empty, or it consists of a node called a root and two binary trees called the left subtree and the right subtree. Pictorially a binary tree looks like the following: Unit 3- Concrete Data Types 23 Parents, Children & Paths Parents & Children: If there is a link from node N to M then N is the parent of M and M is a child of N. The root has no parent. A leaf is a node on the bottom level of the tree without any children. A node can have a maximum of 2 children. A tree cannot have cycles. Grandparents, grand children, ancestors, descendants are defined similarly. Path from N1 to Nk a sequence of nodes N1, N2,..., Nk, where Ni is a parent of Ni+1. path length : # of nodes in the path from N1 to Nk (some authors use # of edges). Unit 3- Concrete Data Types 24

13 Depth or level of a node N length of the unique path from the root to N the level of the root is 1. Height of a node N: length of the longest path from N to a leaf a leaf's height is 1. Height of the tree: height of its root The number of nodes in a binary tree of height h is >= h and <= 2h -1 nodes. Unit 3- Concrete Data Types 25 Implementation of Trees Implementation of a binary tree in C++: a node in the tree contains the item and two pointers to the subtrees: typedef int TYPE ; struct bnode { TYPE item; bnode* left; bnode* right; }; A C++ binary search tree is just a pointer to the root. Unit 3- Concrete Data Types 26

14 Common Operations for Binary Trees Insert an item in the tree: To the left or right of a node: insert_left: insert item on the left of a given node insert_right: insert item on the right of a given node find: finds the node in the tree with a given item find_parent: finds the parent of a given node in the tree delete_node: removes the node with the given item from the tree print: prints the whole tree (sideways) A Binary Tree Toolkit An implementation of a module (or toolkit) for the binary tree structure can be found in the Examples: Binary Tree Unit 3- Concrete Data Types 27 Traversing a binary tree There are three types of traversal. preorder : node then left subtree then right subtree inorder : left subtree then node then right subtree postorder : left subtree then right subtree then node Inorder traversal: The following code applies a function visit to every node in the tree inorder: void inorder( bnode* root ) { // apply the function visit to every node in the tree, inorder if( root!= NULL ) { inorder( root->left); visit ( root ); // apply visit to the root of the tree inorder( root->right); } } Tree traversal is not usually implemented by a function. What is shown here is just an example. Unit 3- Concrete Data Types 28

15 Higher trees and Graphs N-ary Trees Like binary trees except that a node may have up to n subtrees. Graphs More general than trees. They can have cycles and are usually hybrid structures. Unit 3- Concrete Data Types 29

### UNIVERSITI MALAYSIA SARAWAK KOTA SAMARAHAN SARAWAK PSD2023 ALGORITHM & DATA STRUCTURE

STUDENT IDENTIFICATION NO UNIVERSITI MALAYSIA SARAWAK 94300 KOTA SAMARAHAN SARAWAK FAKULTI SAINS KOMPUTER & TEKNOLOGI MAKLUMAT (Faculty of Computer Science & Information Technology) Diploma in Multimedia

### Ordered Lists and Binary Trees

Data Structures and Algorithms Ordered Lists and Binary Trees Chris Brooks Department of Computer Science University of San Francisco Department of Computer Science University of San Francisco p.1/62 6-0:

### DATA STRUCTURES USING C

DATA STRUCTURES USING C QUESTION BANK UNIT I 1. Define data. 2. Define Entity. 3. Define information. 4. Define Array. 5. Define data structure. 6. Give any two applications of data structures. 7. Give

### 1) The postfix expression for the infix expression A+B*(C+D)/F+D*E is ABCD+*F/DE*++

Answer the following 1) The postfix expression for the infix expression A+B*(C+D)/F+D*E is ABCD+*F/DE*++ 2) Which data structure is needed to convert infix notations to postfix notations? Stack 3) The

Unordered Linked Lists Derive class unorderedlinkedlist from the abstract class linkedlisttype Implement the operations search, insertfirst, insertlast, deletenode See code on page 292 Defines an unordered

### Data Structures and Algorithms

Data Structures and Algorithms CS245-2016S-06 Binary Search Trees David Galles Department of Computer Science University of San Francisco 06-0: Ordered List ADT Operations: Insert an element in the list

### Converting a Number from Decimal to Binary

Converting a Number from Decimal to Binary Convert nonnegative integer in decimal format (base 10) into equivalent binary number (base 2) Rightmost bit of x Remainder of x after division by two Recursive

### Data Structure with C

Subject: Data Structure with C Topic : Tree Tree A tree is a set of nodes that either:is empty or has a designated node, called the root, from which hierarchically descend zero or more subtrees, which

### Binary Trees and Huffman Encoding Binary Search Trees

Binary Trees and Huffman Encoding Binary Search Trees Computer Science E119 Harvard Extension School Fall 2012 David G. Sullivan, Ph.D. Motivation: Maintaining a Sorted Collection of Data A data dictionary

### Questions 1 through 25 are worth 2 points each. Choose one best answer for each.

Questions 1 through 25 are worth 2 points each. Choose one best answer for each. 1. For the singly linked list implementation of the queue, where are the enqueues and dequeues performed? c a. Enqueue in

### Data Structures Using C++ 2E. Chapter 5 Linked Lists

Data Structures Using C++ 2E Chapter 5 Linked Lists Test #1 Next Thursday During Class Cover through (near?) end of Chapter 5 Objectives Learn about linked lists Become aware of the basic properties of

### Learning Outcomes. COMP202 Complexity of Algorithms. Binary Search Trees and Other Search Trees

Learning Outcomes COMP202 Complexity of Algorithms Binary Search Trees and Other Search Trees [See relevant sections in chapters 2 and 3 in Goodrich and Tamassia.] At the conclusion of this set of lecture

### Data Structure [Question Bank]

Unit I (Analysis of Algorithms) 1. What are algorithms and how they are useful? 2. Describe the factor on best algorithms depends on? 3. Differentiate: Correct & Incorrect Algorithms? 4. Write short note:

Lecture 11 Doubly Linked Lists & Array of Linked Lists In this lecture Doubly linked lists Array of Linked Lists Creating an Array of Linked Lists Representing a Sparse Matrix Defining a Node for a Sparse

### root node level: internal node edge leaf node CS@VT Data Structures & Algorithms 2000-2009 McQuain

inary Trees 1 A binary tree is either empty, or it consists of a node called the root together with two binary trees called the left subtree and the right subtree of the root, which are disjoint from each

### Binary Search Trees (BST)

Binary Search Trees (BST) 1. Hierarchical data structure with a single reference to node 2. Each node has at most two child nodes (a left and a right child) 3. Nodes are organized by the Binary Search

### Output: 12 18 30 72 90 87. struct treenode{ int data; struct treenode *left, *right; } struct treenode *tree_ptr;

50 20 70 10 30 69 90 14 35 68 85 98 16 22 60 34 (c) Execute the algorithm shown below using the tree shown above. Show the exact output produced by the algorithm. Assume that the initial call is: prob3(root)

### 12 Abstract Data Types

12 Abstract Data Types 12.1 Source: Foundations of Computer Science Cengage Learning Objectives After studying this chapter, the student should be able to: Define the concept of an abstract data type (ADT).

Linked List as an ADT (cont d.) Default constructor Initializes list to an empty state Destroy the list Deallocates memory occupied by each node Initialize the list Reinitializes list to an empty state

### The following themes form the major topics of this chapter: The terms and concepts related to trees (Section 5.2).

CHAPTER 5 The Tree Data Model There are many situations in which information has a hierarchical or nested structure like that found in family trees or organization charts. The abstraction that models hierarchical

### 10CS35: Data Structures Using C

CS35: Data Structures Using C QUESTION BANK REVIEW OF STRUCTURES AND POINTERS, INTRODUCTION TO SPECIAL FEATURES OF C OBJECTIVE: Learn : Usage of structures, unions - a conventional tool for handling a

### 1 2-3 Trees: The Basics

CS10: Data Structures and Object-Oriented Design (Fall 2013) November 1, 2013: 2-3 Trees: Inserting and Deleting Scribes: CS 10 Teaching Team Lecture Summary In this class, we investigated 2-3 Trees in

### Data Structures. Level 6 C30151. www.fetac.ie. Module Descriptor

The Further Education and Training Awards Council (FETAC) was set up as a statutory body on 11 June 2001 by the Minister for Education and Science. Under the Qualifications (Education & Training) Act,

### TREE BASIC TERMINOLOGIES

TREE Trees are very flexible, versatile and powerful non-liner data structure that can be used to represent data items possessing hierarchical relationship between the grand father and his children and

### Binary Search Trees. A Generic Tree. Binary Trees. Nodes in a binary search tree ( B-S-T) are of the form. P parent. Key. Satellite data L R

Binary Search Trees A Generic Tree Nodes in a binary search tree ( B-S-T) are of the form P parent Key A Satellite data L R B C D E F G H I J The B-S-T has a root node which is the only node whose parent

### B-Trees. Algorithms and data structures for external memory as opposed to the main memory B-Trees. B -trees

B-Trees Algorithms and data structures for external memory as opposed to the main memory B-Trees Previous Lectures Height balanced binary search trees: AVL trees, red-black trees. Multiway search trees:

### ECE 250 Data Structures and Algorithms MIDTERM EXAMINATION 2008-10-23/5:15-6:45 REC-200, EVI-350, RCH-106, HH-139

ECE 250 Data Structures and Algorithms MIDTERM EXAMINATION 2008-10-23/5:15-6:45 REC-200, EVI-350, RCH-106, HH-139 Instructions: No aides. Turn off all electronic media and store them under your desk. If

### BM267 - Introduction to Data Structures

BM267 - Introduction to Data Structures 3. Elementary Data Structures Ankara University Computer Engineering Department BLM267 1 Objectives Learn about elementary data structures - Data structures that

### Quiz 4 Solutions EECS 211: FUNDAMENTALS OF COMPUTER PROGRAMMING II. 1 Q u i z 4 S o l u t i o n s

Quiz 4 Solutions Q1: What value does function mystery return when called with a value of 4? int mystery ( int number ) { if ( number

### PES Institute of Technology-BSC QUESTION BANK

PES Institute of Technology-BSC Faculty: Mrs. R.Bharathi CS35: Data Structures Using C QUESTION BANK UNIT I -BASIC CONCEPTS 1. What is an ADT? Briefly explain the categories that classify the functions

### Data Structures Using C++

Data Structures Using C++ 1.1 Introduction Data structure is an implementation of an abstract data type having its own set of data elements along with functions to perform operations on that data. Arrays

### A binary search tree or BST is a binary tree that is either empty or in which the data element of each node has a key, and:

Binary Search Trees 1 The general binary tree shown in the previous chapter is not terribly useful in practice. The chief use of binary trees is for providing rapid access to data (indexing, if you will)

### Analysis of a Search Algorithm

CSE 326 Lecture 4: Lists and Stacks 1. Agfgd 2. Dgsdsfd 3. Hdffdsf 4. Sdfgsfdg 5. Tefsdgass We will review: Analysis: Searching a sorted array (from last time) List ADT: Insert, Delete, Find, First, Kth,

### MAX = 5 Current = 0 'This will declare an array with 5 elements. Inserting a Value onto the Stack (Push) -----------------------------------------

=============================================================================================================================== DATA STRUCTURE PSEUDO-CODE EXAMPLES (c) Mubashir N. Mir - www.mubashirnabi.com

### A binary search tree is a binary tree with a special property called the BST-property, which is given as follows:

Chapter 12: Binary Search Trees A binary search tree is a binary tree with a special property called the BST-property, which is given as follows: For all nodes x and y, if y belongs to the left subtree

### Lecture 12 Doubly Linked Lists (with Recursion)

Lecture 12 Doubly Linked Lists (with Recursion) In this lecture Introduction to Doubly linked lists What is recursion? Designing a node of a DLL Recursion and Linked Lists o Finding a node in a LL (recursively)

### Data Structures Using C++ 2E. Chapter 5 Linked Lists

Data Structures Using C++ 2E Chapter 5 Linked Lists Doubly Linked Lists Traversed in either direction Typical operations Initialize the list Destroy the list Determine if list empty Search list for a given

### Symbol Tables. Introduction

Symbol Tables Introduction A compiler needs to collect and use information about the names appearing in the source program. This information is entered into a data structure called a symbol table. The

### Previous Lectures. B-Trees. External storage. Two types of memory. B-trees. Main principles

B-Trees Algorithms and data structures for external memory as opposed to the main memory B-Trees Previous Lectures Height balanced binary search trees: AVL trees, red-black trees. Multiway search trees:

### Data Structures, Practice Homework 3, with Solutions (not to be handed in)

Data Structures, Practice Homework 3, with Solutions (not to be handed in) 1. Carrano, 4th edition, Chapter 9, Exercise 1: What is the order of each of the following tasks in the worst case? (a) Computing

### 5. A full binary tree with n leaves contains [A] n nodes. [B] log n 2 nodes. [C] 2n 1 nodes. [D] n 2 nodes.

1. The advantage of.. is that they solve the problem if sequential storage representation. But disadvantage in that is they are sequential lists. [A] Lists [B] Linked Lists [A] Trees [A] Queues 2. The

### Analysis of Algorithms I: Binary Search Trees

Analysis of Algorithms I: Binary Search Trees Xi Chen Columbia University Hash table: A data structure that maintains a subset of keys from a universe set U = {0, 1,..., p 1} and supports all three dictionary

### Abstract Data Type. EECS 281: Data Structures and Algorithms. The Foundation: Data Structures and Abstract Data Types

EECS 281: Data Structures and Algorithms The Foundation: Data Structures and Abstract Data Types Computer science is the science of abstraction. Abstract Data Type Abstraction of a data structure on that

### Binary Search Trees CMPSC 122

Binary Search Trees CMPSC 122 Note: This notes packet has significant overlap with the first set of trees notes I do in CMPSC 360, but goes into much greater depth on turning BSTs into pseudocode than

### Data Structure and Algorithm I Midterm Examination 120 points Time: 9:10am-12:10pm (180 minutes), Friday, November 12, 2010

Data Structure and Algorithm I Midterm Examination 120 points Time: 9:10am-12:10pm (180 minutes), Friday, November 12, 2010 Problem 1. In each of the following question, please specify if the statement

### BSc (Hons) Business Information Systems, BSc (Hons) Computer Science with Network Security. & BSc. (Hons.) Software Engineering

BSc (Hons) Business Information Systems, BSc (Hons) Computer Science with Network Security & BSc. (Hons.) Software Engineering Cohort: BIS/05/FT BCNS/05/FT BSE/05/FT Examinations for 2005-2006 / Semester

### The ADT Binary Search Tree

The ADT Binary Search Tree The Binary Search Tree is a particular type of binary tree that enables easy searching for specific items. Definition The ADT Binary Search Tree is a binary tree which has an

### KITES TECHNOLOGY COURSE MODULE (C, C++, DS)

KITES TECHNOLOGY 360 Degree Solution www.kitestechnology.com/academy.php info@kitestechnology.com technologykites@gmail.com Contact: - 8961334776 9433759247 9830639522.NET JAVA WEB DESIGN PHP SQL, PL/SQL

### Chapter 14 The Binary Search Tree

Chapter 14 The Binary Search Tree In Chapter 5 we discussed the binary search algorithm, which depends on a sorted vector. Although the binary search, being in O(lg(n)), is very efficient, inserting a

### 1. The memory address of the first element of an array is called A. floor address B. foundation addressc. first address D.

1. The memory address of the first element of an array is called A. floor address B. foundation addressc. first address D. base address 2. The memory address of fifth element of an array can be calculated

### From Last Time: Remove (Delete) Operation

CSE 32 Lecture : More on Search Trees Today s Topics: Lazy Operations Run Time Analysis of Binary Search Tree Operations Balanced Search Trees AVL Trees and Rotations Covered in Chapter of the text From

### Binary Search Trees. Data in each node. Larger than the data in its left child Smaller than the data in its right child

Binary Search Trees Data in each node Larger than the data in its left child Smaller than the data in its right child FIGURE 11-6 Arbitrary binary tree FIGURE 11-7 Binary search tree Data Structures Using

### Stacks. Linear data structures

Stacks Linear data structures Collection of components that can be arranged as a straight line Data structure grows or shrinks as we add or remove objects ADTs provide an abstract layer for various operations

### Linked Lists, Stacks, Queues, Deques. It s time for a chainge!

Linked Lists, Stacks, Queues, Deques It s time for a chainge! Learning Goals After this unit, you should be able to... Differentiate an abstraction from an implementation. Define and give examples of problems

### recursion, O(n), linked lists 6/14

recursion, O(n), linked lists 6/14 recursion reducing the amount of data to process and processing a smaller amount of data example: process one item in a list, recursively process the rest of the list

LINKED DATA STRUCTURES 1 Linked Lists A linked list is a structure in which objects refer to the same kind of object, and where: the objects, called nodes, are linked in a linear sequence. we keep a reference

### Data Structures Fibonacci Heaps, Amortized Analysis

Chapter 4 Data Structures Fibonacci Heaps, Amortized Analysis Algorithm Theory WS 2012/13 Fabian Kuhn Fibonacci Heaps Lacy merge variant of binomial heaps: Do not merge trees as long as possible Structure:

### Binary Search Trees 3/20/14

Binary Search Trees 3/0/4 Presentation for use ith the textbook Data Structures and Algorithms in Java, th edition, by M. T. Goodrich, R. Tamassia, and M. H. Goldasser, Wiley, 04 Binary Search Trees 4

### Krishna Institute of Engineering & Technology, Ghaziabad Department of Computer Application MCA-213 : DATA STRUCTURES USING C

Tutorial#1 Q 1:- Explain the terms data, elementary item, entity, primary key, domain, attribute and information? Also give examples in support of your answer? Q 2:- What is a Data Type? Differentiate

### 1. Relational database accesses data in a sequential form. (Figures 7.1, 7.2)

Chapter 7 Data Structures for Computer Graphics (This chapter was written for programmers - option in lecture course) Any computer model of an Object must comprise three different types of entities: 1.

### Any two nodes which are connected by an edge in a graph are called adjacent node.

. iscuss following. Graph graph G consist of a non empty set V called the set of nodes (points, vertices) of the graph, a set which is the set of edges and a mapping from the set of edges to a set of pairs

### Parallelization: Binary Tree Traversal

By Aaron Weeden and Patrick Royal Shodor Education Foundation, Inc. August 2012 Introduction: According to Moore s law, the number of transistors on a computer chip doubles roughly every two years. First

### Data Structures and Data Manipulation

Data Structures and Data Manipulation What the Specification Says: Explain how static data structures may be used to implement dynamic data structures; Describe algorithms for the insertion, retrieval

### Algorithms and Data Structures Exercise for the Final Exam (17 June 2014) Stack, Queue, Lists, Trees, Heap

Algorithms and Data Structures Exercise for the Final Exam (17 June 2014) Stack, Queue, Lists, Trees, Heap Singly linked list (1) Data about exam results are stored into a singly linked list. Each list

### Algorithms and Data Structures

Algorithms and Data Structures Part 2: Data Structures PD Dr. rer. nat. habil. Ralf-Peter Mundani Computation in Engineering (CiE) Summer Term 2016 Overview general linked lists stacks queues trees 2 2

### A binary heap is a complete binary tree, where each node has a higher priority than its children. This is called heap-order property

CmSc 250 Intro to Algorithms Chapter 6. Transform and Conquer Binary Heaps 1. Definition A binary heap is a complete binary tree, where each node has a higher priority than its children. This is called

### Binary Heap Algorithms

CS Data Structures and Algorithms Lecture Slides Wednesday, April 5, 2009 Glenn G. Chappell Department of Computer Science University of Alaska Fairbanks CHAPPELLG@member.ams.org 2005 2009 Glenn G. Chappell

### Data Structures and Algorithms Lists

Data Structures and Algorithms Lists Chris Brooks Department of Computer Science University of San Francisco Department of Computer Science University of San Francisco p.1/19 5-0: Abstract Data Types An

### Exam study sheet for CS2711. List of topics

Exam study sheet for CS2711 Here is the list of topics you need to know for the final exam. For each data structure listed below, make sure you can do the following: 1. Give an example of this data structure

1 ADTs,, Arrays, Linked Lists Outline and Required Reading: ADTs ( 2.1.2) Arrays ( 1.5) Linked Lists ( 4.3.1, 4.3.2) COSC 2011, Fall 2003, Section A Instructor: N. Vlajic Abstract Data Type (ADT) 2 abstract

### Binary Search Trees > = Binary Search Trees 1. 2004 Goodrich, Tamassia

Binary Search Trees < 6 2 > = 1 4 8 9 Binary Search Trees 1 Binary Search Trees A binary search tree is a binary tree storing keyvalue entries at its internal nodes and satisfying the following property:

### Lecture 11 Array of Linked Lists

Lecture 11 Array of Linked Lists In this lecture Array of Linked Lists Creating an Array of Linked Lists Representing a Sparse Matrix Defining a Node for Sparse Matrix Exercises Solutions An Array of Linked

### Balanced Binary Search Tree

AVL Trees / Slide 1 Balanced Binary Search Tree Worst case height of binary search tree: N-1 Insertion, deletion can be O(N) in the worst case We want a tree with small height Height of a binary tree with

### Sample Questions Csci 1112 A. Bellaachia

Sample Questions Csci 1112 A. Bellaachia Important Series : o S( N) 1 2 N N i N(1 N) / 2 i 1 o Sum of squares: N 2 N( N 1)(2N 1) N i for large N i 1 6 o Sum of exponents: N k 1 k N i for large N and k

### Short Notes on Dynamic Memory Allocation, Pointer and Data Structure

Short Notes on Dynamic Memory Allocation, Pointer and Data Structure 1 Dynamic Memory Allocation in C/C++ Motivation /* a[100] vs. *b or *c */ Func(int array_size) double k, a[100], *b, *c; b = (double

### C Primer. Fall Introduction C vs. Java... 1

CS 33 Intro Computer Systems Doeppner C Primer Fall 2016 Contents 1 Introduction 1 1.1 C vs. Java.......................................... 1 2 Functions 1 2.1 The main() Function....................................

### C++ Keywords. If/else Selection Structure. Looping Control Structures. Switch Statements. Example Program

C++ Keywords There are many keywords in C++ that are not used in other languages. bool, const_cast, delete, dynamic_cast, const, enum, extern, register, sizeof, typedef, explicit, friend, inline, mutable,

### M-way Trees and B-Trees

Carlos Moreno cmoreno @ uwaterloo.ca EIT-4103 https://ece.uwaterloo.ca/~cmoreno/ece250 Standard reminder to set phones to silent/vibrate mode, please! Once upon a time... in a course that we all like to

### Heaps & Priority Queues in the C++ STL 2-3 Trees

Heaps & Priority Queues in the C++ STL 2-3 Trees CS 3 Data Structures and Algorithms Lecture Slides Friday, April 7, 2009 Glenn G. Chappell Department of Computer Science University of Alaska Fairbanks

### Sequential Data Structures

Sequential Data Structures In this lecture we introduce the basic data structures for storing sequences of objects. These data structures are based on arrays and linked lists, which you met in first year

### Lecture Notes on Binary Search Trees

Lecture Notes on Binary Search Trees 15-122: Principles of Imperative Computation Frank Pfenning Lecture 17 March 17, 2010 1 Introduction In the previous two lectures we have seen how to exploit the structure

### Full and Complete Binary Trees

Full and Complete Binary Trees Binary Tree Theorems 1 Here are two important types of binary trees. Note that the definitions, while similar, are logically independent. Definition: a binary tree T is full

### International Journal Of Engineering Research & Management Technology

International Journal Of Engineering Research & Management Technology ISSN: 2348-4039 September- 2014 Volume 1, Issue-5 Dynamic Implementation Using Linked List Karuna Department of Information and Technology

### Binary Heaps. CSE 373 Data Structures

Binary Heaps CSE Data Structures Readings Chapter Section. Binary Heaps BST implementation of a Priority Queue Worst case (degenerate tree) FindMin, DeleteMin and Insert (k) are all O(n) Best case (completely

### Home Page. Data Structures. Title Page. Page 1 of 24. Go Back. Full Screen. Close. Quit

Data Structures Page 1 of 24 A.1. Arrays (Vectors) n-element vector start address + ielementsize 0 +1 +2 +3 +4... +n-1 start address continuous memory block static, if size is known at compile time dynamic,

### Data Structures and Algorithms

Data Structures and Algorithms CS245-2016S-05 Abstract Data Types and Lists David Galles Department of Computer Science University of San Francisco 05-0: Abstract Data Types Recall that an Abstract Data

### GRAPH THEORY LECTURE 4: TREES

GRAPH THEORY LECTURE 4: TREES Abstract. 3.1 presents some standard characterizations and properties of trees. 3.2 presents several different types of trees. 3.7 develops a counting method based on a bijection

### In our lecture about Binary Search Trees (BST) we have seen that the operations of searching for and inserting an element in a BST can be of the

In our lecture about Binary Search Trees (BST) we have seen that the operations of searching for and inserting an element in a BST can be of the order O(log n) (in the best case) and of the order O(n)

### CS 253: Algorithms. Chapter 12. Binary Search Trees. * Deletion and Problems. Credit: Dr. George Bebis

CS 2: Algorithms Chapter Binary Search Trees * Deletion and Problems Credit: Dr. George Bebis Binary Search Trees Tree representation: A linked data structure in which each node is an object Node representation:

### Course: Programming II - Abstract Data Types. The ADT Stack. A stack. The ADT Stack and Recursion Slide Number 1

Definition Course: Programming II - Abstract Data Types The ADT Stack The ADT Stack is a linear sequence of an arbitrary number of items, together with access procedures. The access procedures permit insertions

### Lecture 3. Arrays. Name of array. c[0] c[1] c[2] c[3] c[4] c[5] c[6] c[7] c[8] c[9] c[10] c[11] Position number of the element within array c

Lecture 3 Data structures arrays structs C strings: array of chars Arrays as parameters to functions Multiple subscripted arrays Structs as parameters to functions Default arguments Inline functions Redirection

### CHAPTER 4 THE PARALLEL ALGORITHM FOR DETECTION AND EXECUTION OF ARITHMETIC OPERATIONS AT INTRAINSTRUCTION LEVEL

39 CHAPTER 4 THE PARALLEL ALGORITHM FOR DETECTION AND EXECUTION OF ARITHMETIC OPERATIONS AT INTRAINSTRUCTION LEVEL In this chapter the relevant work of parallelism exploitation within a single statement

### 2. Compressing data to reduce the amount of transmitted data (e.g., to save money).

Presentation Layer The presentation layer is concerned with preserving the meaning of information sent across a network. The presentation layer may represent (encode) the data in various ways (e.g., data

### CSE 326: Data Structures B-Trees and B+ Trees

Announcements (4//08) CSE 26: Data Structures B-Trees and B+ Trees Brian Curless Spring 2008 Midterm on Friday Special office hour: 4:-5: Thursday in Jaech Gallery (6 th floor of CSE building) This is

### One Dimension Array: Declaring a fixed-array, if array-name is the name of an array

Arrays in Visual Basic 6 An array is a collection of simple variables of the same type to which the computer can efficiently assign a list of values. Array variables have the same kinds of names as simple

Linked Lists Ch 17 (Gaddis) Introduction to Linked Lists A data structure representing a A series of nodes chained together in sequence CS 3358 Summer I 2012 Jill Seaman - Each node points to one other

### SYSTEMS PROGRAMMING C++ INTRODUCTION

Faculty of Computer Science / Institute of Systems Architecture / Operating Systems SYSTEMS PROGRAMMING C++ INTRODUCTION Alexander Warg WHY C++? C++ is the language that allows to express ideas from the