Algorithm Analysis
CENG 213 Data Structures 1
Algorithm
An algorithm is a set of instructions to be followed to
solve a problem.
There can be more than one solution (more than one
algorithm) to solv
#include <cstdlib>/ This library is added for the NULL keyword
class StackException/ Throw this exception class when invalid stack operation is performed
cfw_
public:
StackException() : message( "S
!MIDDLE EAST TECHNICAL UNIVERSITY, NORTHERN CYPRUS CAMPUS
CNG213 C Programming Programming Assignment 2!
Date handed out:
Sunday 22 November 2015
Date submission due: Monday 7 December 2015
Path Finde
MIDDLE EAST TECHNICAL UNIVERSITY, NORTHERN CYPRUS CAMPUS
CNG213 C Programming Programming Assignment 1
Date handed out:
Wednesday 04 November 2015
Date submission due: Monday 16 Nove
!MIDDLE EAST TECHNICAL UNIVERSITY, NORTHERN CYPRUS CAMPUS
CNG213 C Programming Programming Assignment 4!
Date handed out:
Sunday 27 December 2015
Date submission due: Friday 08 January 2016
Indexing T
Trees
1
Preliminaries (continued)
A path from node n1 to nk is defined as a sequence of
nodes n1, n2, , nk such that ni is parent of ni+1 (1 i < k)
The length of a path is the number of edges on tha
Abstract Data Types (ADTs)
An abstract data type (ADT) is an abstraction of a data structure
An ADT specifies:
Data stored
Operations on the data
Error conditions associated with operations
01/17
Sorting Algorithms
Sorting
Sorting is a process that organizes a collection of data into either ascending or
descending order.
An internal sort requires that the collection of data fit entirely in the
Recursion
CENG 707
1
Recursion
Recursion is a technique that solves a problem by solving
a smaller problem of the same type.
A recursive function is a function invoking itself, either
directly or in
The Abstract Data Type Queue
A queue is a list from which items are deleted from one end ( front)
and into which items are inserted at the other end ( rear, or back)
It is like line of people waitin
Linked Lists
1
Linked List Basics
Linked lists and arrays are similar since they both
store collections of data.
The array's features all follow from its strategy of
allocating the memory for all it
Intoduction to C+
1
Programming in C+
C+
Improves on many of C's features
Has object-oriented capabilities
Increases software quality and reusability
Developed by Bjarne Stroustrup at Bell Labs
!MIDDLE EAST TECHNICAL UNIVERSITY, NORTHERN CYPRUS CAMPUS
CNG213 C Programming Programming Assignment 3!
Date handed out:
11 December 2015, Friday
Date submission due: 24 December 2015, Thursday
Telep
Sorting Algorithms
CENG 213 Data Structures
Sorting
Sorting is a process that organizes a collection of data into either ascending or
descending order.
An internal sort requires that the collection of
#include <vector>
#include <string>
using namespace std;
class Recipe
cfw_
public:
struct Ingredient/ Ingredients of the recipe
cfw_
string name;/ name of the ingredient
int cost;/ cost of the i
#include <cstdlib>/ This library is added for the NULL keyword
#include <string>
using namespace std;
class LinkedAndXOrBinaryTreeException/ Throw this exception class when invalid tree operation is p
The Abstract Data Type Queue
A queue is a list from which items are deleted from one end (front)
and into which items are inserted at the other end (rear, or back)
It is like line of people waiting
GRAPHS Definitions
A graph G = (V, E) consists of
a set of vertices, V, and
a set of edges, E, where each edge is a pair (v,w) s.t. v,w V
Vertices are sometimes called nodes, edges are sometimes c
Priority Queues
(Heaps)
CENG 213 Data Struc
1
Priority Queues
Many applications require that we process records
with keys in order, but not necessarily in full sorted
order.
Often we collect a set o
Linked Lists
CENG 213 Data Struc
1
Linked List Basics
Linked lists and arrays are similar since they both
store collections of data.
The array's features all follow from its strategy of
allocating t
Intoduction to C+
CENG 213 Data Structures
1
Programming in C+
C+
Improves on many of C's features
Has object-oriented capabilities
Increases software quality and reusability
Developed by Bjarne
Trees
1
Outline
Preliminaries
What is Tree?
Implementation of Trees using C+
Tree traversals and applications
Binary Trees
Binary Search Trees
Structure and operations
Analysis
AVL Trees
2
Wh
AVL Trees
CENG 213 Data Struc
1
AVL Trees
An AVL tree is a binary search tree with a balance condition.
AVL is named for its inventors: Adelson-Velskii and Landis
AVL tree approximates the ideal tree
Abstract Data Types (ADTs)
An abstract data type (ADT) is an abstraction of a data structure
An ADT specifies:
Data stored
Operations on the data
Error conditions associated with operations
09/17
CENG 707
Data Structures and
Algorithms
Nihan Kesim iekli
Department of Computer Engineering
Middle East Technical University
Fall 2012
1
CENG 707
Instructor: Nihan Kesim iekli
Office: A308
Email: nih
CENG 707
Data Structures and
Algorithms
Nihan Kesim iekli
Department of Computer Engineering
Middle East Technical University
Fall 2010
1
CENG 707
Instructor: Nihan Kesim iekli
Office: A308
Email: nih
Priority Queues
(Heaps)
1
Priority Queues
Many applications require that we process records
with keys in order, but not necessarily in full sorted
order.
Often we collect a set of items and process
General Trees
General trees are similar to binary trees, except
that there is no restriction on the number of
children that any node may have.
General Trees
Chapter 7
Well, non-binary trees anyway.
Ge