CSCI 103 Algorithms and Problem Solving
Tutorial Exercises 3
October December 2016
Linked Lists
Stacks and Queues
Tutorial Exercises 3
Objectives
After the completion of these exercises, the student should be able to:
Traverse, search and delete nodes f
FAMILIES OF DISTRIBUTIONS
Parametric Families: Functional form indexed by parameters (e.g. , 2 ) Each
member has a specific value for each parameter.
Exponential Family: A family of pdfs or pmfs is called an exponential family if it can be
represented as
USEFUL INEQUALITIES AND IDENTITIES
Numerical Inequalities:
Lemma 1: Let a,b be positive numbers and p,q be positive numbers greater than 1
satisfying:
1 1
1
1
+ = 1 , then a p + b q ab
p q
p
q
Holders Inequality: Let X, Y be any rvs and let p and q satisf
PROPERTIES OF A RANDOM SAMPLE
Background Concepts:
Def: The random variables X i ,i = 1,.n are called a random sample of size n from the
population f ( x ) if X i ,i = 1,.n are mutually independent random variables and the
marginal pdf (pmf) of each X i i
MINIMAL SUFFICIENT STATISTICS
If a statistic is sufficient, then so is an augmented statistic S ' ( S ,T ) . Since the goal is
to summarize information concisely, we desire to work with minimal sufficient
statistics.
Def: A statistic S= T ( X ) is minimal
RATIO OF LIKELIHOODS AS SUFFICIENT STATISTICS
Given two pdfs (or pmfs) f o ( x ) , f1 ( x ) and propose a statistic, S =
f1 ( x )
fo ( x )
(the ratio of
likelihoods) for a single observation. The two pdfs (pmfs) can (but need not be) the
same distribution
PRINCIPLES OF DATA REDUCTION
Goal: Make inferences about a parameter(s) in a family using a sample X i , i = 1,.n .
Data Reduction: Functions of the data called statistics may summarize all the information in the
sample about the parameter(s). This is oft
PRINCIPLES OF DATA REDUCTION
1. Def: Likelihood Function: If f ( x ) is the pdf (pmf) of X = ( X 1 , X n ) and we
observe X = x , the likelihood function of is L ( x ) = f ( x ) .
2. Def: Likelihood Principle: If x, y are two sample points (different samp
ANCILLIARY STATISTICS
Def: A statistic S ( X ) whose distribution is not a function of is an ancillary statistic.
Consider the situation where S is the minimal sufficient statistic for and the dim ( S ) > dim ( ) .
Then sometimes we can write S = (T,C ) .
BAYESIAN ESTIMATION
Assumptions:
Classical Inference: Parameters are constants that are unknown. They are
estimated from samples of data. The estimators are random variables.
Bayesian Inference: Parameters are random variables. The parameters of their
ass
POINT ESTIMATION
Def: A point estimator is any function W ( X 1 ,.X n ) of a sample.
So, any statistic is a point estimator but in order to be useful, estimators must have
good properties. We will study different methods of computing point estimators, the
April June 2016
CSCI 103 Algorithms and Problem Solving
Tutorial Exercises 2
Tutorial Exercises 2
More on Problem Solving
Sorting and Searching
Objectives
After the completion of these exercises, the student should be able to:
Understand the concept of in
CSCI 103 Algorithms and Problem Solving
Tutorial Exercise 1
October - December 2016
Introduction to Problem Solving
Pseudocode and Flowcharts
Tutorial Exercise 1
Objectives
After the completion of these exercises, the students should be able to:
Understa
CSCI103 Algorithm and Problem Solving
Lecture Exercises 4
Lecture Exercises 4
Sorting and Searching
Question 1: Selection Sort
Trace the sort for every pass until the list of numbers is sorted in ascending order.
For each pass, indicate clearly the values
CSCI103 Algorithm and Problem Solving
Lecture Exercises 5
Lecture Exercises 5
Linked lists
sortList
3
count
55
70
80
head
Figure 1: sortList Linked List
Question 1: Defining and creating Linked List
(a) Define the data structures to create a linked list
CSCI103 Algorithm and Problem Solving
Lecture Exercises 3
Lecture Exercises 3
More on Problem Solving
Question 1
Peter and his three young children (Andrew, John and Matthew) want to
cross to the other side of the river. His boat can carry at most two per
CSCI103 Algorithm and Problem Solving
Lecture Exercises 1
Lecture Exercises 1
Introduction to Problem Solving
Question 1
Identify the start state, goal state, operators and constraints (if any) in the followin
g problem:
What is the result of 20 +234 X 56
CSCI 103 Algorithms and Problem Solving
Tutorial Exercise 1
October - December 2016
Introduction to Problem Solving
Pseudocode and Flowcharts
Tutorial Exercise 1
Objectives
After the completion of these exercises, the students should be able to:
Underst
CSCI 103 Algorithms and Problem Solving
Tutorial Exercises 2
Tutorial Exercises 2
October December 2016
More on Problem Solving
Sorting and Searching
Objectives
After the completion of these exercises, the student should be able to:
Understand the concep
Lecture 2
Pseudocode and Flowcharts
CSCI 103 Algorithms & Problem Solving
October December 2016
Topics
Flowchart
Pseudocode
Using Flowchart and Pseudocode
Basic Data Types
Basic Data Structures
Modularisation
CSCI 103
2
Recall:
Algorithm
An algorit
CSCI103 Algorithm and Problem Solving
Lecture Exercises 6
Lecture Exercises 6
Stacks and Queues
Question 1: Stacks
(a) The figure below shows a stack S implemented using a linked list.
Stack S
2
count
S24
S80
top
Draw a diagram to show the stack S after t
CSCI103 Algorithm and Problem Solving
Lecture Exercises 5
Lecture Exercises 5
Linked lists
sortList
3
count
55
70
80
head
Figure 1: sortList Linked List
Question 1: Defining and creating Linked List
(a) Define the data structures to create a linked list c
Lecture 5
Linked Lists
CSCI 103 Algorithms & Problem Solving
October December 2016
Topics
What are linked lists ?
Create List
Insert Node
Delete Node
Traversing a Linked List
Doubly Linked List
CSCI 103
2
What are Linked Lists ?
3
Linear
List
. 1
A
COMPLETE FAMILIES OF STATISTICS
Def: Assume that f ( t ) is the family of pdfs (pmfs) for the statistic T ( X ) , (which is
random variable). The family is called complete if E g (T ) = 0 implies that
P ( g ( T ) = 0 ) = 1 . The statistic T ( X ) is also